julianhyde commented on a change in pull request #2144:
URL: https://github.com/apache/calcite/pull/2144#discussion_r485806842



##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -2690,7 +2691,14 @@ int complexity() {
     }
 
     @Override public RelDataType getType() {
-      return rexBuilder.typeFactory.leastRestrictive(Util.distinctList(types));
+      if (this.types.isEmpty()) {
+        // Expression is "x IS NULL"
+        return ref.getType();

Review comment:
       I agree it's a bit strange. It's tricky because the assignment rules for 
the left-hand type are different from the right-hand types.
   
   The type assignment rules are complicated (e.g. when you compare a REAL to a 
DECIMAL, do you convert the REAL to a DECIMAL or vice versa?; and hundred other 
things.  I decided to not spend effort addressing it at this point.  If you can 
find a SQL example where it matters, log a bug.

##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -2690,7 +2691,14 @@ int complexity() {
     }
 
     @Override public RelDataType getType() {
-      return rexBuilder.typeFactory.leastRestrictive(Util.distinctList(types));
+      if (this.types.isEmpty()) {
+        // Expression is "x IS NULL"
+        return ref.getType();

Review comment:
       I agree it's a bit strange. It's tricky because the assignment rules for 
the left-hand type are different from the right-hand types.
   
   The type assignment rules are complicated (e.g. when you compare a REAL to a 
DECIMAL, do you convert the REAL to a DECIMAL or vice versa?; and hundred other 
things).  I decided to not spend effort addressing it at this point.  If you 
can find a SQL example where it matters, log a bug.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to