sourceMetastore.createDatabase(HCatCreateDBDesc.create(dbName).ifNotExists(false).build());
@Test public void testDatabaseLocation() throws Exception { HCatClient client = HCatClient.create(new Configuration(hcatConf)); String dbName = "locationDB"; client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE); HCatCreateDBDesc dbDesc = HCatCreateDBDesc.create(dbName) .ifNotExists(true).location("/tmp/" + dbName).build(); client.createDatabase(dbDesc); HCatDatabase newDB = client.getDatabase(dbName); assertTrue(newDB.getLocation().matches(".*/tmp/" + dbName)); client.close(); }
/** * Creates the builder for defining attributes. * * @param dbName the db name * @return the builder */ public static Builder create(String dbName) { return new Builder(dbName); }
/** * Creates the builder for defining attributes. * * @param dbName the db name * @return the builder */ public static Builder create(String dbName) { return new Builder(dbName); }
public void createDatabase(String db, String location) throws Exception { HCatCreateDBDesc dbDesc = HCatCreateDBDesc.create(db).ifNotExists(true).location(location).build(); hcatClient.createDatabase(dbDesc); List<String> dbNames = hcatClient.listDatabaseNamesByPattern(db); Assert.assertTrue(dbNames.contains(db)); }
/** * Creates the builder for defining attributes. * * @param dbName the db name * @return the builder */ public static Builder create(String dbName) { return new Builder(dbName); }
client.dropDatabase(db, true, HCatClient.DropDBMode.CASCADE); HCatCreateDBDesc dbDesc = HCatCreateDBDesc.create(db).ifNotExists(false) .build(); client.createDatabase(dbDesc); List<String> dbNames = client.listDatabaseNamesByPattern("*");
client.createDatabase(HCatCreateDBDesc.create(dbName).ifNotExists(false).build());
client.createDatabase(HCatCreateDBDesc.create(dbName).ifNotExists(false).build());
.ifNotExists(true).build(); client.createDatabase(dbDesc); ArrayList<HCatFieldSchema> cols = new ArrayList<HCatFieldSchema>();
client.createDatabase(HCatCreateDBDesc.create(dbName).build()); List<HCatFieldSchema> columnSchema = Arrays.asList(new HCatFieldSchema("foo", Type.INT, ""), new HCatFieldSchema("bar", Type.STRING, ""));
client.createDatabase(HCatCreateDBDesc.create(dbName).build());
client.createDatabase(HCatCreateDBDesc.create(dbName).ifNotExists(false).build());
client.createDatabase(HCatCreateDBDesc.create(dbName).ifNotExists(false).build());
client.createDatabase(HCatCreateDBDesc.create(dbName).ifNotExists(false).build());
client.createDatabase(HCatCreateDBDesc.create(dbName).build()); List<HCatFieldSchema> columnSchema = Arrays.asList(new HCatFieldSchema("foo", Type.INT, ""), new HCatFieldSchema("bar", Type.STRING, ""));
@Test public void testPartitionSchema() throws Exception { try { HCatClient client = HCatClient.create(new Configuration(hcatConf)); final String dbName = "myDb"; final String tableName = "myTable"; client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE); client.createDatabase(HCatCreateDBDesc.create(dbName).build()); List<HCatFieldSchema> columnSchema = Arrays.asList(new HCatFieldSchema("foo", Type.INT, ""), new HCatFieldSchema("bar", Type.STRING, "")); List<HCatFieldSchema> partitionSchema = Arrays.asList(new HCatFieldSchema("dt", Type.STRING, ""), new HCatFieldSchema("grid", Type.STRING, "")); client.createTable(HCatCreateTableDesc.create(dbName, tableName, columnSchema).partCols(partitionSchema).build()); HCatTable table = client.getTable(dbName, tableName); List<HCatFieldSchema> partitionColumns = table.getPartCols(); assertArrayEquals("Didn't get expected partition-schema back from the HCatTable.", partitionSchema.toArray(), partitionColumns.toArray()); client.dropDatabase(dbName, false, HCatClient.DropDBMode.CASCADE); } catch (Exception unexpected) { LOG.error("Unexpected exception!", unexpected); assertTrue("Unexpected exception! " + unexpected.getMessage(), false); } }