Search in sources :

Example 11 with SymbolReference

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

the class FunctionAssertions method needsBoundValue.

private static boolean needsBoundValue(Expression projectionExpression) {
    final AtomicBoolean hasSymbolReferences = new AtomicBoolean();
    new DefaultTraversalVisitor<Void, Void>() {

        @Override
        protected Void visitSymbolReference(SymbolReference node, Void context) {
            hasSymbolReferences.set(true);
            return null;
        }
    }.process(projectionExpression, null);
    return hasSymbolReferences.get();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SymbolReference(com.facebook.presto.sql.tree.SymbolReference)

Example 12 with SymbolReference

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

the class ProjectNode method isIdentity.

public boolean isIdentity() {
    for (Map.Entry<Symbol, Expression> entry : assignments.entrySet()) {
        Expression expression = entry.getValue();
        Symbol symbol = entry.getKey();
        if (!(expression instanceof SymbolReference && ((SymbolReference) expression).getName().equals(symbol.getName()))) {
            return false;
        }
    }
    return true;
}
Also used : Expression(com.facebook.presto.sql.tree.Expression) Symbol(com.facebook.presto.sql.planner.Symbol) SymbolReference(com.facebook.presto.sql.tree.SymbolReference) Map(java.util.Map)

Example 13 with SymbolReference

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

the class SimplifyCountOverConstant method isCountOverConstant.

private static boolean isCountOverConstant(AggregationNode.Aggregation aggregation, Assignments inputs) {
    Signature signature = aggregation.getSignature();
    if (!signature.getName().equals("count") || signature.getArgumentTypes().size() != 1) {
        return false;
    }
    Expression argument = aggregation.getCall().getArguments().get(0);
    if (argument instanceof SymbolReference) {
        argument = inputs.get(Symbol.from(argument));
    }
    return argument instanceof Literal && !(argument instanceof NullLiteral);
}
Also used : Expression(com.facebook.presto.sql.tree.Expression) SymbolReference(com.facebook.presto.sql.tree.SymbolReference) Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) NullLiteral(com.facebook.presto.sql.tree.NullLiteral) Literal(com.facebook.presto.sql.tree.Literal) NullLiteral(com.facebook.presto.sql.tree.NullLiteral)

Aggregations

SymbolReference (com.facebook.presto.sql.tree.SymbolReference)13 Expression (com.facebook.presto.sql.tree.Expression)8 ImmutableList (com.google.common.collect.ImmutableList)5 Signature (com.facebook.presto.metadata.Signature)4 Cast (com.facebook.presto.sql.tree.Cast)4 IdentityLinkedHashMap (com.facebook.presto.util.maps.IdentityLinkedHashMap)4 Map (java.util.Map)4 Domain (com.facebook.presto.spi.predicate.Domain)3 TupleDomain (com.facebook.presto.spi.predicate.TupleDomain)3 Type (com.facebook.presto.spi.type.Type)3 LiteralInterpreter.toExpression (com.facebook.presto.sql.planner.LiteralInterpreter.toExpression)3 ComparisonExpression (com.facebook.presto.sql.tree.ComparisonExpression)3 Session (com.facebook.presto.Session)2 Metadata (com.facebook.presto.metadata.Metadata)2 Signature.internalOperator (com.facebook.presto.metadata.Signature.internalOperator)2 Block (com.facebook.presto.spi.block.Block)2 SATURATED_FLOOR_CAST (com.facebook.presto.spi.function.OperatorType.SATURATED_FLOOR_CAST)2 DiscreteValues (com.facebook.presto.spi.predicate.DiscreteValues)2 Marker (com.facebook.presto.spi.predicate.Marker)2 NullableValue (com.facebook.presto.spi.predicate.NullableValue)2