gianm commented on code in PR #16326:
URL: https://github.com/apache/druid/pull/16326#discussion_r1940506768


##########
processing/src/main/java/org/apache/druid/query/groupby/GroupingEngine.java:
##########
@@ -985,7 +988,7 @@ private static boolean summaryRowPreconditions(GroupByQuery 
query)
         return false;
       }
     }
-    if (!query.getDimensions().isEmpty()) {
+    if (!query.getDimensions().isEmpty() || query.hasDroppedDimensions()) {

Review Comment:
   With a clause like `GROUP BY 'dummy'`, we can drop the literal and treat it 
like `GROUP BY ()`, _but_ we need to remember that the dimension was dropped to 
ensure we handle the no-results case correctly:
   
   - When using `GROUP BY ()`, if no results match the filter, a summary row 
should be included.
   - When using `GROUP BY 'dummy'` a summary row should _not_ be included.
   
   When `hasDroppedDimensions` is true, i.e. in the `GROUP BY 'dummy'` case, we 
signify this to the native engine in two ways:
   
   - For native `groupBy` query type we set `hasDroppedDimensions: true` in the 
context.
   - For native `timeseries` query type we set `skipEmptyBuckets: true` in the 
context (look in `DruidQuery#toTimeseriesQuery` for this).
   
   You probably saw the query work as expected locally because it was planned 
into `timeseries`, and the code you have highlighted here is only for 
`groupBy`. Try running it with MSQ- in that case it will get planned to 
`groupBy` because the planner never uses `timeseries` for MSQ. Then you will 
see a difference.



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