Search in sources :

Example 46 with RoutedCollectPhase

use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.

the class DocLevelCollectTest method testCollectDocLevelWhereClause.

@Test
public void testCollectDocLevelWhereClause() throws Throwable {
    EqOperator op = (EqOperator) functions.get(new FunctionIdent(EqOperator.NAME, ImmutableList.<DataType>of(DataTypes.INTEGER, DataTypes.INTEGER)));
    List<Symbol> toCollect = Collections.<Symbol>singletonList(testDocLevelReference);
    WhereClause whereClause = new WhereClause(new Function(op.info(), Arrays.<Symbol>asList(testDocLevelReference, Literal.of(2))));
    RoutedCollectPhase collectNode = getCollectNode(toCollect, whereClause);
    Bucket result = collect(collectNode);
    assertThat(result, contains(isRow(2)));
}
Also used : Function(io.crate.analyze.symbol.Function) EqOperator(io.crate.operation.operator.EqOperator) Bucket(io.crate.data.Bucket) Symbol(io.crate.analyze.symbol.Symbol) WhereClause(io.crate.analyze.WhereClause) RoutedCollectPhase(io.crate.planner.node.dql.RoutedCollectPhase) SQLTransportIntegrationTest(io.crate.integrationtests.SQLTransportIntegrationTest) Test(org.junit.Test)

Example 47 with RoutedCollectPhase

use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.

the class HandlerSideLevelCollectTest method testClusterLevel.

@Test
public void testClusterLevel() throws Exception {
    Schemas schemas = internalCluster().getInstance(Schemas.class);
    TableInfo tableInfo = schemas.getTableInfo(new TableIdent("sys", "cluster"));
    Routing routing = tableInfo.getRouting(WhereClause.MATCH_ALL, null);
    Reference clusterNameRef = new Reference(new ReferenceIdent(SysClusterTableInfo.IDENT, new ColumnIdent(ClusterNameExpression.NAME)), RowGranularity.CLUSTER, DataTypes.STRING);
    RoutedCollectPhase collectNode = collectNode(routing, Arrays.<Symbol>asList(clusterNameRef), RowGranularity.CLUSTER);
    Bucket result = collect(collectNode);
    assertThat(result.size(), is(1));
    assertThat(((BytesRef) result.iterator().next().get(0)).utf8ToString(), Matchers.startsWith("SUITE-"));
}
Also used : 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)

Example 48 with RoutedCollectPhase

use of io.crate.planner.node.dql.RoutedCollectPhase 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

RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)48 Test (org.junit.Test)36 CrateUnitTest (io.crate.test.integration.CrateUnitTest)25 Collect (io.crate.planner.node.dql.Collect)18 MergePhase (io.crate.planner.node.dql.MergePhase)15 Merge (io.crate.planner.Merge)14 Routing (io.crate.metadata.Routing)10 Symbol (io.crate.analyze.symbol.Symbol)8 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)8 DistributedGroupBy (io.crate.planner.node.dql.DistributedGroupBy)7 Bucket (io.crate.data.Bucket)6 Reference (io.crate.metadata.Reference)6 Row (io.crate.data.Row)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 OrderBy (io.crate.analyze.OrderBy)3 Function (io.crate.analyze.symbol.Function)3 CollectionBucket (io.crate.data.CollectionBucket)3