Java 类com.facebook.presto.sql.tree.CoalesceExpression 实例源码

项目:presto    文件:ExpressionInterpreter.java   
@Override
protected Object visitCoalesceExpression(CoalesceExpression node, Object context)
{
    Type type = type(node);
    List<Object> values = node.getOperands().stream()
            .map(value -> processWithExceptionHandling(value, context))
            .filter(value -> value != null)
            .collect(Collectors.toList());

    if ((!values.isEmpty() && !(values.get(0) instanceof Expression)) || values.size() == 1) {
        return values.get(0);
    }

    List<Expression> expressions = values.stream()
            .map(value -> toExpression(value, type))
            .collect(Collectors.toList());

    if (expressions.isEmpty()) {
        return null;
    }
    return new CoalesceExpression(expressions);
}
项目:presto    文件:SqlToRowExpressionTranslator.java   
@Override
protected RowExpression visitCoalesceExpression(CoalesceExpression node, Void context)
{
    List<RowExpression> arguments = node.getOperands().stream()
                    .map(value -> process(value, context))
                    .collect(toImmutableList());

    List<Type> argumentTypes = arguments.stream().map(RowExpression::getType).collect(toImmutableList());
    return call(coalesceSignature(types.get(node), argumentTypes), types.get(node), arguments);
}
项目:presto    文件:RelationPlanner.java   
private static Expression oneIfNull(Optional<Symbol> symbol)
{
    if (symbol.isPresent()) {
        return new CoalesceExpression(new QualifiedNameReference(symbol.get().toQualifiedName()), new LongLiteral("1"));
    }
    else {
        return new LongLiteral("1");
    }
}
项目:presto    文件:ExpressionAnalyzer.java   
@Override
protected Type visitCoalesceExpression(CoalesceExpression node, StackableAstVisitorContext<AnalysisContext> context)
{
    Type type = coerceToSingleType(context, "All COALESCE operands must be the same type: %s", node.getOperands());

    expressionTypes.put(node, type);
    return type;
}
项目:hue    文件:VeroGenExpFormatter.java   
@Override
protected String visitCoalesceExpression(CoalesceExpression node, Void context)
{
    return "COALESCE(" + joinExpressions(node.getOperands()) + ")";
}
项目:presto-query-formatter    文件:ExpressionFormatter.java   
@Override
protected String visitCoalesceExpression(CoalesceExpression node, StackableAstVisitorContext<Integer> indent)
{
    return "COALESCE(" + joinExpressions(node.getOperands(), indent) + ")";
}
项目:presto    文件:HashGenerationOptimizer.java   
private static Expression orNullHashCode(Expression expression)
{
    return new CoalesceExpression(expression, new LongLiteral(String.valueOf(TypeUtils.NULL_HASH_CODE)));
}
项目:presto    文件:AggregationAnalyzer.java   
@Override
protected Boolean visitCoalesceExpression(CoalesceExpression node, Void context)
{
    return node.getOperands().stream().allMatch(expression -> process(expression, context));
}
项目:presto    文件:ExpressionFormatter.java   
@Override
protected String visitCoalesceExpression(CoalesceExpression node, Boolean unmangleNames)
{
    return "COALESCE(" + joinExpressions(node.getOperands(), unmangleNames) + ")";
}
项目:presto    文件:QueryUtil.java   
public static SelectItem aliasedNullToEmpty(String column, String alias)
{
    return new SingleColumn(new CoalesceExpression(nameReference(column), new StringLiteral("")), alias);
}
项目:EchoQuery    文件:ExpressionFormatter.java   
@Override
protected String visitCoalesceExpression(CoalesceExpression node, Boolean unmangleNames)
{
    return "COALESCE(" + joinExpressions(node.getOperands(), unmangleNames) + ")";
}