use of io.crate.planner.operators.LogicalPlan in project crate by crate.
the class SingleRowSubselectPlannerTest method testSingleRowSubSelectOfWhereInJoin.
@Test
public void testSingleRowSubSelectOfWhereInJoin() throws Exception {
LogicalPlan plan = e.logicalPlan("select * from users u1, users u2 where u1.name = (select 'Arthur')");
assertThat(plan.dependencies().keySet(), contains(instanceOf(RootRelationBoundary.class)));
}
use of io.crate.planner.operators.LogicalPlan in project crate by crate.
the class MoveFilterBeneathWindowAggTest method test_filter_part_on_windows_function_partition_columns_is_moved.
@Test
public void test_filter_part_on_windows_function_partition_columns_is_moved() {
var collect = e.logicalPlan("SELECT id FROM t1");
WindowFunction windowFunction = (WindowFunction) e.asSymbol("ROW_NUMBER() OVER(PARTITION BY id)");
WindowAgg windowAgg = (WindowAgg) WindowAgg.create(collect, List.of(windowFunction));
Symbol query = e.asSymbol("ROW_NUMBER() OVER(PARTITION BY id) = 2 AND id = 10 AND x = 1");
Filter filter = new Filter(windowAgg, query);
var rule = new MoveFilterBeneathWindowAgg();
Match<Filter> match = rule.pattern().accept(filter, Captures.empty());
assertThat(match.isPresent(), is(true));
assertThat(match.value(), Matchers.sameInstance(filter));
LogicalPlan newPlan = rule.apply(match.value(), match.captures(), new TableStats(), CoordinatorTxnCtx.systemTransactionContext(), e.nodeCtx);
var expectedPlan = "Filter[((row_number() OVER (PARTITION BY id) = 2) AND (x = 1))]\n" + " └ WindowAgg[id, row_number() OVER (PARTITION BY id)]\n" + " └ Filter[(id = 10)]\n" + " └ Collect[doc.t1 | [id] | true]";
assertThat(newPlan, isPlan(expectedPlan));
}
use of io.crate.planner.operators.LogicalPlan in project crate by crate.
the class MoveFilterBeneathWindowAggTest method test_filter_on_containing_windows_function_is_not_moved.
@Test
public void test_filter_on_containing_windows_function_is_not_moved() {
var collect = e.logicalPlan("SELECT id FROM t1");
WindowFunction windowFunction = (WindowFunction) e.asSymbol("ROW_NUMBER() OVER(PARTITION by id)");
WindowAgg windowAgg = (WindowAgg) WindowAgg.create(collect, List.of(windowFunction));
Symbol query = e.asSymbol("ROW_NUMBER() OVER(PARTITION by id) = 2");
Filter filter = new Filter(windowAgg, query);
var rule = new MoveFilterBeneathWindowAgg();
Match<Filter> match = rule.pattern().accept(filter, Captures.empty());
assertThat(match.isPresent(), is(true));
assertThat(match.value(), Matchers.sameInstance(filter));
LogicalPlan newPlan = rule.apply(match.value(), match.captures(), new TableStats(), CoordinatorTxnCtx.systemTransactionContext(), e.nodeCtx);
assertThat(newPlan, nullValue());
}
Aggregations