use of org.apache.drill.exec.proto.UserProtos.TableMetadata in project drill by axbaretto.
the class TestMetadataProvider method tables.
@Test
public void tables() throws Exception {
// test("SELECT * FROM INFORMATION_SCHEMA.`TABLES`"); // SQL equivalent
GetTablesResp resp = client.getTables(null, null, null, null).get();
assertEquals(RequestStatus.OK, resp.getStatus());
List<TableMetadata> tables = resp.getTablesList();
assertEquals(17, tables.size());
verifyTable("INFORMATION_SCHEMA", "CATALOGS", tables);
verifyTable("INFORMATION_SCHEMA", "COLUMNS", tables);
verifyTable("INFORMATION_SCHEMA", "SCHEMATA", tables);
verifyTable("INFORMATION_SCHEMA", "TABLES", tables);
verifyTable("INFORMATION_SCHEMA", "VIEWS", tables);
verifyTable("sys", "boot", tables);
verifyTable("sys", "drillbits", tables);
verifyTable("sys", "memory", tables);
verifyTable("sys", SystemTable.OPTION.getTableName(), tables);
verifyTable("sys", SystemTable.OPTION_VAL.getTableName(), tables);
verifyTable("sys", "threads", tables);
verifyTable("sys", "version", tables);
verifyTable("sys", SystemTable.INTERNAL_OPTIONS.getTableName(), tables);
verifyTable("sys", SystemTable.INTERNAL_OPTIONS_VAL.getTableName(), tables);
}
use of org.apache.drill.exec.proto.UserProtos.TableMetadata in project drill by axbaretto.
the class TestMetadataProvider method tablesWithSystemTableFilter.
@Test
public void tablesWithSystemTableFilter() throws Exception {
// test("SELECT * FROM INFORMATION_SCHEMA.`TABLES` WHERE TABLE_TYPE IN ('SYSTEM_TABLE')"); // SQL equivalent
GetTablesResp resp = client.getTables(null, null, null, Arrays.asList("SYSTEM_TABLE")).get();
assertEquals(RequestStatus.OK, resp.getStatus());
List<TableMetadata> tables = resp.getTablesList();
assertEquals(17, tables.size());
verifyTable("INFORMATION_SCHEMA", "CATALOGS", tables);
verifyTable("INFORMATION_SCHEMA", "COLUMNS", tables);
verifyTable("INFORMATION_SCHEMA", "SCHEMATA", tables);
verifyTable("INFORMATION_SCHEMA", "TABLES", tables);
verifyTable("INFORMATION_SCHEMA", "VIEWS", tables);
verifyTable("sys", "boot", tables);
verifyTable("sys", "drillbits", tables);
verifyTable("sys", "memory", tables);
verifyTable("sys", SystemTable.OPTION.getTableName(), tables);
verifyTable("sys", SystemTable.OPTION_VAL.getTableName(), tables);
verifyTable("sys", "threads", tables);
verifyTable("sys", "version", tables);
verifyTable("sys", SystemTable.INTERNAL_OPTIONS.getTableName(), tables);
verifyTable("sys", SystemTable.INTERNAL_OPTIONS_VAL.getTableName(), tables);
}
use of org.apache.drill.exec.proto.UserProtos.TableMetadata in project drill by axbaretto.
the class TestMetadataProvider method tablesWithTableNameFilter.
@Test
public void tablesWithTableNameFilter() throws Exception {
// test("SELECT * FROM INFORMATION_SCHEMA.`TABLES` WHERE TABLE_NAME LIKE '%o%'"); // SQL equivalent
GetTablesResp resp = client.getTables(null, null, LikeFilter.newBuilder().setPattern("%o%").build(), null).get();
assertEquals(RequestStatus.OK, resp.getStatus());
List<TableMetadata> tables = resp.getTablesList();
assertEquals(10, tables.size());
verifyTable("sys", "boot", tables);
verifyTable("sys", "memory", tables);
verifyTable("sys", SystemTable.OPTION.getTableName(), tables);
verifyTable("sys", SystemTable.OPTION_VAL.getTableName(), tables);
verifyTable("sys", "version", tables);
verifyTable("sys", SystemTable.INTERNAL_OPTIONS.getTableName(), tables);
verifyTable("sys", SystemTable.INTERNAL_OPTIONS_VAL.getTableName(), tables);
}
use of org.apache.drill.exec.proto.UserProtos.TableMetadata in project drill by apache.
the class DrillMetaImpl method serverGetTables.
private MetaResultSet serverGetTables(String catalog, final Pat schemaPattern, final Pat tableNamePattern, final List<String> typeList) {
// Catalog is not a pattern
final LikeFilter catalogNameFilter = newLikeFilter(quote(catalog));
final LikeFilter schemaNameFilter = newLikeFilter(schemaPattern);
final LikeFilter tableNameFilter = newLikeFilter(tableNamePattern);
return new MetadataAdapter<MetaImpl.MetaTable, GetTablesResp, TableMetadata>(MetaTable.class) {
@Override
protected RequestStatus getStatus(GetTablesResp response) {
return response.getStatus();
}
@Override
protected DrillPBError getError(GetTablesResp response) {
return response.getError();
}
@Override
protected List<TableMetadata> getResult(GetTablesResp response) {
return response.getTablesList();
}
@Override
protected MetaImpl.MetaTable adapt(TableMetadata protoValue) {
return new MetaImpl.MetaTable(protoValue.getCatalogName(), protoValue.getSchemaName(), protoValue.getTableName(), protoValue.getType());
}
}.getMeta(connection.getClient().getTables(catalogNameFilter, schemaNameFilter, tableNameFilter, typeList));
}
use of org.apache.drill.exec.proto.UserProtos.TableMetadata in project drill by apache.
the class TestMetadataProvider method tablesWithTableNameFilter.
@Test
public void tablesWithTableNameFilter() throws Exception {
// test("SELECT * FROM INFORMATION_SCHEMA.`TABLES` WHERE TABLE_NAME LIKE '%o%'"); // SQL equivalent
GetTablesResp resp = client.getTables(null, null, LikeFilter.newBuilder().setPattern("%o%").build(), null).get();
assertEquals(RequestStatus.OK, resp.getStatus());
List<TableMetadata> tables = resp.getTablesList();
assertEquals(12, tables.size());
// Verify System Tables
for (SystemTable sysTbl : SystemTable.values()) {
String sysTblName = sysTbl.getTableName();
if (sysTblName.contains("o")) {
verifyTable("sys", sysTblName, tables);
}
}
}
Aggregations