Search in sources :

Example 1 with Window

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

the class AstBuilder method visitFunctionCall.

@Override
public Node visitFunctionCall(SqlBaseParser.FunctionCallContext context) {
    Optional<Expression> filter = visitIfPresent(context.filter(), Expression.class);
    Optional<Window> window = visitIfPresent(context.over(), Window.class);
    Optional<OrderBy> orderBy = Optional.empty();
    if (context.ORDER() != null) {
        orderBy = Optional.of(new OrderBy(visit(context.sortItem(), SortItem.class)));
    }
    QualifiedName name = getQualifiedName(context.qualifiedName());
    boolean distinct = isDistinct(context.setQuantifier());
    boolean ignoreNulls = context.nullTreatment() != null && context.nullTreatment().IGNORE() != null;
    if (name.toString().equalsIgnoreCase("if")) {
        check(context.expression().size() == 2 || context.expression().size() == 3, "Invalid number of arguments for 'if' function", context);
        check(!window.isPresent(), "OVER clause not valid for 'if' function", context);
        check(!distinct, "DISTINCT not valid for 'if' function", context);
        check(!filter.isPresent(), "FILTER not valid for 'if' function", context);
        Expression elseExpression = null;
        if (context.expression().size() == 3) {
            elseExpression = (Expression) visit(context.expression(2));
        }
        return new IfExpression(getLocation(context), (Expression) visit(context.expression(0)), (Expression) visit(context.expression(1)), elseExpression);
    }
    if (name.toString().equalsIgnoreCase("nullif")) {
        check(context.expression().size() == 2, "Invalid number of arguments for 'nullif' function", context);
        check(!window.isPresent(), "OVER clause not valid for 'nullif' function", context);
        check(!distinct, "DISTINCT not valid for 'nullif' function", context);
        check(!filter.isPresent(), "FILTER not valid for 'nullif' function", context);
        return new NullIfExpression(getLocation(context), (Expression) visit(context.expression(0)), (Expression) visit(context.expression(1)));
    }
    if (name.toString().equalsIgnoreCase("coalesce")) {
        check(context.expression().size() >= 2, "The 'coalesce' function must have at least two arguments", context);
        check(!window.isPresent(), "OVER clause not valid for 'coalesce' function", context);
        check(!distinct, "DISTINCT not valid for 'coalesce' function", context);
        check(!filter.isPresent(), "FILTER not valid for 'coalesce' function", context);
        return new CoalesceExpression(getLocation(context), visit(context.expression(), Expression.class));
    }
    if (name.toString().equalsIgnoreCase("try")) {
        check(context.expression().size() == 1, "The 'try' function must have exactly one argument", context);
        check(!window.isPresent(), "OVER clause not valid for 'try' function", context);
        check(!distinct, "DISTINCT not valid for 'try' function", context);
        check(!filter.isPresent(), "FILTER not valid for 'try' function", context);
        return new TryExpression(getLocation(context), (Expression) visit(getOnlyElement(context.expression())));
    }
    if (name.toString().equalsIgnoreCase("$internal$bind")) {
        check(context.expression().size() >= 1, "The '$internal$bind' function must have at least one arguments", context);
        check(!window.isPresent(), "OVER clause not valid for '$internal$bind' function", context);
        check(!distinct, "DISTINCT not valid for '$internal$bind' function", context);
        check(!filter.isPresent(), "FILTER not valid for '$internal$bind' function", context);
        int numValues = context.expression().size() - 1;
        List<Expression> arguments = context.expression().stream().map(this::visit).map(Expression.class::cast).collect(toImmutableList());
        return new BindExpression(getLocation(context), arguments.subList(0, numValues), arguments.get(numValues));
    }
    return new FunctionCall(getLocation(context), getQualifiedName(context.qualifiedName()), window, filter, orderBy, distinct, ignoreNulls, visit(context.expression(), Expression.class));
}
Also used : Window(com.facebook.presto.sql.tree.Window) OrderBy(com.facebook.presto.sql.tree.OrderBy) IfExpression(com.facebook.presto.sql.tree.IfExpression) NullIfExpression(com.facebook.presto.sql.tree.NullIfExpression) QualifiedName(com.facebook.presto.sql.tree.QualifiedName) TryExpression(com.facebook.presto.sql.tree.TryExpression) SortItem(com.facebook.presto.sql.tree.SortItem) SubqueryExpression(com.facebook.presto.sql.tree.SubqueryExpression) SubscriptExpression(com.facebook.presto.sql.tree.SubscriptExpression) LogicalBinaryExpression(com.facebook.presto.sql.tree.LogicalBinaryExpression) SearchedCaseExpression(com.facebook.presto.sql.tree.SearchedCaseExpression) CoalesceExpression(com.facebook.presto.sql.tree.CoalesceExpression) SimpleCaseExpression(com.facebook.presto.sql.tree.SimpleCaseExpression) NotExpression(com.facebook.presto.sql.tree.NotExpression) LambdaExpression(com.facebook.presto.sql.tree.LambdaExpression) IfExpression(com.facebook.presto.sql.tree.IfExpression) BindExpression(com.facebook.presto.sql.tree.BindExpression) QuantifiedComparisonExpression(com.facebook.presto.sql.tree.QuantifiedComparisonExpression) InListExpression(com.facebook.presto.sql.tree.InListExpression) TryExpression(com.facebook.presto.sql.tree.TryExpression) ArithmeticUnaryExpression(com.facebook.presto.sql.tree.ArithmeticUnaryExpression) DereferenceExpression(com.facebook.presto.sql.tree.DereferenceExpression) NullIfExpression(com.facebook.presto.sql.tree.NullIfExpression) ComparisonExpression(com.facebook.presto.sql.tree.ComparisonExpression) Expression(com.facebook.presto.sql.tree.Expression) ArithmeticBinaryExpression(com.facebook.presto.sql.tree.ArithmeticBinaryExpression) BindExpression(com.facebook.presto.sql.tree.BindExpression) NullIfExpression(com.facebook.presto.sql.tree.NullIfExpression) FunctionCall(com.facebook.presto.sql.tree.FunctionCall) CoalesceExpression(com.facebook.presto.sql.tree.CoalesceExpression)

Example 2 with Window

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

the class TestSqlParser method testNullTreatment.

@Test
public void testNullTreatment() {
    assertExpression("lead(x, 1) ignore nulls over()", new FunctionCall(QualifiedName.of("lead"), Optional.of(new Window(ImmutableList.of(), Optional.empty(), Optional.empty())), Optional.empty(), Optional.empty(), false, true, ImmutableList.of(new Identifier("x"), new LongLiteral("1"))));
    assertExpression("lead(x, 1) respect nulls over()", new FunctionCall(QualifiedName.of("lead"), Optional.of(new Window(ImmutableList.of(), Optional.empty(), Optional.empty())), Optional.empty(), Optional.empty(), false, false, ImmutableList.of(new Identifier("x"), new LongLiteral("1"))));
}
Also used : Window(com.facebook.presto.sql.tree.Window) Identifier(com.facebook.presto.sql.tree.Identifier) QueryUtil.quotedIdentifier(com.facebook.presto.sql.QueryUtil.quotedIdentifier) LongLiteral(com.facebook.presto.sql.tree.LongLiteral) FunctionCall(com.facebook.presto.sql.tree.FunctionCall) Test(org.testng.annotations.Test)

Example 3 with Window

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

the class QueryPlanner method window.

private PlanBuilder window(PlanBuilder subPlan, QuerySpecification node) {
    List<FunctionCall> windowFunctions = ImmutableList.copyOf(analysis.getWindowFunctions(node));
    if (windowFunctions.isEmpty()) {
        return subPlan;
    }
    for (FunctionCall windowFunction : windowFunctions) {
        Window window = windowFunction.getWindow().get();
        // Extract frame
        WindowFrame.Type frameType = WindowFrame.Type.RANGE;
        FrameBound.Type frameStartType = FrameBound.Type.UNBOUNDED_PRECEDING;
        FrameBound.Type frameEndType = FrameBound.Type.CURRENT_ROW;
        Expression frameStart = null;
        Expression frameEnd = null;
        if (window.getFrame().isPresent()) {
            WindowFrame frame = window.getFrame().get();
            frameType = frame.getType();
            frameStartType = frame.getStart().getType();
            frameStart = frame.getStart().getValue().orElse(null);
            if (frame.getEnd().isPresent()) {
                frameEndType = frame.getEnd().get().getType();
                frameEnd = frame.getEnd().get().getValue().orElse(null);
            }
        }
        // Pre-project inputs
        ImmutableList.Builder<Expression> inputs = ImmutableList.<Expression>builder().addAll(windowFunction.getArguments()).addAll(window.getPartitionBy()).addAll(Iterables.transform(window.getOrderBy(), SortItem::getSortKey));
        if (frameStart != null) {
            inputs.add(frameStart);
        }
        if (frameEnd != null) {
            inputs.add(frameEnd);
        }
        subPlan = subPlan.appendProjections(inputs.build(), symbolAllocator, idAllocator);
        // Rewrite PARTITION BY in terms of pre-projected inputs
        ImmutableList.Builder<Symbol> partitionBySymbols = ImmutableList.builder();
        for (Expression expression : window.getPartitionBy()) {
            partitionBySymbols.add(subPlan.translate(expression));
        }
        // Rewrite ORDER BY in terms of pre-projected inputs
        Map<Symbol, SortOrder> orderings = new LinkedHashMap<>();
        for (SortItem item : window.getOrderBy()) {
            Symbol symbol = subPlan.translate(item.getSortKey());
            orderings.put(symbol, toSortOrder(item));
        }
        // Rewrite frame bounds in terms of pre-projected inputs
        Optional<Symbol> frameStartSymbol = Optional.empty();
        Optional<Symbol> frameEndSymbol = Optional.empty();
        if (frameStart != null) {
            frameStartSymbol = Optional.of(subPlan.translate(frameStart));
        }
        if (frameEnd != null) {
            frameEndSymbol = Optional.of(subPlan.translate(frameEnd));
        }
        WindowNode.Frame frame = new WindowNode.Frame(frameType, frameStartType, frameStartSymbol, frameEndType, frameEndSymbol);
        TranslationMap outputTranslations = subPlan.copyTranslations();
        // Rewrite function call in terms of pre-projected inputs
        Expression parametersReplaced = ExpressionTreeRewriter.rewriteWith(new ParameterRewriter(analysis.getParameters(), analysis), windowFunction);
        outputTranslations.addIntermediateMapping(windowFunction, parametersReplaced);
        Expression rewritten = subPlan.rewrite(parametersReplaced);
        boolean needCoercion = rewritten instanceof Cast;
        // Strip out the cast and add it back as a post-projection
        if (rewritten instanceof Cast) {
            rewritten = ((Cast) rewritten).getExpression();
        }
        // If refers to existing symbol, don't create another PlanNode
        if (rewritten instanceof SymbolReference) {
            if (needCoercion) {
                subPlan = explicitCoercionSymbols(subPlan, subPlan.getRoot().getOutputSymbols(), ImmutableList.of(windowFunction));
            }
            continue;
        }
        Symbol newSymbol = symbolAllocator.newSymbol(rewritten, analysis.getType(windowFunction));
        outputTranslations.put(parametersReplaced, newSymbol);
        WindowNode.Function function = new WindowNode.Function((FunctionCall) rewritten, analysis.getFunctionSignature(windowFunction), frame);
        List<Symbol> sourceSymbols = subPlan.getRoot().getOutputSymbols();
        ImmutableList.Builder<Symbol> orderBySymbols = ImmutableList.builder();
        orderBySymbols.addAll(orderings.keySet());
        // create window node
        subPlan = new PlanBuilder(outputTranslations, new WindowNode(idAllocator.getNextId(), subPlan.getRoot(), new WindowNode.Specification(partitionBySymbols.build(), orderBySymbols.build(), orderings), ImmutableMap.of(newSymbol, function), Optional.empty(), ImmutableSet.of(), 0), analysis.getParameters());
        if (needCoercion) {
            subPlan = explicitCoercionSymbols(subPlan, sourceSymbols, ImmutableList.of(windowFunction));
        }
    }
    return subPlan;
}
Also used : Cast(com.facebook.presto.sql.tree.Cast) WindowFrame(com.facebook.presto.sql.tree.WindowFrame) ImmutableList(com.google.common.collect.ImmutableList) SymbolReference(com.facebook.presto.sql.tree.SymbolReference) LinkedHashMap(java.util.LinkedHashMap) IdentityLinkedHashMap(com.facebook.presto.util.maps.IdentityLinkedHashMap) SortItem(com.facebook.presto.sql.tree.SortItem) WindowFrame(com.facebook.presto.sql.tree.WindowFrame) FunctionCall(com.facebook.presto.sql.tree.FunctionCall) Window(com.facebook.presto.sql.tree.Window) WindowNode(com.facebook.presto.sql.planner.plan.WindowNode) FrameBound(com.facebook.presto.sql.tree.FrameBound) SortOrder(com.facebook.presto.spi.block.SortOrder) Expression(com.facebook.presto.sql.tree.Expression)

Example 4 with Window

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

the class QueryPlanner method window.

private PlanBuilder window(PlanBuilder subPlan, List<FunctionCall> windowFunctions) {
    if (windowFunctions.isEmpty()) {
        return subPlan;
    }
    for (FunctionCall windowFunction : windowFunctions) {
        Window window = windowFunction.getWindow().get();
        // Extract frame
        WindowFrame.Type frameType = WindowFrame.Type.RANGE;
        FrameBound.Type frameStartType = FrameBound.Type.UNBOUNDED_PRECEDING;
        FrameBound.Type frameEndType = FrameBound.Type.CURRENT_ROW;
        Expression frameStart = null;
        Expression frameEnd = null;
        if (window.getFrame().isPresent()) {
            WindowFrame frame = window.getFrame().get();
            frameType = frame.getType();
            frameStartType = frame.getStart().getType();
            frameStart = frame.getStart().getValue().orElse(null);
            if (frame.getEnd().isPresent()) {
                frameEndType = frame.getEnd().get().getType();
                frameEnd = frame.getEnd().get().getValue().orElse(null);
            }
        }
        // Pre-project inputs
        ImmutableList.Builder<Expression> inputs = ImmutableList.<Expression>builder().addAll(windowFunction.getArguments()).addAll(window.getPartitionBy()).addAll(Iterables.transform(getSortItemsFromOrderBy(window.getOrderBy()), SortItem::getSortKey));
        if (frameStart != null) {
            inputs.add(frameStart);
        }
        if (frameEnd != null) {
            inputs.add(frameEnd);
        }
        subPlan = subPlan.appendProjections(inputs.build(), variableAllocator, idAllocator);
        // Rewrite PARTITION BY in terms of pre-projected inputs
        ImmutableList.Builder<VariableReferenceExpression> partitionByVariables = ImmutableList.builder();
        for (Expression expression : window.getPartitionBy()) {
            partitionByVariables.add(subPlan.translateToVariable(expression));
        }
        // Rewrite ORDER BY in terms of pre-projected inputs
        LinkedHashMap<VariableReferenceExpression, SortOrder> orderings = new LinkedHashMap<>();
        for (SortItem item : getSortItemsFromOrderBy(window.getOrderBy())) {
            VariableReferenceExpression variable = subPlan.translateToVariable(item.getSortKey());
            // don't override existing keys, i.e. when "ORDER BY a ASC, a DESC" is specified
            orderings.putIfAbsent(variable, toSortOrder(item));
        }
        // Rewrite frame bounds in terms of pre-projected inputs
        Optional<VariableReferenceExpression> frameStartVariable = Optional.empty();
        Optional<VariableReferenceExpression> frameEndVariable = Optional.empty();
        if (frameStart != null) {
            frameStartVariable = Optional.of(subPlan.translate(frameStart));
        }
        if (frameEnd != null) {
            frameEndVariable = Optional.of(subPlan.translate(frameEnd));
        }
        WindowNode.Frame frame = new WindowNode.Frame(toWindowType(frameType), toBoundType(frameStartType), frameStartVariable, toBoundType(frameEndType), frameEndVariable, Optional.ofNullable(frameStart).map(Expression::toString), Optional.ofNullable(frameEnd).map(Expression::toString));
        TranslationMap outputTranslations = subPlan.copyTranslations();
        // Rewrite function call in terms of pre-projected inputs
        Expression rewritten = subPlan.rewrite(windowFunction);
        boolean needCoercion = rewritten instanceof Cast;
        // Strip out the cast and add it back as a post-projection
        if (rewritten instanceof Cast) {
            rewritten = ((Cast) rewritten).getExpression();
        }
        // If refers to existing variable, don't create another PlanNode
        if (rewritten instanceof SymbolReference) {
            if (needCoercion) {
                subPlan = explicitCoercionVariables(subPlan, subPlan.getRoot().getOutputVariables(), ImmutableList.of(windowFunction));
            }
            continue;
        }
        Type returnType = analysis.getType(windowFunction);
        VariableReferenceExpression newVariable = variableAllocator.newVariable(rewritten, returnType);
        outputTranslations.put(windowFunction, newVariable);
        // TODO: replace arguments with RowExpression once we introduce subquery expression for RowExpression (#12745).
        // Wrap all arguments in CallExpression to be RawExpression.
        // The utility that work on the CallExpression should be aware of the RawExpression handling.
        // The interface will be dirty until we introduce subquery expression for RowExpression.
        // With subqueries, the translation from Expression to RowExpression can happen here.
        WindowNode.Function function = new WindowNode.Function(call(windowFunction.getName().toString(), analysis.getFunctionHandle(windowFunction), returnType, ((FunctionCall) rewritten).getArguments().stream().map(OriginalExpressionUtils::castToRowExpression).collect(toImmutableList())), frame, windowFunction.isIgnoreNulls());
        ImmutableList.Builder<VariableReferenceExpression> orderByVariables = ImmutableList.builder();
        orderByVariables.addAll(orderings.keySet());
        Optional<OrderingScheme> orderingScheme = Optional.empty();
        if (!orderings.isEmpty()) {
            orderingScheme = Optional.of(new OrderingScheme(orderByVariables.build().stream().map(variable -> new Ordering(variable, orderings.get(variable))).collect(toImmutableList())));
        }
        // create window node
        subPlan = new PlanBuilder(outputTranslations, new WindowNode(subPlan.getRoot().getSourceLocation(), idAllocator.getNextId(), subPlan.getRoot(), new WindowNode.Specification(partitionByVariables.build(), orderingScheme), ImmutableMap.of(newVariable, function), Optional.empty(), ImmutableSet.of(), 0));
        if (needCoercion) {
            subPlan = explicitCoercionVariables(subPlan, subPlan.getRoot().getOutputVariables(), ImmutableList.of(windowFunction));
        }
    }
    return subPlan;
}
Also used : Cast(com.facebook.presto.sql.tree.Cast) WindowFrame(com.facebook.presto.sql.tree.WindowFrame) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) SymbolReference(com.facebook.presto.sql.tree.SymbolReference) OriginalExpressionUtils.asSymbolReference(com.facebook.presto.sql.relational.OriginalExpressionUtils.asSymbolReference) LinkedHashMap(java.util.LinkedHashMap) SortItem(com.facebook.presto.sql.tree.SortItem) WindowFrame(com.facebook.presto.sql.tree.WindowFrame) Ordering(com.facebook.presto.spi.plan.Ordering) FunctionCall(com.facebook.presto.sql.tree.FunctionCall) Window(com.facebook.presto.sql.tree.Window) WindowNode(com.facebook.presto.sql.planner.plan.WindowNode) OrderingScheme(com.facebook.presto.spi.plan.OrderingScheme) PlannerUtils.toOrderingScheme(com.facebook.presto.sql.planner.PlannerUtils.toOrderingScheme) FrameBound(com.facebook.presto.sql.tree.FrameBound) SortOrder(com.facebook.presto.common.block.SortOrder) PlannerUtils.toSortOrder(com.facebook.presto.sql.planner.PlannerUtils.toSortOrder) WindowNodeUtil.toBoundType(com.facebook.presto.sql.planner.optimizations.WindowNodeUtil.toBoundType) WindowNodeUtil.toWindowType(com.facebook.presto.sql.planner.optimizations.WindowNodeUtil.toWindowType) Type(com.facebook.presto.common.type.Type) RelationType(com.facebook.presto.sql.analyzer.RelationType) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) CallExpression(com.facebook.presto.spi.relation.CallExpression) LambdaExpression(com.facebook.presto.sql.tree.LambdaExpression) RowExpression(com.facebook.presto.spi.relation.RowExpression) Expression(com.facebook.presto.sql.tree.Expression) OriginalExpressionUtils.castToRowExpression(com.facebook.presto.sql.relational.OriginalExpressionUtils.castToRowExpression) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression)

Example 5 with Window

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

the class TestSwapAdjacentWindowsBySpecifications method subsetComesFirst.

@Test
public void subsetComesFirst() {
    String columnAAlias = "ALIAS_A";
    String columnBAlias = "ALIAS_B";
    ExpectedValueProvider<WindowNode.Specification> specificationA = specification(ImmutableList.of(columnAAlias), ImmutableList.of(), ImmutableMap.of());
    ExpectedValueProvider<WindowNode.Specification> specificationAB = specification(ImmutableList.of(columnAAlias, columnBAlias), ImmutableList.of(), ImmutableMap.of());
    Optional<Window> windowAB = Optional.of(new Window(ImmutableList.of(new SymbolReference("a"), new SymbolReference("b")), Optional.empty(), Optional.empty()));
    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", DOUBLE), newWindowNodeFunction(ImmutableList.of(new Symbol("a")))), p.window(new WindowNode.Specification(ImmutableList.of(p.variable("a"), p.variable("b")), Optional.empty()), ImmutableMap.of(p.variable("avg_2", DOUBLE), newWindowNodeFunction(ImmutableList.of(new Symbol("b")))), p.values(p.variable("a"), p.variable("b"))))).matches(window(windowMatcherBuilder -> windowMatcherBuilder.specification(specificationAB).addFunction(functionCall("avg", Optional.empty(), ImmutableList.of(columnBAlias))), window(windowMatcherBuilder -> windowMatcherBuilder.specification(specificationA).addFunction(functionCall("avg", Optional.empty(), ImmutableList.of(columnAAlias))), values(ImmutableMap.of(columnAAlias, 0, columnBAlias, 1)))));
}
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