use of org.apache.drill.exec.proto.UserProtos.GetTablesResp 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.GetTablesResp in project drill by apache.
the class TestMetadataProvider method tablesWithTableNameFilterAndSchemaNameFilter.
@Test
public void tablesWithTableNameFilterAndSchemaNameFilter() throws Exception {
// test("SELECT * FROM INFORMATION_SCHEMA.`TABLES` " +
// "WHERE TABLE_SCHEMA LIKE '%N\\_S%' ESCAPE '\\' AND TABLE_NAME LIKE '%o%'"); // SQL equivalent
GetTablesResp resp = client.getTables(null, LikeFilter.newBuilder().setPattern("%N\\_S%").setEscape("\\").build(), LikeFilter.newBuilder().setPattern("%o%").build(), null).get();
assertEquals(RequestStatus.OK, resp.getStatus());
List<TableMetadata> tables = resp.getTablesList();
assertEquals(0, tables.size());
}
use of org.apache.drill.exec.proto.UserProtos.GetTablesResp 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(4, tables.size());
verifyTable("sys", "boot", tables);
verifyTable("sys", "memory", tables);
verifyTable("sys", "options", tables);
verifyTable("sys", "version", tables);
}
use of org.apache.drill.exec.proto.UserProtos.GetTablesResp in project drill by apache.
the class TestMetadataProvider method tablesWithTableFilter.
@Test
public void tablesWithTableFilter() throws Exception {
// test("SELECT * FROM INFORMATION_SCHEMA.`TABLES` WHERE TABLE_TYPE IN ('TABLE')"); // SQL equivalent
GetTablesResp resp = client.getTables(null, null, null, Arrays.asList("TABLE")).get();
assertEquals(RequestStatus.OK, resp.getStatus());
List<TableMetadata> tables = resp.getTablesList();
assertTrue(tables.isEmpty());
}
use of org.apache.drill.exec.proto.UserProtos.GetTablesResp in project drill by apache.
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(11, 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", "options", tables);
verifyTable("sys", "threads", tables);
verifyTable("sys", "version", tables);
}
Aggregations