mihaibudiu commented on code in PR #4727:
URL: https://github.com/apache/calcite/pull/4727#discussion_r2666572083
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java:
##########
@@ -4842,6 +4844,58 @@ private static class IsNotDistinctFromImplementor
extends AbstractRexCallImpleme
}
}
+ /** Implementor for the {@code IS DISTINCT FROM} SQL operator. */
+ private static class IsDistinctFromImplementor extends
AbstractRexCallImplementor {
+ IsDistinctFromImplementor() {
+ super("is_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);
+
+ // Generated expression:
+ // left IS NULL ?
+ // (right IS NULL ? FALSE : TRUE) : -> when left is null
+ // (right IS NULL ? TRUE : -> when left is not null
+ // !left.equals(right)) -> when both are not null,
compare values
+ final Expression equalsExpression =
Review Comment:
This is an interesting approach, but from my experience it is dangerous to
subclass a different expression.
I would rather have a common abstract class and two final classes that
derive from it. Just slightly more verbose than what you wrote.
--
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]