Search in sources :

Example 6 with Window

use of com.facebook.presto.sql.tree.Window in project presto by prestodb.

the class TestSwapAdjacentWindowsBySpecifications method dependentWindowsAreNotReordered.

@Test
public void dependentWindowsAreNotReordered() {
    Optional<Window> windowA = Optional.of(new Window(ImmutableList.of(new SymbolReference("a")), Optional.empty(), Optional.empty()));
    tester().assertThat(new GatherAndMergeWindows.SwapAdjacentWindowsBySpecifications(0)).on(p -> p.window(new WindowNode.Specification(ImmutableList.of(p.variable("a")), Optional.empty()), ImmutableMap.of(p.variable("avg_1"), newWindowNodeFunction(ImmutableList.of(new Symbol("avg_2")))), p.window(new WindowNode.Specification(ImmutableList.of(p.variable("a"), p.variable("b")), Optional.empty()), ImmutableMap.of(p.variable("avg_2"), newWindowNodeFunction(ImmutableList.of(new Symbol("a")))), p.values(p.variable("a"), p.variable("b"))))).doesNotFire();
}
Also used : Window(com.facebook.presto.sql.tree.Window) PlanMatchPattern.specification(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.specification) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) Test(org.testng.annotations.Test) TypeSignatureProvider.fromTypes(com.facebook.presto.sql.analyzer.TypeSignatureProvider.fromTypes) Expressions.call(com.facebook.presto.sql.relational.Expressions.call) PlanMatchPattern.window(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.window) RANGE(com.facebook.presto.sql.planner.plan.WindowNode.Frame.WindowType.RANGE) ImmutableList(com.google.common.collect.ImmutableList) Symbol(com.facebook.presto.sql.planner.Symbol) UNBOUNDED_PRECEDING(com.facebook.presto.sql.planner.plan.WindowNode.Frame.BoundType.UNBOUNDED_PRECEDING) PlanMatchPattern.functionCall(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.functionCall) BIGINT(com.facebook.presto.common.type.BigintType.BIGINT) SymbolReference(com.facebook.presto.sql.tree.SymbolReference) CURRENT_ROW(com.facebook.presto.sql.planner.plan.WindowNode.Frame.BoundType.CURRENT_ROW) WindowNode(com.facebook.presto.sql.planner.plan.WindowNode) ImmutableMap(com.google.common.collect.ImmutableMap) DOUBLE(com.facebook.presto.common.type.DoubleType.DOUBLE) Collectors(java.util.stream.Collectors) List(java.util.List) BaseRuleTest(com.facebook.presto.sql.planner.iterative.rule.test.BaseRuleTest) Window(com.facebook.presto.sql.tree.Window) MetadataManager.createTestMetadataManager(com.facebook.presto.metadata.MetadataManager.createTestMetadataManager) FunctionHandle(com.facebook.presto.spi.function.FunctionHandle) Optional(java.util.Optional) PlanMatchPattern.values(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values) ExpectedValueProvider(com.facebook.presto.sql.planner.assertions.ExpectedValueProvider) WindowNode(com.facebook.presto.sql.planner.plan.WindowNode) SymbolReference(com.facebook.presto.sql.tree.SymbolReference) Symbol(com.facebook.presto.sql.planner.Symbol) Test(org.testng.annotations.Test) BaseRuleTest(com.facebook.presto.sql.planner.iterative.rule.test.BaseRuleTest)

Aggregations

Window (com.facebook.presto.sql.tree.Window)6 WindowNode (com.facebook.presto.sql.planner.plan.WindowNode)4 FunctionCall (com.facebook.presto.sql.tree.FunctionCall)4 SymbolReference (com.facebook.presto.sql.tree.SymbolReference)4 ImmutableList (com.google.common.collect.ImmutableList)4 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)3 Expression (com.facebook.presto.sql.tree.Expression)3 SortItem (com.facebook.presto.sql.tree.SortItem)3 Test (org.testng.annotations.Test)3 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)2 DOUBLE (com.facebook.presto.common.type.DoubleType.DOUBLE)2 MetadataManager.createTestMetadataManager (com.facebook.presto.metadata.MetadataManager.createTestMetadataManager)2 FunctionHandle (com.facebook.presto.spi.function.FunctionHandle)2 TypeSignatureProvider.fromTypes (com.facebook.presto.sql.analyzer.TypeSignatureProvider.fromTypes)2 Symbol (com.facebook.presto.sql.planner.Symbol)2 ExpectedValueProvider (com.facebook.presto.sql.planner.assertions.ExpectedValueProvider)2 PlanMatchPattern.functionCall (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.functionCall)2 PlanMatchPattern.specification (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.specification)2 PlanMatchPattern.values (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values)2 PlanMatchPattern.window (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.window)2