@Override protected ExtractionResult visitNotExpression(NotExpression node, Boolean complement) { return process(node.getValue(), !complement); }
@Override protected String visitNotExpression(NotExpression node, Void context) { return "(NOT " + process(node.getValue(), context) + ")"; }
@Override protected R visitNotExpression(NotExpression node, C context) { return process(node.getValue(), context); }
@Override protected Boolean visitNotExpression(NotExpression node, Void context) { return process(node.getValue(), context); }
public static Expression normalize(Expression expression) { if (expression instanceof NotExpression) { NotExpression not = (NotExpression) expression; if (not.getValue() instanceof ComparisonExpression && ((ComparisonExpression) not.getValue()).getOperator() != IS_DISTINCT_FROM) { ComparisonExpression comparison = (ComparisonExpression) not.getValue(); return new ComparisonExpression(comparison.getOperator().negate(), comparison.getLeft(), comparison.getRight()); } if (not.getValue() instanceof NotExpression) { return normalize(((NotExpression) not.getValue()).getValue()); } } return expression; }
@Override protected Object visitNotExpression(NotExpression node, Object context) { Object value = process(node.getValue(), context); if (value == null) { return null; } if (value instanceof Expression) { return new NotExpression(toExpression(value, type(node.getValue()))); } return !(Boolean) value; }
@Override protected Type visitNotExpression(NotExpression node, StackableAstVisitorContext<Context> context) { coerceType(context, node.getValue(), BOOLEAN, "Value of logical NOT expression"); return setExpressionType(node, BOOLEAN); }
@Override public Expression rewriteNotExpression(NotExpression node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { if (node.getValue() instanceof LogicalBinaryExpression) { LogicalBinaryExpression child = (LogicalBinaryExpression) node.getValue(); List<Expression> predicates = extractPredicates(child); List<Expression> negatedPredicates = predicates.stream().map(predicate -> treeRewriter.rewrite((Expression) new NotExpression(predicate), context)).collect(toImmutableList()); return combinePredicates(child.getOperator().flip(), negatedPredicates); } else if (node.getValue() instanceof ComparisonExpression && ((ComparisonExpression) node.getValue()).getOperator() != IS_DISTINCT_FROM) { ComparisonExpression child = (ComparisonExpression) node.getValue(); return new ComparisonExpression(child.getOperator().negate(), treeRewriter.rewrite(child.getLeft(), context), treeRewriter.rewrite(child.getRight(), context)); } else if (node.getValue() instanceof NotExpression) { NotExpression child = (NotExpression) node.getValue(); return treeRewriter.rewrite(child.getValue(), context); } return new NotExpression(treeRewriter.rewrite(node.getValue(), context)); } }
private static boolean isSemiJoinOutputReference(Expression conjunct, Symbol semiJoinOutput) { SymbolReference semiJoinOuputSymbolReference = semiJoinOutput.toSymbolReference(); return conjunct.equals(semiJoinOuputSymbolReference) || (conjunct instanceof NotExpression && ((NotExpression) conjunct).getValue().equals(semiJoinOuputSymbolReference)); }
@Override protected RowExpression visitNotExpression(NotExpression node, Void context) { return call(Signatures.notSignature(), BOOLEAN, process(node.getValue(), context)); }
@Override protected String visitNotExpression(NotExpression node, Boolean negate) { return process(node.getValue(), !negate); }
@Override protected String visitNotExpression(NotExpression node, Void context) { return "(NOT " + process(node.getValue(), context) + ")"; }
@Override protected String visitNotExpression(NotExpression node, Boolean context) { return "(NOT " + process(node.getValue(), context) + ")"; }
@Override protected Boolean visitNotExpression(NotExpression node, Void context) { return process(node.getValue(), context); }
@Override protected String visitNotExpression(NotExpression node, Void context) { return "(NOT " + process(node.getValue(), context) + ")"; }
@Override protected Type visitNotExpression(NotExpression node, StackableAstVisitorContext<AnalysisContext> context) { coerceType(context, node.getValue(), BOOLEAN, "Value of logical NOT expression"); expressionTypes.put(node, BOOLEAN); return BOOLEAN; }
@Override protected R visitNotExpression(NotExpression node, C context) { return process(node.getValue(), context); }
@Override protected Object visitNotExpression(NotExpression node, Object context) { Object value = process(node.getValue(), context); if (value == null) { return null; } if (value instanceof Expression) { return new NotExpression(toExpression(value, expressionTypes.get(node.getValue()))); } return !(Boolean) value; }