xiedeyantu commented on code in PR #4260:
URL: https://github.com/apache/calcite/pull/4260#discussion_r2015227048
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java:
##########
@@ -4741,6 +4743,47 @@ private static class IsNullImplementor extends
AbstractRexCallImplementor {
}
}
+ /** Implementor for the {@code IS NOT DISTINCT FROM} SQL operator. */
+ private static class IsNotDistinctFromImplementor extends
AbstractRexCallImplementor {
+ IsNotDistinctFromImplementor() {
+ super("is_not_distinct_from", NullPolicy.NONE, false);
+ }
+
+ @Override public RexToLixTranslator.Result implement(final
RexToLixTranslator translator,
+ final RexCall call, final List<RexToLixTranslator.Result> arguments) {
+ final RexToLixTranslator.Result left = arguments.get(0);
+ final RexToLixTranslator.Result right = arguments.get(1);
+
+ final Expression valueExpression =
+ Expressions.condition(left.isNullVariable,
+ Expressions.condition(right.isNullVariable, BOXED_TRUE_EXPR,
BOXED_FALSE_EXPR),
+ Expressions.condition(right.isNullVariable, BOXED_FALSE_EXPR,
+ Expressions.equal(left.valueVariable, right.valueVariable)));
+
+ BlockBuilder builder = translator.getBlockBuilder();
+ final ParameterExpression valueVariable =
+ Expressions.parameter(valueExpression.getType(),
+ builder.newName(variableName + "_value"));
+ final Expression isNullExpression = FALSE_EXPR;
+ final ParameterExpression isNullVariable =
+ Expressions.parameter(Boolean.TYPE,
+ builder.newName(variableName + "_isNull"));
+
+ builder.add(
+ Expressions.declare(Modifier.FINAL, valueVariable, valueExpression));
+ builder.add(
+ Expressions.declare(Modifier.FINAL, isNullVariable,
isNullExpression));
+
+ return new RexToLixTranslator.Result(isNullVariable, valueVariable);
+ }
+
+ @Override Expression implementSafe(final RexToLixTranslator translator,
+ final RexCall call, final List<Expression> argValueList) {
+ throw new IllegalStateException("This implementSafe should not be
called,"
+ + " please call implement(...)");
Review Comment:
Here we need to Implement `implementSafe` method, I referred to other
implementations and also threw an error here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]