Search in sources :

Example 6 with TableMetadata

use of org.apache.drill.exec.proto.UserProtos.TableMetadata 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, Collections.singletonList("TABLE")).get();
    assertEquals(RequestStatus.OK, resp.getStatus());
    List<TableMetadata> tables = resp.getTablesList();
    assertTrue(tables.isEmpty());
}
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 7 with TableMetadata

use of org.apache.drill.exec.proto.UserProtos.TableMetadata 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());
}
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 8 with TableMetadata

use of org.apache.drill.exec.proto.UserProtos.TableMetadata in project drill by axbaretto.

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());
}
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 9 with TableMetadata

use of org.apache.drill.exec.proto.UserProtos.TableMetadata in project drill by axbaretto.

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());
}
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 10 with TableMetadata

use of org.apache.drill.exec.proto.UserProtos.TableMetadata in project drill by axbaretto.

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)

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