case GREATER_THAN_OR_EQUAL: if (rexBuilder != null && RexUtil.isReferenceOrAccess(call.operands.get(1), true) && RexUtil.isLiteral(call.operands.get(0), true)) {
/** * Returns whether every expression in a list is a literal. * * @param expressionOperands list of expressions to check * @return true if every expression from the specified list is literal. */ public static boolean allLiterals(List<RexNode> expressionOperands) { for (RexNode rexNode : expressionOperands) { if (!isLiteral(rexNode, true)) { return false; } } return true; }
/** * Returns whether every expression in a list is a literal. * * @param expressionOperands list of expressions to check * @return true if every expression from the specified list is literal. */ public static boolean allLiterals(List<RexNode> expressionOperands) { for (RexNode rexNode : expressionOperands) { if (!isLiteral(rexNode, true)) { return false; } } return true; }
@Override public boolean isOperandLiteral(int ordinal, boolean allowCast) { return RexUtil.isLiteral(operands.get(ordinal), allowCast); }
@Override public boolean isOperandLiteral(int ordinal, boolean allowCast) { return RexUtil.isLiteral(operands.get(ordinal), allowCast); }
if (node.isA(SqlKind.CAST)) { RexCall call = (RexCall) node; if (isLiteral(call.operands.get(0), false)) {
if (node.isA(SqlKind.CAST)) { RexCall call = (RexCall) node; if (isLiteral(call.operands.get(0), false)) {
/** Tests {@link org.apache.calcite.rex.RexUtil#isLiteral(RexNode, boolean)}, * which was added to enhance Calcite's public API * <a href="https://issues.apache.org/jira/browse/CALCITE-1219">[CALCITE-1219] * Add a method to SqlOperatorBinding to determine whether operand is a * literal</a>. */ @Test public void testRexNodeLiteral() { final RexNode literal = rexBuilder.makeZeroLiteral( integerDataType); final RexNode castLiteral = rexBuilder.makeCall( integerDataType, SqlStdOperatorTable.CAST, Lists.newArrayList(literal)); final RexNode castCastLiteral = rexBuilder.makeCall( integerDataType, SqlStdOperatorTable.CAST, Lists.newArrayList(castLiteral)); // RexLiteral is considered as a Literal assertSame(true, RexUtil.isLiteral(literal, true)); // CAST(RexLiteral as type) is considered as a Literal assertSame(true, RexUtil.isLiteral(castLiteral, true)); // CAST(CAST(RexLiteral as type) as type) is NOT considered as a Literal assertSame(false, RexUtil.isLiteral(castCastLiteral, true)); } }
/** Tests {@link org.apache.calcite.rex.RexUtil#isLiteral(RexNode, boolean)}, * which was added to enhance Calcite's public API * <a href="https://issues.apache.org/jira/browse/CALCITE-1219">[CALCITE-1219] * Add a method to SqlOperatorBinding to determine whether operand is a * literal</a>. */ @Test public void testRexNodeLiteral() { final RexNode literal = rexBuilder.makeZeroLiteral( integerDataType); final RexNode castLiteral = rexBuilder.makeCall( integerDataType, SqlStdOperatorTable.CAST, Lists.newArrayList(literal)); final RexNode castCastLiteral = rexBuilder.makeCall( integerDataType, SqlStdOperatorTable.CAST, Lists.newArrayList(castLiteral)); // RexLiteral is considered as a Literal assertSame(true, RexUtil.isLiteral(literal, true)); // CAST(RexLiteral as type) is considered as a Literal assertSame(true, RexUtil.isLiteral(castLiteral, true)); // CAST(CAST(RexLiteral as type) as type) is NOT considered as a Literal assertSame(false, RexUtil.isLiteral(castCastLiteral, true)); } }
List<RexNode> projectedExpressions = expressionsCollector.getProjectedExpressions(); return projectedExpressions.size() == 1 && RexUtil.isLiteral(projectedExpressions.get(agg.getGroupSet().nth(0)), true);