@Override public Expression rewriteIsNotNullPredicate(IsNotNullPredicate node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { Expression value = treeRewriter.rewrite(node.getValue(), context); return new NotExpression(new IsNullPredicate(value)); }
@Override protected Void visitComparisonExpression(ComparisonExpression node, Integer indentLevel) { print(indentLevel, node.getOperator().toString()); super.visitComparisonExpression(node, indentLevel + 1); return null; }
@Override protected Void visitLogicalBinaryExpression(LogicalBinaryExpression node, Integer indentLevel) { print(indentLevel, node.getOperator().toString()); super.visitLogicalBinaryExpression(node, indentLevel + 1); return null; }
private static QualifiedName asQualifiedName(Expression expression) { QualifiedName name = null; if (expression instanceof Identifier) { name = QualifiedName.of(((Identifier) expression).getValue()); } else if (expression instanceof DereferenceExpression) { name = DereferenceExpression.getQualifiedName((DereferenceExpression) expression); } return name; }
@Override public Expression rewriteLambdaExpression(LambdaExpression node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { return new LambdaExpression(node.getArguments(), treeRewriter.rewrite(node.getBody(), context)); } }, expression);
@Override protected R visitSampledRelation(SampledRelation node, C context) { process(node.getRelation(), context); process(node.getSamplePercentage(), context); return null; }
@Override protected R visitAtTimeZone(AtTimeZone node, C context) { process(node.getValue(), context); process(node.getTimeZone(), context); return null; }
@Override protected R visitSelect(Select node, C context) { for (SelectItem item : node.getSelectItems()) { process(item, context); } return null; }
@Override protected R visitCoalesceExpression(CoalesceExpression node, C context) { for (Expression operand : node.getOperands()) { process(operand, context); } return null; }
@Override protected Void visitSelect(Select node, Integer indentLevel) { String distinct = ""; if (node.isDistinct()) { distinct = "[DISTINCT]"; } print(indentLevel, "Select" + distinct); super.visitSelect(node, indentLevel + 1); // visit children return null; }
@Override protected R visitOrderBy(OrderBy node, C context) { for (SortItem sortItem : node.getSortItems()) { process(sortItem, context); } return null; }
@Override protected R visitExists(ExistsPredicate node, C context) { process(node.getSubquery(), context); return null; }
@Override protected R visitLateral(Lateral node, C context) { process(node.getQuery(), context); return super.visitLateral(node, context); } }
@Override protected R visitGroupingOperation(GroupingOperation node, C context) { for (Expression columnArgument : node.getGroupingColumns()) { process(columnArgument, context); } return null; }
@Override protected Void visitArithmeticBinary(ArithmeticBinaryExpression node, Integer indentLevel) { print(indentLevel, node.getOperator().toString()); super.visitArithmeticBinary(node, indentLevel + 1); return null; }