private RexNode castNullLiteralIfNeeded(RexNode node, RelDataType type) { if (!RexLiteral.isNullLiteral(node)) { return node; } return rexBuilder.makeCast(type, node); }
assert literalExpr.isA(SqlKind.CAST); RexNode child = ((RexCall) literalExpr).getOperands().get(0); assert RexLiteral.isNullLiteral(child);
public void setPoint(RexNode coordinate) { super.setPoint(coordinate); if (RexLiteral.isNullLiteral(coordinate)) { // since they explicitly asked for the null value as a point, // adjust the null semantics to match if (nullSemantics == SqlNullSemantics.NULL_MATCHES_NOTHING) { nullSemantics = SqlNullSemantics.NULL_MATCHES_NULL; } } }
private RexNode castNullLiteralIfNeeded(RexNode node, RelDataType type) { if (!RexLiteral.isNullLiteral(node)) { return node; } return rexBuilder.makeCast(type, node); }
/** * @return true if this endpoint has the null value for its coordinate */ public boolean isNull() { if (!isFinite()) { return false; } return RexLiteral.isNullLiteral(coordinate); }
public void setPoint(RexNode coordinate) { super.setPoint(coordinate); if (RexLiteral.isNullLiteral(coordinate)) { // since they explicitly asked for the null value as a point, // adjust the null semantics to match if (nullSemantics == SqlNullSemantics.NULL_MATCHES_NOTHING) { nullSemantics = SqlNullSemantics.NULL_MATCHES_NULL; } } }
private RexNode castNullLiteralIfNeeded(RexNode node, RelDataType type) { if (!RexLiteral.isNullLiteral(node)) { return node; } return rexBuilder.makeCast(type, node); }
/** * @return true if this endpoint has the null value for its coordinate */ public boolean isNull() { if (!isFinite()) { return false; } return RexLiteral.isNullLiteral(coordinate); }
static int compareCoordinates(RexNode coord1, RexNode coord2) { assert coord1 instanceof RexLiteral; assert coord2 instanceof RexLiteral; // null values always sort lowest boolean isNull1 = RexLiteral.isNullLiteral(coord1); boolean isNull2 = RexLiteral.isNullLiteral(coord2); if (isNull1 && isNull2) { return 0; } else if (isNull1) { return -1; } else if (isNull2) { return 1; } else { RexLiteral lit1 = (RexLiteral) coord1; RexLiteral lit2 = (RexLiteral) coord2; return lit1.getValue().compareTo(lit2.getValue()); } }
static int compareCoordinates(RexNode coord1, RexNode coord2) { assert (coord1 instanceof RexLiteral); assert (coord2 instanceof RexLiteral); // null values always sort lowest boolean isNull1 = RexLiteral.isNullLiteral(coord1); boolean isNull2 = RexLiteral.isNullLiteral(coord2); if (isNull1 && isNull2) { return 0; } else if (isNull1) { return -1; } else if (isNull2) { return 1; } else { RexLiteral lit1 = (RexLiteral) coord1; RexLiteral lit2 = (RexLiteral) coord2; return lit1.getValue().compareTo(lit2.getValue()); } }
/** * 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 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; }
/** * Sets a finite value for this endpoint. * * @param boundType bound type (upper/lower) * @param strictness boundary strictness * @param coordinate endpoint position */ void setFinite( SargBoundType boundType, SargStrictness strictness, RexNode coordinate) { // validate the input assert (coordinate != null); if (!(coordinate instanceof RexDynamicParam) && !(coordinate instanceof RexInputRef)) { assert (coordinate instanceof RexLiteral); RexLiteral literal = (RexLiteral) coordinate; if (!RexLiteral.isNullLiteral(literal)) { assert (SqlTypeUtil.canAssignFrom( dataType, literal.getType())); } } this.boundType = boundType; this.coordinate = coordinate; this.strictness = strictness; convertToTargetType(); }
/** * Sets a finite value for this endpoint. * * @param boundType bound type (upper/lower) * @param strictness boundary strictness * @param coordinate endpoint position */ void setFinite( SargBoundType boundType, SargStrictness strictness, RexNode coordinate) { // validate the input assert coordinate != null; if (!(coordinate instanceof RexDynamicParam) && !(coordinate instanceof RexInputRef)) { assert coordinate instanceof RexLiteral; RexLiteral literal = (RexLiteral) coordinate; if (!RexLiteral.isNullLiteral(literal)) { assert SqlTypeUtil.canAssignFrom( dataType, literal.getType()); } } this.boundType = boundType; this.coordinate = coordinate; this.strictness = strictness; convertToTargetType(); }
/** * @return true if all tuples match rowType; otherwise, assert on mismatch */ private boolean assertRowType() { for (List<RexLiteral> tuple : tuples) { assert tuple.size() == rowType.getFieldCount(); for (Pair<RexLiteral, RelDataTypeField> pair : Pair.zip(tuple, rowType.getFieldList())) { RexLiteral literal = pair.left; RelDataType fieldType = pair.right.getType(); // TODO jvs 19-Feb-2006: strengthen this a bit. For example, // overflow, rounding, and padding/truncation must already have // been dealt with. if (!RexLiteral.isNullLiteral(literal)) { assert SqlTypeUtil.canAssignFrom(fieldType, literal.getType()) : "to " + fieldType + " from " + literal; } } } return true; }
/** * @return true if all tuples match rowType; otherwise, assert on mismatch */ private boolean assertRowType() { for (List<RexLiteral> tuple : tuples) { assert tuple.size() == rowType.getFieldCount(); for (Pair<RexLiteral, RelDataTypeField> pair : Pair.zip(tuple, rowType.getFieldList())) { RexLiteral literal = pair.left; RelDataType fieldType = pair.right.getType(); // TODO jvs 19-Feb-2006: strengthen this a bit. For example, // overflow, rounding, and padding/truncation must already have // been dealt with. if (!RexLiteral.isNullLiteral(literal)) { assert (SqlTypeUtil.canAssignFrom( fieldType, literal.getType())); } } } return true; }
if (RexLiteral.isNullLiteral(literal)) { return;
if (RexLiteral.isNullLiteral(literal)) { return;
assert literalExpr.isA(SqlKind.CAST); RexNode child = ((RexCall) literalExpr).getOperands().get(0); assert RexLiteral.isNullLiteral(child);
assert (literalExpr.isA(RexKind.Cast)); RexNode child = ((RexCall) literalExpr).getOperands().get(0); assert RexLiteral.isNullLiteral(child);