Search in sources :

Example 1 with InformationSchemaInfo

use of io.crate.metadata.information.InformationSchemaInfo in project crate by crate.

the class HandlerSideLevelCollectTest method testInformationSchemaColumns.

@Test
public void testInformationSchemaColumns() throws Exception {
    InformationSchemaInfo schemaInfo = internalCluster().getInstance(InformationSchemaInfo.class);
    TableInfo tableInfo = schemaInfo.getTableInfo("columns");
    assert tableInfo != null;
    Routing routing = tableInfo.getRouting(WhereClause.MATCH_ALL, null);
    List<Symbol> toCollect = new ArrayList<>();
    for (Reference ref : tableInfo.columns()) {
        toCollect.add(ref);
    }
    RoutedCollectPhase collectNode = collectNode(routing, toCollect, RowGranularity.DOC);
    Bucket result = collect(collectNode);
    String expected = "id| string| NULL| false| true| 1| cluster| sys\n" + "master_node| string| NULL| false| true| 2| cluster| sys\n" + "name| string| NULL| false| true| 3| cluster| sys\n" + "settings| object| NULL| false| true| 4| cluster| sys\n";
    assertThat(TestingHelpers.printedTable(result), Matchers.containsString(expected));
    // second time - to check if the internal iterator resets
    result = collect(collectNode);
    assertThat(TestingHelpers.printedTable(result), Matchers.containsString(expected));
}
Also used : InformationSchemaInfo(io.crate.metadata.information.InformationSchemaInfo) Bucket(io.crate.data.Bucket) CollectionBucket(io.crate.data.CollectionBucket) Symbol(io.crate.analyze.symbol.Symbol) ArrayList(java.util.ArrayList) TableInfo(io.crate.metadata.table.TableInfo) SysClusterTableInfo(io.crate.metadata.sys.SysClusterTableInfo) RoutedCollectPhase(io.crate.planner.node.dql.RoutedCollectPhase) SQLTransportIntegrationTest(io.crate.integrationtests.SQLTransportIntegrationTest) Test(org.junit.Test)

Example 2 with InformationSchemaInfo

use of io.crate.metadata.information.InformationSchemaInfo in project crate by crate.

the class HandlerSideLevelCollectTest method testInformationSchemaTables.

@Test
public void testInformationSchemaTables() throws Exception {
    InformationSchemaInfo schemaInfo = internalCluster().getInstance(InformationSchemaInfo.class);
    TableInfo tablesTableInfo = schemaInfo.getTableInfo("tables");
    Routing routing = tablesTableInfo.getRouting(WhereClause.MATCH_ALL, null);
    List<Symbol> toCollect = new ArrayList<>();
    for (Reference reference : tablesTableInfo.columns()) {
        toCollect.add(reference);
    }
    Symbol tableNameRef = toCollect.get(8);
    FunctionImplementation eqImpl = functions.get(new FunctionIdent(EqOperator.NAME, ImmutableList.of(DataTypes.STRING, DataTypes.STRING)));
    Function whereClause = new Function(eqImpl.info(), Arrays.asList(tableNameRef, Literal.of("shards")));
    RoutedCollectPhase collectNode = collectNode(routing, toCollect, RowGranularity.DOC, new WhereClause(whereClause));
    Bucket result = collect(collectNode);
    assertThat(TestingHelpers.printedTable(result), is("NULL| NULL| strict| 0| 1| NULL| NULL| NULL| shards| sys| NULL\n"));
}
Also used : Symbol(io.crate.analyze.symbol.Symbol) ArrayList(java.util.ArrayList) WhereClause(io.crate.analyze.WhereClause) Function(io.crate.analyze.symbol.Function) InformationSchemaInfo(io.crate.metadata.information.InformationSchemaInfo) Bucket(io.crate.data.Bucket) CollectionBucket(io.crate.data.CollectionBucket) TableInfo(io.crate.metadata.table.TableInfo) SysClusterTableInfo(io.crate.metadata.sys.SysClusterTableInfo) RoutedCollectPhase(io.crate.planner.node.dql.RoutedCollectPhase) SQLTransportIntegrationTest(io.crate.integrationtests.SQLTransportIntegrationTest) Test(org.junit.Test)

Aggregations

Symbol (io.crate.analyze.symbol.Symbol)2 Bucket (io.crate.data.Bucket)2 CollectionBucket (io.crate.data.CollectionBucket)2 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)2 InformationSchemaInfo (io.crate.metadata.information.InformationSchemaInfo)2 SysClusterTableInfo (io.crate.metadata.sys.SysClusterTableInfo)2 TableInfo (io.crate.metadata.table.TableInfo)2 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 WhereClause (io.crate.analyze.WhereClause)1 Function (io.crate.analyze.symbol.Function)1