@Test public void getTableMeta() throws TException { String dbName = "db9"; // For this one don't specify a location to make sure it gets put in the catalog directory Database db = new DatabaseBuilder() .setName(dbName) .build(conf); db.unsetCatalogName(); client.createDatabase(db); String[] tableNames = {"table_in_other_catalog_1", "table_in_other_catalog_2", "random_name"}; List<TableMeta> expected = new ArrayList<>(tableNames.length); for (int i = 0; i < tableNames.length; i++) { Table table = new TableBuilder() .inDb(db) .setTableName(tableNames[i]) .addCol("id", "int") .addCol("name", "string") .build(conf); table.unsetCatName(); client.createTable(table); TableMeta tableMeta = new TableMeta(dbName, tableNames[i], TableType.MANAGED_TABLE.name()); tableMeta.setCatName(expectedCatalog()); expected.add(tableMeta); } List<String> types = Collections.singletonList(TableType.MANAGED_TABLE.name()); List<TableMeta> actual = client.getTableMeta(dbName, "*", types); Assert.assertEquals(new TreeSet<>(expected), new TreeSet<>(actual)); actual = client.getTableMeta("*", "table_*", types); Assert.assertEquals(expected.subList(0, 2), actual.subList(0, 2)); }
t.unsetCatName(); client.createTable(t);
.addTableParam("PARTITION_LEVEL_PRIVILEGE", "true") .build(conf); table.unsetCatName(); client.createTable(table);
@Test public void tablesGetExists() throws TException { String dbName = "db_in_other_catalog"; // For this one don't specify a location to make sure it gets put in the catalog directory Database db = new DatabaseBuilder() .setName(dbName) .build(conf); db.unsetCatalogName(); client.createDatabase(db); String[] tableNames = new String[4]; for (int i = 0; i < tableNames.length; i++) { tableNames[i] = "table_in_other_catalog_" + i; Table table = new TableBuilder() .inDb(db) .setTableName(tableNames[i]) .addCol("col1_" + i, ColumnType.STRING_TYPE_NAME) .addCol("col2_" + i, ColumnType.INT_TYPE_NAME) .build(conf); table.unsetCatName(); client.createTable(table); } Set<String> tables = new HashSet<>(client.getTables(dbName, "*e_in_other_*")); Assert.assertEquals(4, tables.size()); for (String tableName : tableNames) Assert.assertTrue(tables.contains(tableName)); List<String> fetchedNames = client.getTables(dbName, "*_3"); Assert.assertEquals(1, fetchedNames.size()); Assert.assertEquals(tableNames[3], fetchedNames.get(0)); Assert.assertTrue("Table exists", client.tableExists(dbName, tableNames[0])); Assert.assertFalse("Table not exists", client.tableExists(dbName, "non_existing_table")); }
.addPartCol("partcol", "string") .build(conf); table.unsetCatName(); client.createTable(table);
@Test public void tablesList() throws TException { String dbName = "db_in_other_catalog"; // For this one don't specify a location to make sure it gets put in the catalog directory Database db = new DatabaseBuilder() .setName(dbName) .build(conf); db.unsetCatalogName(); client.createDatabase(db); String[] tableNames = new String[4]; for (int i = 0; i < tableNames.length; i++) { tableNames[i] = "table_in_other_catalog_" + i; TableBuilder builder = new TableBuilder() .inDb(db) .setTableName(tableNames[i]) .addCol("col1_" + i, ColumnType.STRING_TYPE_NAME) .addCol("col2_" + i, ColumnType.INT_TYPE_NAME); if (i == 0) builder.addTableParam("the_key", "the_value"); Table table = builder.build(conf); table.unsetCatName(); client.createTable(table); } String filter = hive_metastoreConstants.HIVE_FILTER_FIELD_PARAMS + "the_key=\"the_value\""; List<String> fetchedNames = client.listTableNamesByFilter(dbName, filter, (short)-1); Assert.assertEquals(1, fetchedNames.size()); Assert.assertEquals(tableNames[0], fetchedNames.get(0)); }
.addPartCol("partcol", "string") .build(conf); table.unsetCatName(); client.createTable(table);
.addPartCol("partcol", "string") .build(conf); table.unsetCatName(); client.createTable(table);
.addCol("col6", "int") .build(conf); table.unsetCatName();
.addPartCol("partcol", "string") .build(conf); table.unsetCatName(); client.createTable(table);
unsetCatName(); } else { setCatName((String)value);
t.unsetCatName(); client.createTable(t);
unsetCatName(); } else { setCatName((String)value);