Skip to content

Commit

Permalink
Fix the issue of unexpected results generated by groupBy queries when…
Browse files Browse the repository at this point in the history
… containing subqueries(#17598)
  • Loading branch information
soullkk committed Jan 1, 2025
1 parent 2d95d3b commit cdb8405
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.druid.query.FrameSignaturePair;
import org.apache.druid.query.IterableRowsCursorHelper;
import org.apache.druid.query.Query;
import org.apache.druid.query.QueryContexts;
import org.apache.druid.query.QueryDataSource;
import org.apache.druid.query.QueryPlus;
import org.apache.druid.query.QueryResourceId;
Expand Down Expand Up @@ -271,6 +272,9 @@ private Sequence<ResultRow> mergeGroupByResultsWithoutPushDown(
if (((QueryDataSource) dataSource).getQuery().getContext() != null) {
subqueryContext.putAll(((QueryDataSource) dataSource).getQuery().getContext());
}
if (canPerformSubquery(((QueryDataSource) dataSource).getQuery())) {
subqueryContext.put(QueryContexts.FINALIZE_KEY, true);
}
subqueryContext.put(GroupByQuery.CTX_KEY_SORT_BY_DIMS_FIRST, false);
subquery = (GroupByQuery) ((QueryDataSource) dataSource).getQuery().withOverriddenContext(subqueryContext);

Expand Down

0 comments on commit cdb8405

Please sign in to comment.