Search in sources :

Example 6 with Collect

use of io.crate.planner.operators.Collect in project crate by crate.

the class CollectQueryCastRulesTest method assertCollectQuery.

private void assertCollectQuery(String query, String expected) {
    var collect = new Collect(tr1, Collections.emptyList(), new WhereClause(e.asSymbol(query)), 100, 10);
    var plan = (io.crate.planner.node.dql.Collect) collect.build(plannerContext, Set.of(), new ProjectionBuilder(e.nodeCtx), TopN.NO_LIMIT, 0, null, null, Row.EMPTY, new SubQueryResults(emptyMap()) {

        @Override
        public Object getSafe(SelectSymbol key) {
            return Literal.of(key.valueType(), null);
        }
    });
    assertThat(((RoutedCollectPhase) plan.collectPhase()).where().toString(), is(expected));
}
Also used : SelectSymbol(io.crate.expression.symbol.SelectSymbol) Collect(io.crate.planner.operators.Collect) SubQueryResults(io.crate.planner.operators.SubQueryResults) WhereClause(io.crate.analyze.WhereClause) ProjectionBuilder(io.crate.execution.dsl.projection.builder.ProjectionBuilder) RoutedCollectPhase(io.crate.execution.dsl.phases.RoutedCollectPhase)

Example 7 with Collect

use of io.crate.planner.operators.Collect in project crate by crate.

the class MergeFiltersTest method testMergeFiltersMatchesOnAFilterWithAnotherFilterAsChild.

@Test
public void testMergeFiltersMatchesOnAFilterWithAnotherFilterAsChild() {
    Collect source = new Collect(tr1, Collections.emptyList(), WhereClause.MATCH_ALL, 100, 10);
    Filter sourceFilter = new Filter(source, e.asSymbol("x > 10"));
    Filter parentFilter = new Filter(sourceFilter, e.asSymbol("y > 10"));
    MergeFilters mergeFilters = new MergeFilters();
    Match<Filter> match = mergeFilters.pattern().accept(parentFilter, Captures.empty());
    assertThat(match.isPresent(), Matchers.is(true));
    assertThat(match.value(), Matchers.sameInstance(parentFilter));
    Filter mergedFilter = mergeFilters.apply(match.value(), match.captures(), new TableStats(), CoordinatorTxnCtx.systemTransactionContext(), e.nodeCtx);
    assertThat(mergedFilter.query(), isSQL("((doc.t2.y > 10) AND (doc.t1.x > 10))"));
}
Also used : Collect(io.crate.planner.operators.Collect) Filter(io.crate.planner.operators.Filter) TableStats(io.crate.statistics.TableStats) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

Aggregations

Collect (io.crate.planner.operators.Collect)7 WhereClause (io.crate.analyze.WhereClause)3 Count (io.crate.planner.operators.Count)2 TableStats (io.crate.statistics.TableStats)2 DocTableRelation (io.crate.analyze.relations.DocTableRelation)1 DocKeys (io.crate.analyze.where.DocKeys)1 RoutedCollectPhase (io.crate.execution.dsl.phases.RoutedCollectPhase)1 ProjectionBuilder (io.crate.execution.dsl.projection.builder.ProjectionBuilder)1 EvaluatingNormalizer (io.crate.expression.eval.EvaluatingNormalizer)1 SelectSymbol (io.crate.expression.symbol.SelectSymbol)1 Filter (io.crate.planner.operators.Filter)1 Get (io.crate.planner.operators.Get)1 LogicalPlan (io.crate.planner.operators.LogicalPlan)1 Rename (io.crate.planner.operators.Rename)1 SubQueryResults (io.crate.planner.operators.SubQueryResults)1 OptimizeCollectWhereClauseAccess (io.crate.planner.optimizer.rule.OptimizeCollectWhereClauseAccess)1 Stats (io.crate.statistics.Stats)1 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)1 Test (org.junit.Test)1