FrankChen021 commented on code in PR #20094:
URL: https://github.com/apache/druid/pull/20094#discussion_r3836152550
##########
sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidCorrelateUnnestRel.java:
##########
@@ -282,21 +283,29 @@ public DruidQuery toDruidQuery(boolean
finalizeAggregations)
final Filter whereFilter =
newLeftDruidRel.getPartialDruidQuery().getWhereFilter();
final RowSignature leftSignature =
DruidRels.dataSourceSignature(newLeftDruidRel);
if (whereFilter == null) {
- if (computeLeftRequiresSubquery(newLeftDruidRel)) {
+ if (updatedLeftQuery.getQuery() instanceof GroupByQuery) {
Review Comment:
[P1] GroupByQuery check is too late to preserve grouped rows
The rewrite above can rebuild a grouped left relation from only its
scan/project before this check, making updatedLeftQuery a ScanQuery rather than
a GroupByQuery. A query that groups an array column and then UNNESTs it can
therefore still read raw pre-group rows and return duplicates or incorrect
results. Detect and preserve grouping before rebuilding the left query, with a
regression test.
--
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]