@Override public Double visitLiteral(RexLiteral literal) { if (literal.isAlwaysFalse() || RexUtil.isNull(literal)) { return 0.0; } else if (literal.isAlwaysTrue()) { return 1.0; } else { assert false; } return null; } }
public RexBuilder getRexBuilder() { return new RexBuilder(typeFactory); }
@Override public Boolean visitFieldAccess(RexFieldAccess fieldAccess) { // "<expr>.FIELD" is constant iff "<expr>" is constant. return fieldAccess.getReferenceExpr().accept(this); }
private static boolean isThreeArgCase(final RexNode rexNode) { return rexNode.getKind() == SqlKind.CASE && ((RexCall) rexNode).getOperands().size() == 3; } }
@Override public Boolean visitCall(RexCall call) { // Constant if operator is deterministic and all operands are // constant. return call.getOperator().isDeterministic() && RexVisitorImpl.visitArrayAnd(this, call.getOperands()); }
@Override public RexNode visitInputRef(RexInputRef inputRef) { final RexInputRef ref = getNewForOldInputRef(inputRef); if (ref.getIndex() == inputRef.getIndex() && ref.getType() == inputRef.getType()) { return inputRef; // re-use old object, to prevent needless expr cloning } return ref; } private RexNode decorrFieldAccess(RexFieldAccess fieldAccess) {
public BlockStatement compileToBlock(List<RexNode> nodes, RelDataType inputRowType) { final RexProgramBuilder programBuilder = new RexProgramBuilder(inputRowType, rexBuilder); for (RexNode node : nodes) { programBuilder.addProject(node, null); } return compileToBlock(programBuilder.getProgram()); }
private static RexTableInputRef extractTableInputRef(RexNode node) { RexTableInputRef ref = null; if (node instanceof RexTableInputRef) { ref = (RexTableInputRef) node; } else if (RexUtil.isLosslessCast(node) && ((RexCall) node).getOperands().get(0) instanceof RexTableInputRef) { ref = (RexTableInputRef) ((RexCall) node).getOperands().get(0); } return ref; }
private boolean go(RexNode cond) { cond.accept(this); return res; } }
private int pos(RexNode expr) { if (expr instanceof RexInputRef) { return ((RexInputRef) expr).getIndex(); } return -1; }
public String apply(RexNode input) { return input + ": " + input.getType(); } };
@Override public String toString() { return "ref for:" + node.toString(); } }
@Override public RexNode visitLiteral(RexLiteral literal) { // Use nullIndicator to decide whether to project null. // Do nothing if the literal is null. if (!RexUtil.isNull(literal) && projectPulledAboveLeftCorrelator && (nullIndicator != null)) { return createCaseExpression( nullIndicator, rexBuilder.constantNull(), literal); } return literal; }
private RexNode timestampLiteral(final DateTime timestamp) { return rexBuilder.makeTimestampLiteral(Calcites.jodaToCalciteTimestampString(timestamp, DateTimeZone.UTC), 0); }
@Override public RexNode visitSubQuery(RexSubQuery subQuery) { return RexUtil.eq(subQuery, this.subQuery) ? replacement : subQuery; } }
@Override public Boolean visitFieldAccess(RexFieldAccess fieldAccess) { // "<expr>.FIELD" is constant iff "<expr>" is constant. return fieldAccess.getReferenceExpr().accept(this); }
public String compile(List<RexNode> nodes, RelDataType inputRowType, String className) { final RexProgramBuilder programBuilder = new RexProgramBuilder(inputRowType, rexBuilder); for (RexNode node : nodes) { programBuilder.addProject(node, null); } return compile(programBuilder.getProgram(), className); }
public Void apply(RexNode input) { return input.accept(eF); } }));
public String apply(RexNode r) { return r.toString(); } };
public Double estimateSelectivity(RexNode predicate) { return predicate.accept(this); }