Search in sources :

Example 1 with TableMetadata

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);
}
Also used : TableMetadata(org.apache.drill.exec.proto.UserProtos.TableMetadata) GetTablesResp(org.apache.drill.exec.proto.UserProtos.GetTablesResp) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest)

Example 2 with TableMetadata

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);
}
Also used : TableMetadata(org.apache.drill.exec.proto.UserProtos.TableMetadata) GetTablesResp(org.apache.drill.exec.proto.UserProtos.GetTablesResp) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest)

Example 3 with TableMetadata

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);
}
Also used : TableMetadata(org.apache.drill.exec.proto.UserProtos.TableMetadata) GetTablesResp(org.apache.drill.exec.proto.UserProtos.GetTablesResp) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest)

Example 4 with TableMetadata

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));
}
Also used : LikeFilter(org.apache.drill.exec.proto.UserProtos.LikeFilter) TableMetadata(org.apache.drill.exec.proto.UserProtos.TableMetadata) DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) GetTablesResp(org.apache.drill.exec.proto.UserProtos.GetTablesResp) ArrayList(java.util.ArrayList) List(java.util.List) MetaImpl(org.apache.calcite.avatica.MetaImpl) RequestStatus(org.apache.drill.exec.proto.UserProtos.RequestStatus)

Example 5 with TableMetadata

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);
        }
    }
}
Also used : TableMetadata(org.apache.drill.exec.proto.UserProtos.TableMetadata) GetTablesResp(org.apache.drill.exec.proto.UserProtos.GetTablesResp) SystemTable(org.apache.drill.exec.store.sys.SystemTable) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest)

Aggregations

GetTablesResp (org.apache.drill.exec.proto.UserProtos.GetTablesResp)12 TableMetadata (org.apache.drill.exec.proto.UserProtos.TableMetadata)12 OptionsTest (org.apache.drill.categories.OptionsTest)10 Test (org.junit.Test)10 SystemTable (org.apache.drill.exec.store.sys.SystemTable)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MetaImpl (org.apache.calcite.avatica.MetaImpl)2 DrillPBError (org.apache.drill.exec.proto.UserBitShared.DrillPBError)2 LikeFilter (org.apache.drill.exec.proto.UserProtos.LikeFilter)2 RequestStatus (org.apache.drill.exec.proto.UserProtos.RequestStatus)2