clintropolis commented on code in PR #15366:
URL: https://github.com/apache/druid/pull/15366#discussion_r1408390380


##########
processing/src/main/java/org/apache/druid/math/expr/Function.java:
##########
@@ -3327,11 +3327,11 @@ public void validateArguments(List<Expr> args)
     @Override
     public ExpressionType getOutputType(Expr.InputBindingInspector inspector, 
List<Expr> args)
     {
-      ExpressionType type = ExpressionType.LONG;
+      ExpressionType type = null;
       for (Expr arg : args) {
-        type = ExpressionTypeConversion.function(type, 
arg.getOutputType(inspector));
+        type = ExpressionTypeConversion.leastRestrictiveType(type, 
arg.getOutputType(inspector));
       }
-      return ExpressionType.asArrayType(type);
+      return type == null ? null : 
ExpressionTypeFactory.getInstance().ofArray(type);
     }

Review Comment:
   it was wrong in some cases and written before `leastRestrictiveType` 
existed, for example if you try to use the array constructor function on an 
array type input, you end up with 
   ```
   org.apache.druid.segment.column.Types$IncompatibleTypeException: Cannot 
implicitly cast [LONG] to [ARRAY<STRING>]
   ```
   which doesn't happen after the change. Will add a test.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to