zabetak commented on a change in pull request #2141:
URL: https://github.com/apache/calcite/pull/2141#discussion_r485078224
##########
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:
Not necessarily subject of this PR but couldn't this logic be inside
`leastRestrictive`? If there is only one type then it is also the least
restrictive so putting it inside we don't break anything in terms of API.
Moreover, if we want to force users to pass more than one type then it would be
better to check this via regular exceptions (e.g., `IllegalArgumentException`)
instead of assertions that can even be disabled.
----------------------------------------------------------------
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]