vlsi commented on a change in pull request #2141:
URL: https://github.com/apache/calcite/pull/2141#discussion_r485091849



##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -2690,7 +2694,14 @@ int complexity() {
     }
 
     @Override public RelDataType getType() {
-      return rexBuilder.typeFactory.leastRestrictive(Util.distinctList(types));
+      List<RelDataType> distinctTypes = Util.distinctList(this.types);
+      assert distinctTypes.size() >= 1 : "at least one type expected";
+      if (distinctTypes.size() == 1) {
+        return distinctTypes.get(0);

Review comment:
       It probably makes sense to move this `if size=1` check to the 
`leastRestrictive` method.
   
   However, I do not know if `null` result is permissible here or if it is a 
catastrophic failure, so I added an assertion, except I put the relevant 
clarification to the message.




----------------------------------------------------------------
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:
[email protected]


Reply via email to