private static boolean containsGet(RexNode node) { try { node.accept( new RexVisitorImpl<Void>(true) { @Override public Void visitCall(RexCall call) { if (call.getOperator() == RexBuilder.GET_OPERATOR) { throw Util.FoundOne.NULL; } return super.visitCall(call); } }); return false; } catch (Util.FoundOne e) { return true; } }
/** * Shifts every {@link RexInputRef} in an expression by {@code offset}. */ public static RexNode shift(RexNode node, final int offset) { return node.accept( new RexShuttle() { @Override public RexNode visitInputRef(RexInputRef input) { return new RexInputRef(input.getIndex() + offset, input.getType()); } }); }
/** * Returns the highest level of any of the inputs of an expression. */ public int maxInputFor(RexNode expr) { level = 0; expr.accept(this); return level; } }
/** * Applies this shuttle to an expression, or returns null if the expression * is null. */ public final RexNode apply(RexNode expr) { return (expr == null) ? null : expr.accept(this); } }
public Void visitCall(RexCall call) { for (RexNode operand : call.operands) { operand.accept(this); } return null; }
RexWindowBound.create(window.getUpperBound(), upperBound), window); return rexAgg.accept(visitor); } finally { bb.window = null;
public Void visitCall(RexCall call) { for (RexNode operand : call.operands) { operand.accept(this); } return null; }
/** * Registers an expression in the list of common sub-expressions, and * returns a reference to that expression. * <p>The expression must be expressed in terms of the <em>inputs</em> of * this program.</p> */ public RexLocalRef registerInput(RexNode expr) { final RexShuttle shuttle = new RegisterInputShuttle(true); final RexNode ref = expr.accept(shuttle); return (RexLocalRef) ref; }
public RexNode visitLocalRef(RexLocalRef local) { // Convert a local ref into the common-subexpression it references. final int index = local.getIndex(); return localExprList.get(index).accept(this); } }
public RexNode visitLocalRef(RexLocalRef local) { // Convert a local ref into the common-subexpression it references. final int index = local.getIndex(); return localExprList.get(index).accept(this); } }
@Override public <R> RexWindowBound accept(RexVisitor<R> visitor) { R r = offset.accept(visitor); if (r instanceof RexNode && r != offset) { return new RexWindowBoundBounded(sqlKind, (RexNode) r); } return this; }
/** * Returns whether an expression contains an OVER clause. */ public static boolean containsOver(RexNode expr) { try { expr.accept(FINDER); return false; } catch (OverFound e) { Util.swallow(e, null); return true; } }
public Boolean visitFieldAccess(RexFieldAccess fieldAccess) { // "<expr>.FIELD" is constant iff "<expr>" is constant. return fieldAccess.getReferenceExpr().accept(this); } }
public Boolean visitCall(RexCall call) { for (RexNode operand : call.getOperands()) { Boolean valid = operand.accept(this); if (valid != null && !valid) { return false; } } return true; }
public RexNode visitCall(RexCall call) { final List<RexNode> newOperands = new ArrayList<RexNode>(); for (RexNode operand : call.getOperands()) { newOperands.add(operand.accept(this)); } return call.clone(call.getType(), newOperands); }
public void visit( RelNode p, int ordinal, RelNode parent) { List<RexNode> childExps = p.getChildExps(); for (RexNode childExp : childExps) { childExp.accept(visitor); } p.childrenAccept(this); } }
@Override public RelNode visit(ProjectRel project) { for (RexNode node : project.getProjects()) { node.accept(rexVisitor(project)); } return super.visit(project); }
public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { final RexNode referenceExpr = fieldAccess.getReferenceExpr().accept(this); return new RexFieldAccess( referenceExpr, fieldAccess.getField()); } }
public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { return builder.makeFieldAccess( fieldAccess.getReferenceExpr().accept(this), fieldAccess.getField().getIndex()); }
public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { final RexNode expr = fieldAccess.getReferenceExpr(); expr.accept(this); final RexNode normalizedExpr = lookup(expr); if (normalizedExpr != expr) { fieldAccess = new RexFieldAccess( normalizedExpr, fieldAccess.getField()); } return register(fieldAccess); }