public static Expression logicalAnd(Expression left, Expression right) { return new LogicalBinaryExpression(LogicalBinaryExpression.Operator.AND, left, right); }
@Override protected PlanNodeStatsEstimate visitLogicalBinaryExpression(LogicalBinaryExpression node, Void context) { switch (node.getOperator()) { case AND: return estimateLogicalAnd(node.getLeft(), node.getRight()); case OR: return estimateLogicalOr(node.getLeft(), node.getRight()); default: throw new IllegalArgumentException("Unexpected binary operator: " + node.getOperator()); } }
@Override protected Object visitLogicalBinaryExpression(LogicalBinaryExpression node, Object context) Object left = process(node.getLeft(), context); Object right; switch (node.getOperator()) { case AND: { if (Boolean.FALSE.equals(left)) { right = process(node.getRight(), context); right = process(node.getRight(), context); return new LogicalBinaryExpression(node.getOperator(), toExpression(left, type(node.getLeft())), toExpression(right, type(node.getRight())));
public static List<Expression> extractPredicates(LogicalBinaryExpression expression) { return extractPredicates(expression.getOperator(), expression); }
@Override protected Object visitLogicalBinaryExpression(LogicalBinaryExpression node, Object context) Object left = process(node.getLeft(), context); Object right; switch (node.getOperator()) { case AND: { if (Boolean.FALSE.equals(left)) { right = process(node.getRight(), context); right = process(node.getRight(), context); return new LogicalBinaryExpression(node.getOperator(), toExpression(left, type(node.getLeft())), toExpression(right, type(node.getRight())));
public static List<Expression> extractPredicates(LogicalBinaryExpression expression) { return extractPredicates(expression.getOperator(), expression); }
@Override protected PlanNodeStatsEstimate visitLogicalBinaryExpression(LogicalBinaryExpression node, Void context) { switch (node.getOperator()) { case AND: return estimateLogicalAnd(node.getLeft(), node.getRight()); case OR: return estimateLogicalOr(node.getLeft(), node.getRight()); default: throw new IllegalArgumentException("Unexpected binary operator: " + node.getOperator()); } }
public static Expression logicalAnd(Expression left, Expression right) { return new LogicalBinaryExpression(LogicalBinaryExpression.Operator.AND, left, right); }
private static List<List<Expression>> getSubPredicates(LogicalBinaryExpression expression) { return extractPredicates(expression.getOperator(), expression).stream() .map(predicate -> predicate instanceof LogicalBinaryExpression ? extractPredicates((LogicalBinaryExpression) predicate) : ImmutableList.of(predicate)) .collect(toImmutableList()); }
@Override protected String visitLogicalBinaryExpression(LogicalBinaryExpression node, Void context) { return formatBinaryExpression(node.getOperator().toString(), node.getLeft(), node.getRight()); }
public static LogicalBinaryExpression and(Expression left, Expression right) { return new LogicalBinaryExpression(Optional.empty(), Operator.AND, left, right); }
private static List<List<Expression>> getSubPredicates(LogicalBinaryExpression expression) { return extractPredicates(expression.getOperator(), expression).stream() .map(predicate -> predicate instanceof LogicalBinaryExpression ? extractPredicates((LogicalBinaryExpression) predicate) : ImmutableList.of(predicate)) .collect(toImmutableList()); }
@Override protected String visitLogicalBinaryExpression(LogicalBinaryExpression node, Void context) { return formatBinaryExpression(node.getOperator().toString(), node.getLeft(), node.getRight()); }
public static LogicalBinaryExpression and(Expression left, Expression right) { return new LogicalBinaryExpression(Optional.empty(), Operator.AND, left, right); }
@Override protected Type visitLogicalBinaryExpression(LogicalBinaryExpression node, StackableAstVisitorContext<Context> context) { coerceType(context, node.getLeft(), BOOLEAN, "Left side of logical expression"); coerceType(context, node.getRight(), BOOLEAN, "Right side of logical expression"); return setExpressionType(node, BOOLEAN); }
@Override protected Void visitLogicalBinaryExpression(LogicalBinaryExpression node, Integer indentLevel) { print(indentLevel, node.getOperator().toString()); super.visitLogicalBinaryExpression(node, indentLevel + 1); return null; }