Search in sources :

Example 6 with WindowAgg

use of io.crate.planner.operators.WindowAgg 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());
}
Also used : WindowFunction(io.crate.expression.symbol.WindowFunction) WindowAgg(io.crate.planner.operators.WindowAgg) Filter(io.crate.planner.operators.Filter) Symbol(io.crate.expression.symbol.Symbol) LogicalPlan(io.crate.planner.operators.LogicalPlan) TableStats(io.crate.statistics.TableStats) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

Aggregations

Symbol (io.crate.expression.symbol.Symbol)6 WindowFunction (io.crate.expression.symbol.WindowFunction)6 Filter (io.crate.planner.operators.Filter)6 LogicalPlan (io.crate.planner.operators.LogicalPlan)6 WindowAgg (io.crate.planner.operators.WindowAgg)6 TableStats (io.crate.statistics.TableStats)6 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)5 Test (org.junit.Test)5 WindowDefinition (io.crate.analyze.WindowDefinition)1 AndOperator (io.crate.expression.operator.AndOperator)1 SymbolVisitors (io.crate.expression.symbol.SymbolVisitors)1 NodeContext (io.crate.metadata.NodeContext)1 TransactionContext (io.crate.metadata.TransactionContext)1 LogicalPlanner.extractColumns (io.crate.planner.operators.LogicalPlanner.extractColumns)1 Rule (io.crate.planner.optimizer.Rule)1 Capture (io.crate.planner.optimizer.matcher.Capture)1 Captures (io.crate.planner.optimizer.matcher.Captures)1 Pattern (io.crate.planner.optimizer.matcher.Pattern)1 Pattern.typeOf (io.crate.planner.optimizer.matcher.Pattern.typeOf)1 Patterns.source (io.crate.planner.optimizer.matcher.Patterns.source)1