zachjsh commented on code in PR #14483:
URL: https://github.com/apache/druid/pull/14483#discussion_r1240598243


##########
sql/src/main/java/org/apache/druid/sql/calcite/run/SqlResults.java:
##########
@@ -161,16 +163,32 @@ public static Object coerce(
         // here if needed
         coercedValue = maybeCoerceArrayToList(value, true);
         if (coercedValue == null) {
-          throw new ISE("Cannot coerce [%s] to %s", 
value.getClass().getName(), sqlTypeName);
+          throw new ISE(prepareCoerceException(value, sqlTypeName, fieldName));
         }
       }
     } else {
-      throw new ISE("Cannot coerce [%s] to %s", value.getClass().getName(), 
sqlTypeName);
+      throw new ISE(prepareCoerceException(value, sqlTypeName, fieldName));
     }
 
     return coercedValue;
   }
 
+  private static String prepareCoerceException(Object value, SqlTypeName 
sqlTypeName, String fieldName)
+  {
+    return StringUtils.format(
+        "Cannot coerce field [%s] of value with class [%s] to %s",

Review Comment:
   `"Cannot coerce field [%s] of type [%s] to  type [%s]"`



##########
sql/src/main/java/org/apache/druid/sql/calcite/run/SqlResults.java:
##########
@@ -161,16 +163,32 @@ public static Object coerce(
         // here if needed
         coercedValue = maybeCoerceArrayToList(value, true);
         if (coercedValue == null) {
-          throw new ISE("Cannot coerce [%s] to %s", 
value.getClass().getName(), sqlTypeName);
+          throw new ISE(prepareCoerceException(value, sqlTypeName, fieldName));
         }
       }
     } else {
-      throw new ISE("Cannot coerce [%s] to %s", value.getClass().getName(), 
sqlTypeName);
+      throw new ISE(prepareCoerceException(value, sqlTypeName, fieldName));
     }
 
     return coercedValue;
   }
 
+  private static String prepareCoerceException(Object value, SqlTypeName 
sqlTypeName, String fieldName)
+  {
+    return StringUtils.format(
+        "Cannot coerce field [%s] of value with class [%s] to %s",

Review Comment:
   `"Cannot coerce field [%s] of type [%s] to type [%s]"`



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