abhishekagarwal87 commented on code in PR #14483:
URL: https://github.com/apache/druid/pull/14483#discussion_r1247815051
##########
sql/src/main/java/org/apache/druid/sql/calcite/run/SqlResults.java:
##########
@@ -220,41 +221,60 @@ private static DateTime coerceDateTime(Object value,
SqlTypeName sqlType)
} else if (value instanceof DateTime) {
dateTime = (DateTime) value;
} else {
- throw cannotCoerce(value, sqlType);
+ throw cannotCoerce(value, sqlType, fieldName);
}
return dateTime;
}
private static String coerceUsingObjectMapper(
final ObjectMapper jsonMapper,
final Object value,
- final SqlTypeName sqlTypeName
+ final SqlTypeName sqlTypeName,
+ final String fieldName
)
{
try {
return jsonMapper.writeValueAsString(value);
}
catch (JsonProcessingException e) {
- throw cannotCoerce(e, value, sqlTypeName);
+ throw cannotCoerce(e, value, sqlTypeName, fieldName);
}
}
- private static IllegalStateException cannotCoerce(
- final Throwable t,
- final Object value,
- final SqlTypeName sqlTypeName
- )
+ private static DruidException cannotCoerce(final Throwable t, final Object
value, final SqlTypeName sqlTypeName, final String fieldName)
+ {
+ return DruidException.forPersona(DruidException.Persona.USER)
+ .ofCategory(DruidException.Category.INVALID_INPUT)
+ .build(
+ t,
+ "Cannot coerce field [%s] class of [%s] to [%s]",
Review Comment:
or
```suggestion
"Cannot coerce field [%s] of class [%s] to
class [%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]