List<RexNode> extraLeftExprs, List<RexNode> extraRightExprs) { switch (node.getKind()) { case AND: case OR:
public boolean isA(SqlKind kind) { return getKind() == kind; }
public boolean isA(Collection<SqlKind> kinds) { return getKind().belongsTo(kinds); }
/** * Returns whether a node represents the NULL value or a series of nested * CAST(NULL as <TYPE>) calls<br> * For Example:<br> * isNull(CAST(CAST(NULL as INTEGER) AS VARCHAR(1))) returns true */ public static boolean isNull(RexNode node) { /* Checks to see if the RexNode is null */ return RexLiteral.isNullLiteral(node) || ((node.getKind() == RexKind.Cast) && isNull(((RexCall) node).operands.get(0))); }
/** * Returns whether a node represents the NULL value or a series of nested * {@code CAST(NULL AS type)} calls. For example: * <code>isNull(CAST(CAST(NULL as INTEGER) AS VARCHAR(1)))</code> * returns {@code true}. */ public static boolean isNull(RexNode expr) { switch (expr.getKind()) { case LITERAL: return ((RexLiteral) expr).getValue2() == null; case CAST: return isNull(((RexCall) expr).operands.get(0)); default: return false; } }
private void addResult(RexNode exp) { // Cast of literal can't be reduced, so skip those (otherwise we'd // go into an infinite loop as we add them back). if (exp.getKind() == SqlKind.CAST) { RexCall cast = (RexCall) exp; RexNode operand = cast.getOperands().get(0); if (operand instanceof RexLiteral) { return; } } constExprs.add(exp); // In the case where the expression corresponds to a UDR argument, // we need to preserve casts. Note that this only applies to // the topmost argument, not expressions nested within the UDR // call. // // REVIEW zfong 6/13/08 - Are there other expressions where we // also need to preserve casts? if (parentCallTypeStack.isEmpty()) { addCasts.add(false); } else { addCasts.add(isUdf(Stacks.peek(parentCallTypeStack))); } }
switch (joinFilter.getKind()) { case EQUALS: break;
/** * Returns whether an expression always evaluates to null. * * <p>Like {@link RexUtil#isNull(RexNode)}, null literals are null, and | * casts of null literals are null. But this method also regards references * to null expressions as null.</p> * * @param expr Expression * @return Whether expression always evaluates to null */ public boolean isNull(RexNode expr) { switch (expr.getKind()) { case LITERAL: return ((RexLiteral) expr).getValue2() == null; case LOCAL_REF: RexLocalRef inputRef = (RexLocalRef) expr; return isNull(exprs.get(inputRef.index)); case CAST: return isNull(((RexCall) expr).operands.get(0)); default: return false; } }
/** * Returns whether an expression always evaluates to null. * * <p/>Like {@link RexUtil#isNull(RexNode)}, null literals are null, and * casts of null literals are null. But this method also regards references * to null expressions as null. * * @param expr Expression * * @return Whether expression always evaluates to null */ public boolean isNull(RexNode expr) { if (RexLiteral.isNullLiteral(expr)) { return true; } if (expr instanceof RexLocalRef) { RexLocalRef inputRef = (RexLocalRef) expr; return isNull(exprs.get(inputRef.index)); } if (expr.getKind() == RexKind.Cast) { return isNull(((RexCall) expr).operands.get(0)); } return false; }
for (int i = 0; i < disjunctions.size(); i++) { final RexNode disjunction = disjunctions.get(i); final RexKind kind = disjunction.getKind(); switch (kind) { case Not:
public RexNode apply(RexNode input) { return input.isAlwaysTrue() ? rexBuilder.makeLiteral(false) : input.isAlwaysFalse() ? rexBuilder.makeLiteral(true) : input.getKind() == SqlKind.NOT ? ((RexCall) input).operands.get(0) : rexBuilder.makeCall(SqlStdOperatorTable.NOT, input); } };
for (int i = 0; i < disjunctions.size(); i++) { final RexNode disjunction = disjunctions.get(i); final SqlKind kind = disjunction.getKind(); switch (kind) { case NOT:
if (leftBitmap.cardinality() == 1) { switch (joinFilter.getKind()) { case EQUALS: weight = 3;
return; switch (rexPredicate.getKind()) { case AND: for (RexNode operand : ((RexCall) rexPredicate).getOperands()) {
private boolean strong(RexNode node) { switch (node.getKind()) { case LITERAL: return ((RexLiteral) node).getValue() == null; case IS_TRUE: case IS_NOT_NULL: case AND: case EQUALS: case NOT_EQUALS: case LESS_THAN: case LESS_THAN_OR_EQUAL: case GREATER_THAN: case GREATER_THAN_OR_EQUAL: return anyStrong(((RexCall) node).getOperands()); case OR: return allStrong(((RexCall) node).getOperands()); case INPUT_REF: return nullColumns.get(((RexInputRef) node).getIndex()); default: return false; } }
if (joinExp.getKind() != RexKind.Equals) { return false;
int[] joinFieldOrdinals) { RexNode joinExp = joinRel.getCondition(); if (joinExp.getKind() != SqlKind.EQUALS) { return false;
if (pred.getKind() == SqlKind.IS_NOT_NULL) { sel *= .9; } else if (