Search in sources :

Example 1 with Literal

use of com.facebook.presto.sql.tree.Literal 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

Signature (com.facebook.presto.metadata.Signature)1 TypeSignature.parseTypeSignature (com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)1 Expression (com.facebook.presto.sql.tree.Expression)1 Literal (com.facebook.presto.sql.tree.Literal)1 NullLiteral (com.facebook.presto.sql.tree.NullLiteral)1 SymbolReference (com.facebook.presto.sql.tree.SymbolReference)1