clintropolis commented on a change in pull request #11853:
URL: https://github.com/apache/druid/pull/11853#discussion_r744012367



##########
File path: core/src/main/java/org/apache/druid/math/expr/ExprEval.java
##########
@@ -554,33 +367,103 @@ public static ExprEval bestEffortOf(@Nullable Object val)
     if (val instanceof ExprEval) {
       return (ExprEval) val;
     }
+    if (val instanceof String) {
+      return new StringExprEval((String) val);
+    }
     if (val instanceof Number) {
       if (val instanceof Float || val instanceof Double) {
         return new DoubleExprEval((Number) val);
       }
       return new LongExprEval((Number) val);
     }
     if (val instanceof Long[]) {
-      return new LongArrayExprEval((Long[]) val);
+      return new ArrayExprEval(ExpressionType.LONG_ARRAY, (Long[]) val);
     }
     if (val instanceof Double[]) {
-      return new DoubleArrayExprEval((Double[]) val);
+      return new ArrayExprEval(ExpressionType.DOUBLE_ARRAY, (Double[]) val);
     }
     if (val instanceof Float[]) {
-      return new DoubleArrayExprEval(Arrays.stream((Float[]) 
val).map(Float::doubleValue).toArray(Double[]::new));
+      return new ArrayExprEval(ExpressionType.DOUBLE_ARRAY, 
Arrays.stream((Float[]) val).map(Float::doubleValue).toArray());
     }
     if (val instanceof String[]) {
-      return new StringArrayExprEval((String[]) val);
+      return new ArrayExprEval(ExpressionType.STRING_ARRAY, (String[]) val);
+    }
+    if (val instanceof Object[]) {
+      ExpressionType arrayType = findArrayType((Object[]) val);
+      if (arrayType != null) {
+        return new ArrayExprEval(arrayType, (Object[]) val);
+      }
+      // default to string if array is empty
+      return new ArrayExprEval(ExpressionType.STRING_ARRAY, (Object[]) val);
     }
 
     if (val instanceof List) {
       // do not convert empty lists to arrays with a single null element here, 
because that should have been done
       // by the selectors preparing their ObjectBindings if necessary. If we 
get to this point it was legitimately
       // empty
-      return bestEffortOf(coerceListToArray((List<?>) val, false));
+      NonnullPair<ExpressionType, Object[]> coerced = 
coerceListToArray((List<?>) val, false);
+      if (coerced == null) {
+        return bestEffortOf(null);
+      }

Review comment:
       yeah, because it is called inside of the `instanceof` I think you're 
right




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