LakshSingla commented on code in PR #16620:
URL: https://github.com/apache/druid/pull/16620#discussion_r1671693644
##########
processing/src/main/java/org/apache/druid/query/groupby/GroupByQueryQueryToolChest.java:
##########
@@ -727,13 +716,33 @@ public ResultRow apply(Object input)
int dimPos = 0;
while (dimsIter.hasNext() && results.hasNext()) {
final DimensionSpec dimensionSpec = dimsIter.next();
-
- // Must convert generic Jackson-deserialized type into the
proper type.
- resultRow.set(
- dimensionStart + dimPos,
- DimensionHandlerUtils.convertObjectToType(results.next(),
dimensionSpec.getOutputType())
- );
-
+ final Object dimensionObject = results.next();
+ final Object dimensionObjectCasted;
+
+ final ColumnType outputType = dimensionSpec.getOutputType();
+
+ // Must convert generic Jackson-deserialized type into the
proper type. The downstream functions expect the
+ // dimensions to be of appropriate types for further processing
like merging and comparing.
+ if (outputType.is(ValueType.COMPLEX)) {
+ // Json columns can interpret generic data objects
appropriately, hence they are wrapped as is in StructuredData.
+ // They don't need to converted them from Object.class to
StructuredData.class using object mapper as that is an
+ // expensive operation that will be wasteful.
+ if (outputType.equals(ColumnType.NESTED_DATA)) {
+ dimensionObjectCasted = StructuredData.wrap(dimensionObject);
+ } else {
+ DruidException.conditionalDefensive(
+ mapper != null,
+ "Cannot deserialize complex dimension from if object
mapper is not provided"
+ );
Review Comment:
Makes sense, I'll move the checks there.
--
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]