gianm commented on a change in pull request #8775: Fix NPE for subquery with 
limit
URL: https://github.com/apache/incubator-druid/pull/8775#discussion_r340945547
 
 

 ##########
 File path: 
sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidOuterQueryRel.java
 ##########
 @@ -129,8 +131,10 @@ public DruidQuery toDruidQuery(final boolean 
finalizeAggregations)
     }
 
     final RowSignature sourceRowSignature = subQuery.getOutputRowSignature();
+    final GroupByQuery groupByQuery = subQuery.toGroupByQuery();
+    final DataSource dataSource = groupByQuery == null ? 
subQuery.getDataSource() : new QueryDataSource(groupByQuery);
 
 Review comment:
   I don't think this is correct. It is ignoring everything about `subQuery` 
except the underlying dataSource. It means that if the underlying query is 
doing something "interesting", like a limit, or expression, etc, then it will 
be ignored.
   
   I'd suggest doing this instead, to at least return a "nice" null instead of 
throwing NPE. Then that will get understood by the planner as an unplannable 
query.
   
   ```java
   if (groupByQuery == null) {
      return null;
   }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to