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(apache#17598)
  • Loading branch information
soullkk committed Jan 1, 2025
1 parent 2d95d3b commit cf38617
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,7 @@
import org.apache.druid.java.util.common.guava.Sequence;
import org.apache.druid.java.util.common.guava.Sequences;
import org.apache.druid.java.util.common.io.Closer;
import org.apache.druid.query.CacheStrategy;
import org.apache.druid.query.DataSource;
import org.apache.druid.query.FrameSignaturePair;
import org.apache.druid.query.IterableRowsCursorHelper;
import org.apache.druid.query.Query;
import org.apache.druid.query.QueryDataSource;
import org.apache.druid.query.QueryPlus;
import org.apache.druid.query.QueryResourceId;
import org.apache.druid.query.QueryRunner;
import org.apache.druid.query.QueryToolChest;
import org.apache.druid.query.SubqueryQueryRunner;
import org.apache.druid.query.*;
import org.apache.druid.query.aggregation.AggregatorFactory;
import org.apache.druid.query.aggregation.MetricManipulationFn;
import org.apache.druid.query.aggregation.MetricManipulatorFns;
Expand Down Expand Up @@ -271,6 +261,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 cf38617

Please sign in to comment.