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));
}
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))"));
}
Aggregations