You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by AsterixDB Code Review <do...@asterix-gerrit.ics.uci.edu> on 2026/10/05 07:37:43 UTC

[L] Change in asterixdb[master]: [ASTERIXDB-3942][COMP] Do not re-split aggregates when sampling range...

From Janhavi Tripurwar <ja...@apache.org>:

Janhavi Tripurwar has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21991?usp=email )


Change subject: [ASTERIXDB-3942][COMP] Do not re-split aggregates when sampling ranges - user model changes: no - storage format changes: no - interface changes: yes
......................................................................

[ASTERIXDB-3942][COMP] Do not re-split aggregates when sampling ranges
- user model changes: no
- storage format changes: no
- interface changes: yes

Details:
The compile-time range map is computed by sampling a copy of the ORDER
input, which has already been through the logical rewrites and so has
its aggregate combiners. The SAMPLING rule set ran the combiner rules
again; they track applied operators by identity, so they split the
copied aggregates a second time. A local SQL sum then read the first
local step's system-null placeholders and failed, and the sort fell
back to a stable sort.

Sample through a new RANGE_MAP_SAMPLING rule set that leaves out the
combiner rules. SAMPLING keeps them: the statistics sampler builds a
plain aggregate and relies on them to split it.

Ext-ref: MB-69866
Generated-by: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Change-Id: Icc6666dd1a22af3c793006e87322d76e401b4486
---
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/DefaultRuleSetFactory.java
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/IRuleSetFactory.java
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/RangeMapUtil.java
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.1.ddl.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.2.update.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.3.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/results/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.3.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.plan
A asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.plan
M asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
12 files changed, 501 insertions(+), 9 deletions(-)



  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/91/21991/1

diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/DefaultRuleSetFactory.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/DefaultRuleSetFactory.java
index 008621c..52fdda4 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/DefaultRuleSetFactory.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/DefaultRuleSetFactory.java
@@ -46,7 +46,9 @@
     public List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> getLogicalRewrites(IRuleSetKind ruleSetKind,
             ICcApplicationContext appCtx) {
         if (ruleSetKind == RuleSetKind.SAMPLING) {
-            return buildLogicalSampling();
+            return buildLogicalSampling(true);
+        } else if (ruleSetKind == RuleSetKind.RANGE_MAP_SAMPLING) {
+            return buildLogicalSampling(false);
         } else if (ruleSetKind == RuleSetKind.QUERY) {
             return getLogicalRewrites(appCtx);
         } else if (ruleSetKind == RuleSetKind.LOGICAL_ADVISOR) {
@@ -67,7 +69,7 @@
             ICcApplicationContext appCtx) {
         if (ruleSetKind == RuleSetKind.QUERY) {
             return buildPhysical(appCtx, CostMethods::new);
-        } else if (ruleSetKind == RuleSetKind.SAMPLING) {
+        } else if (ruleSetKind == RuleSetKind.SAMPLING || ruleSetKind == RuleSetKind.RANGE_MAP_SAMPLING) {
             return buildPhysical(appCtx, CostMethods::new);
         } else {
             return Collections.emptyList();
@@ -107,10 +109,12 @@
         return defaultLogicalRewrites;
     }
 
-    public static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> buildLogicalSampling() {
+    public static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> buildLogicalSampling(
+            boolean introduceCombiners) {
         List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> logicalRewrites = new ArrayList<>();
         SequentialFixpointRuleController seqCtrlNoDfs = new SequentialFixpointRuleController(false);
-        logicalRewrites.add(Pair.of(seqCtrlNoDfs, RuleCollections.buildConsolidationRuleCollection()));
+        logicalRewrites
+                .add(Pair.of(seqCtrlNoDfs, RuleCollections.buildConsolidationRuleCollection(introduceCombiners)));
         logicalRewrites.add(Pair.of(seqCtrlNoDfs, RuleCollections.buildPlanCleanupRuleCollection()));
         return logicalRewrites;
     }
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/IRuleSetFactory.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/IRuleSetFactory.java
index c0df2d4..742437a 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/IRuleSetFactory.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/compiler/provider/IRuleSetFactory.java
@@ -31,7 +31,13 @@
     enum RuleSetKind implements IRuleSetKind {
         QUERY,
         LOGICAL_ADVISOR,
-        SAMPLING
+        SAMPLING,
+        /**
+         * Samples a copy of a subplan that has already been through the logical rewrites, to compute a range map
+         * at compile time. Unlike {@link #SAMPLING}, it does not introduce aggregate combiners: the subplan already
+         * has them, and splitting an aggregate twice feeds one local step's output into another.
+         */
+        RANGE_MAP_SAMPLING
     }
 
     /**
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
index d5b835b..1118384 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/base/RuleCollections.java
@@ -317,15 +317,21 @@
     }
 
     public static List<IAlgebraicRewriteRule> buildConsolidationRuleCollection() {
+        return buildConsolidationRuleCollection(true);
+    }
+
+    public static List<IAlgebraicRewriteRule> buildConsolidationRuleCollection(boolean introduceCombiners) {
         List<IAlgebraicRewriteRule> consolidation = new LinkedList<>();
         consolidation.add(new ConsolidateSelectsRule());
         consolidation.add(new ConsolidateAssignsRule(false));
         consolidation.add(new InlineAssignIntoAggregateRule());
         consolidation.add(new RewriteCountDistinctToHashRule());
         consolidation.add(new RewriteDistinctAggregateRule());
-        // The following rule should run after RewriteDistinctAggregateRule
-        consolidation.add(new AsterixIntroduceGroupByCombinerRule());
-        consolidation.add(new IntroduceAggregateCombinerRule());
+        if (introduceCombiners) {
+            // The following rule should run after RewriteDistinctAggregateRule
+            consolidation.add(new AsterixIntroduceGroupByCombinerRule());
+            consolidation.add(new IntroduceAggregateCombinerRule());
+        }
         // Re-infer all types after introducing aggregate combiners
         consolidation.add(new ReinferAllTypesRule());
         consolidation.add(new CountVarToCountOneRule());
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/RangeMapUtil.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/RangeMapUtil.java
index fc95cb7..446d29b 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/RangeMapUtil.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/RangeMapUtil.java
@@ -275,7 +275,8 @@
 
         List<List<IAObject>> val;
         try {
-            val = AnalysisUtil.runQuery(topRef, rangeMapResultVar, newCtx, IRuleSetFactory.RuleSetKind.SAMPLING);
+            val = AnalysisUtil.runQuery(topRef, rangeMapResultVar, newCtx,
+                    IRuleSetFactory.RuleSetKind.RANGE_MAP_SAMPLING);
             return org.apache.asterix.optimizer.rules.cbo.RangeMapUtil.deserializeRangeMap(val);
         } catch (Throwable t) {
             LOGGER.warn("Failed to compute static RangeMap, falling back to stable sort", t);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.1.ddl.sqlpp
new file mode 100644
index 0000000..95ed39a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.1.ddl.sqlpp
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : The compile-time range map for the top-level ORDER BY is computed by sampling
+ *                a subplan whose aggregates already have combiners. Sampling must not split them
+ *                again, or the range map cannot be computed and the sort is not parallel.
+ * Expected Res : SUCCESS
+ */
+drop  dataverse tpch if exists;
+create  dataverse tpch;
+
+use tpch;
+
+
+create type tpch.OrderType as
+ closed {
+  o_orderkey : bigint,
+  o_custkey : bigint,
+  o_orderstatus : string,
+  o_totalprice : double,
+  o_orderdate : string,
+  o_orderpriority : string,
+  o_clerk : string,
+  o_shippriority : bigint,
+  o_comment : string
+};
+
+create type tpch.CustomerType as
+ closed {
+  c_custkey : bigint,
+  c_name : string,
+  c_address : string,
+  c_nationkey : bigint,
+  c_phone : string,
+  c_acctbal : double,
+  c_mktsegment : string,
+  c_comment : string
+};
+
+create type tpch.SupplierType as
+ closed {
+  s_suppkey : bigint,
+  s_name : string,
+  s_address : string,
+  s_nationkey : bigint,
+  s_phone : string,
+  s_acctbal : double,
+  s_comment : string
+};
+
+create type tpch.NationType as
+ closed {
+  n_nationkey : bigint,
+  n_name : string,
+  n_regionkey : bigint,
+  n_comment : string
+};
+
+create type tpch.RegionType as
+ closed {
+  r_regionkey : bigint,
+  r_name : string,
+  r_comment : string
+};
+
+create  dataset Orders(OrderType) primary key o_orderkey;
+
+create  dataset Supplier(SupplierType) primary key s_suppkey;
+
+create  dataset Region(RegionType) primary key r_regionkey;
+
+create  dataset Nation(NationType) primary key n_nationkey;
+
+create  dataset Customer(CustomerType) primary key c_custkey;
+
+create  dataset SelectedNation(NationType) primary key n_nationkey;
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.2.update.sqlpp
new file mode 100644
index 0000000..3a64f84
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.2.update.sqlpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : The compile-time range map for the top-level ORDER BY is computed by sampling
+ *                a subplan whose aggregates already have combiners. Sampling must not split them
+ *                again, or the range map cannot be computed and the sort is not parallel.
+ * Expected Res : SUCCESS
+ */
+use tpch;
+
+
+load  dataset Orders using localfs ((`path`=`asterix_nc1://data/tpch0.001/orders.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+load  dataset Supplier using localfs ((`path`=`asterix_nc1://data/tpch0.001/supplier.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+load  dataset Region using localfs ((`path`=`asterix_nc1://data/tpch0.001/region.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+load  dataset Nation using localfs ((`path`=`asterix_nc1://data/tpch0.001/nation.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+load  dataset Customer using localfs ((`path`=`asterix_nc1://data/tpch0.001/customer.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
+load  dataset SelectedNation using localfs ((`path`=`asterix_nc1://data/tpch0.001/selectednation.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`));
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.3.query.sqlpp
new file mode 100644
index 0000000..fd55c17
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.3.query.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : The compile-time range map for the top-level ORDER BY is computed by sampling
+ *                a subplan whose aggregates already have combiners. Sampling must not split them
+ *                again, or the range map cannot be computed and the sort is not parallel.
+ * Expected Res : SUCCESS
+ */
+
+USE tpch;
+
+SELECT  nation.n_nationkey AS nation_key,
+        nation.n_name AS name,
+        (
+            SELECT ELEMENT orderdate
+            FROM  Orders AS orders,
+                  Customer AS customer
+            WHERE orders.o_custkey = customer.c_custkey AND customer.c_nationkey = nation.n_nationkey
+            GROUP BY orders.o_orderdate AS orderdate
+            ORDER BY sum(orders.o_totalprice)
+            LIMIT 3
+        ) AS aggregates
+FROM  Nation AS nation,
+      SelectedNation AS sn
+WHERE nation.n_nationkey /*+ indexnl */ = sn.n_nationkey
+ORDER BY nation.n_nationkey;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.query.sqlpp
new file mode 100644
index 0000000..25180d7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.query.sqlpp
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : The compile-time range map for the top-level ORDER BY is computed by sampling
+ *                a subplan whose aggregates already have combiners. Sampling must not split them
+ *                again, or the range map cannot be computed and the sort is not parallel.
+ * Expected Res : SUCCESS
+ */
+
+USE tpch;
+
+EXPLAIN
+SELECT  nation.n_nationkey AS nation_key,
+        nation.n_name AS name,
+        (
+            SELECT ELEMENT orderdate
+            FROM  Orders AS orders,
+                  Customer AS customer
+            WHERE orders.o_custkey = customer.c_custkey AND customer.c_nationkey = nation.n_nationkey
+            GROUP BY orders.o_orderdate AS orderdate
+            ORDER BY sum(orders.o_totalprice)
+            LIMIT 3
+        ) AS aggregates
+FROM  Nation AS nation,
+      SelectedNation AS sn
+WHERE nation.n_nationkey /*+ indexnl */ = sn.n_nationkey
+ORDER BY nation.n_nationkey;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.3.adm
new file mode 100644
index 0000000..3834939
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.3.adm
@@ -0,0 +1,11 @@
+{ "nation_key": 0, "name": "ALGERIA", "aggregates": [ "1994-05-27", "1994-05-08", "1993-08-27" ] }
+{ "nation_key": 1, "name": "ARGENTINA", "aggregates": [ "1997-08-14", "1997-11-26", "1998-04-20" ] }
+{ "nation_key": 2, "name": "BRAZIL", "aggregates": [ "1993-03-05", "1994-08-31", "1997-05-04" ] }
+{ "nation_key": 3, "name": "CANADA", "aggregates": [ "1992-02-22", "1992-11-28", "1995-02-17" ] }
+{ "nation_key": 4, "name": "EGYPT", "aggregates": [ "1998-04-19", "1996-03-12", "1997-07-25" ] }
+{ "nation_key": 19, "name": "ROMANIA", "aggregates": [ "1994-07-05", "1994-11-17", "1997-02-07" ] }
+{ "nation_key": 20, "name": "SAUDI ARABIA", "aggregates": [ "1994-04-30", "1992-05-10", "1994-01-31" ] }
+{ "nation_key": 21, "name": "VIETNAM", "aggregates": [ "1994-02-17", "1995-08-05", "1994-06-01" ] }
+{ "nation_key": 22, "name": "RUSSIA", "aggregates": [ "1993-11-16", "1996-01-11", "1995-07-15" ] }
+{ "nation_key": 23, "name": "UNITED KINGDOM", "aggregates": [ "1997-12-18", "1995-05-26", "1997-05-13" ] }
+{ "nation_key": 24, "name": "UNITED STATES", "aggregates": [  ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.plan
new file mode 100644
index 0000000..42bbac8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.plan
@@ -0,0 +1,119 @@
+distribute result [$$113] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    assign [$$113] <- [{"nation_key": $$132, "name": $$129, "aggregates": $$112}] project: [$$113] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+    -- ASSIGN  |PARTITIONED|
+      exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+      -- SORT_MERGE_EXCHANGE [$$132(ASC) ]  |PARTITIONED|
+        project ([$$132, $$129, $$112]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+        -- STREAM_PROJECT  |PARTITIONED|
+          exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            group by ([$$132 := $$135; $$133 := $$136]) decor ([$$129]) {
+                      aggregate [$$112] <- [listify($$orderdate)] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                      -- AGGREGATE  |LOCAL|
+                        limit 3 [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                        -- STREAM_LIMIT  |LOCAL|
+                          project ([$$orderdate]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                          -- STREAM_PROJECT  |LOCAL|
+                            order (ASC, $$123) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                            -- MICRO_STABLE_SORT [$$123(ASC)]  |LOCAL|
+                              group by ([$$orderdate := $$137]) decor ([]) {
+                                        aggregate [$$123] <- [agg-global-sql-sum($$134)] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                        -- AGGREGATE  |LOCAL|
+                                          nested tuple source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                          -- NESTED_TUPLE_SOURCE  |LOCAL|
+                                     } [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                              -- MICRO_PRE_CLUSTERED_GROUP_BY[$$137]  |LOCAL|
+                                order (ASC, $$137) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                -- MICRO_STABLE_SORT [$$137(ASC)]  |LOCAL|
+                                  select (not(is-missing($$138))) project: [$$134, $$137] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                  -- STREAM_SELECT  |LOCAL|
+                                    project ([$$134, $$137, $$138]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                    -- STREAM_PROJECT  |LOCAL|
+                                      nested tuple source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                   } [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+            -- PRE_CLUSTERED_GROUP_BY[$$135, $$136]  |PARTITIONED|
+              exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                order (ASC, $$135) (ASC, $$136) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                -- STABLE_SORT [$$135(ASC), $$136(ASC)]  |PARTITIONED|
+                  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                  -- HASH_PARTITION_EXCHANGE [$$135, $$136]  |PARTITIONED|
+                    group by ([$$135 := $$118; $$136 := $$119; $$137 := $$115; $$138 := $$131]) decor ([$$129]) {
+                              aggregate [$$134] <- [agg-local-sql-sum($$110)] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                              -- AGGREGATE  |LOCAL|
+                                nested tuple source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                -- NESTED_TUPLE_SOURCE  |LOCAL|
+                           } [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                    -- SORT_GROUP_BY[$$118, $$119, $$115, $$131]  |PARTITIONED|
+                      exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        project ([$$129, $$110, $$118, $$119, $$115, $$131]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                        -- STREAM_PROJECT  |PARTITIONED|
+                          exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            left outer join (eq($$124, $$118)) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                            -- HYBRID_HASH_JOIN [$$118][$$124]  |PARTITIONED|
+                              exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                              -- HASH_PARTITION_EXCHANGE [$$118]  |PARTITIONED|
+                                project ([$$129, $$118, $$119]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                -- STREAM_PROJECT  |PARTITIONED|
+                                  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                    unnest-map [$$119, $$sn] <- index-search("SelectedNation", 0, "Default", "tpch", "SelectedNation", true, true, 1, $$118, 1, $$118, true, true, true) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                    -- BTREE_SEARCH  |PARTITIONED|
+                                      exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                        order (ASC, $$118) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                        -- STABLE_SORT [$$118(ASC)]  |PARTITIONED|
+                                          exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                            assign [$$129] <- [$$nation.getField(1)] project: [$$129, $$118] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                            -- ASSIGN  |PARTITIONED|
+                                              exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                data-scan []<-[$$118, $$nation] <- tpch.Nation [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                -- DATASOURCE_SCAN  |PARTITIONED|
+                                                  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                    empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                              exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                              -- HASH_PARTITION_EXCHANGE [$$124]  |PARTITIONED|
+                                assign [$$131] <- [true] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                -- ASSIGN  |PARTITIONED|
+                                  project ([$$110, $$115, $$124]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      join (eq($$126, $$121)) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                      -- HYBRID_HASH_JOIN [$$126][$$121]  |PARTITIONED|
+                                        exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                        -- HASH_PARTITION_EXCHANGE [$$126]  |PARTITIONED|
+                                          assign [$$115, $$126, $$110] <- [$$orders.getField(4), $$orders.getField(1), $$orders.getField(3)] project: [$$110, $$115, $$126] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                          -- ASSIGN  |PARTITIONED|
+                                            project ([$$orders]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                            -- STREAM_PROJECT  |PARTITIONED|
+                                              exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                data-scan []<-[$$120, $$orders] <- tpch.Orders [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                -- DATASOURCE_SCAN  |PARTITIONED|
+                                                  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                    empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                        exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                          assign [$$124] <- [$$customer.getField(3)] project: [$$124, $$121] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                          -- ASSIGN  |PARTITIONED|
+                                            exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              data-scan []<-[$$121, $$customer] <- tpch.Customer [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                  empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.plan
new file mode 100644
index 0000000..36a832b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/tpch-sql-sugar/nest_aggregate_parallel_sort/nest_aggregate_parallel_sort.4.plan
@@ -0,0 +1,123 @@
+distribute result [$$113] [cardinality: 634.2, doc-size: 18.08, op-cost: 0.0, total-cost: 66006.1]
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  exchange [cardinality: 634.2, doc-size: 18.08, op-cost: 0.0, total-cost: 66006.1]
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    assign [$$113] <- [{"nation_key": $$132, "name": $$129, "aggregates": $$112}] project: [$$113] [cardinality: 634.2, doc-size: 18.08, op-cost: 0.0, total-cost: 66006.1]
+    -- ASSIGN  |PARTITIONED|
+      exchange [cardinality: 634.2, doc-size: 18.08, op-cost: 0.0, total-cost: 66006.1]
+      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+        order (ASC, $$132) [cardinality: 634.2, doc-size: 18.08, op-cost: 1475.91, total-cost: 66006.1]
+        -- STABLE_SORT [$$132(ASC)]  |PARTITIONED|
+          exchange [cardinality: 634.2, doc-size: 18.08, op-cost: 0.0, total-cost: 64530.19]
+          -- RANGE_PARTITION_EXCHANGE [$$132(ASC)] RANGE_MAP:{SPLIT:3}  |PARTITIONED|
+            project ([$$132, $$129, $$112]) [cardinality: 634.2, doc-size: 18.08, op-cost: 0.0, total-cost: 64530.19]
+            -- STREAM_PROJECT  |PARTITIONED|
+              exchange [cardinality: 634.2, doc-size: 18.08, op-cost: 0.0, total-cost: 64530.19]
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                group by ([$$132 := $$135; $$133 := $$136]) decor ([$$129]) {
+                          aggregate [$$112] <- [listify($$orderdate)] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                          -- AGGREGATE  |LOCAL|
+                            limit 3 [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                            -- STREAM_LIMIT  |LOCAL|
+                              project ([$$orderdate]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                              -- STREAM_PROJECT  |LOCAL|
+                                order (ASC, $$123) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                -- MICRO_STABLE_SORT [$$123(ASC)]  |LOCAL|
+                                  group by ([$$orderdate := $$137]) decor ([]) {
+                                            aggregate [$$123] <- [agg-global-sql-sum($$134)] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                            -- AGGREGATE  |LOCAL|
+                                              nested tuple source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                              -- NESTED_TUPLE_SOURCE  |LOCAL|
+                                         } [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                  -- MICRO_PRE_CLUSTERED_GROUP_BY[$$137]  |LOCAL|
+                                    order (ASC, $$137) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                    -- MICRO_STABLE_SORT [$$137(ASC)]  |LOCAL|
+                                      select (not(is-missing($$138))) project: [$$134, $$137] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                      -- STREAM_SELECT  |LOCAL|
+                                        project ([$$134, $$137, $$138]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                        -- STREAM_PROJECT  |LOCAL|
+                                          nested tuple source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                          -- NESTED_TUPLE_SOURCE  |LOCAL|
+                       } [cardinality: 634.2, doc-size: 18.08, op-cost: 31859.15, total-cost: 64530.19]
+                -- PRE_CLUSTERED_GROUP_BY[$$135, $$136]  |PARTITIONED|
+                  exchange [cardinality: 634.2, doc-size: 18.08, op-cost: 0.0, total-cost: 32671.04]
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    order (ASC, $$135) (ASC, $$136) [cardinality: 634.2, doc-size: 18.08, op-cost: 31859.15, total-cost: 32671.04]
+                    -- STABLE_SORT [$$135(ASC), $$136(ASC)]  |PARTITIONED|
+                      exchange [cardinality: 634.2, doc-size: 18.08, op-cost: 0.0, total-cost: 811.89]
+                      -- HASH_PARTITION_EXCHANGE [$$135, $$136]  |PARTITIONED|
+                        group by ([$$135 := $$118; $$136 := $$119; $$137 := $$115; $$138 := $$131]) decor ([$$129]) {
+                                  aggregate [$$134] <- [local-sql-sum-serial($$110)] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                  -- AGGREGATE  |LOCAL|
+                                    nested tuple source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+                               } [cardinality: 634.2, doc-size: 18.08, op-cost: 799.36, total-cost: 811.89]
+                        -- EXTERNAL_GROUP_BY[$$118, $$119, $$115, $$131]  |PARTITIONED|
+                          exchange [cardinality: 25.0, doc-size: 18.08, op-cost: 0.0, total-cost: 12.53]
+                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                            project ([$$129, $$110, $$118, $$119, $$115, $$131]) [cardinality: 25.0, doc-size: 18.08, op-cost: 0.0, total-cost: 12.53]
+                            -- STREAM_PROJECT  |PARTITIONED|
+                              exchange [cardinality: 25.0, doc-size: 18.08, op-cost: 0.0, total-cost: 12.53]
+                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                left outer join (eq($$124, $$118)) [cardinality: 660.62, doc-size: 54.08, op-cost: 543.26, total-cost: 3070.23]
+                                -- HYBRID_HASH_JOIN [$$118][$$124]  |PARTITIONED|
+                                  exchange [cardinality: 25.0, doc-size: 18.08, op-cost: 0.0, total-cost: 12.53]
+                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                    assign [$$129] <- [$$nation.getField(1)] project: [$$119, $$118, $$129] [cardinality: 25.0, doc-size: 18.08, op-cost: 0.0, total-cost: 12.53]
+                                    -- ASSIGN  |PARTITIONED|
+                                      exchange [cardinality: 25.0, doc-size: 18.08, op-cost: 0.0, total-cost: 12.53]
+                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                        unnest-map [$$118, $$nation] <- index-search("Nation", 0, "Default", "tpch", "Nation", true, true, 1, $$119, 1, $$119, true, true, true) [cardinality: 25.0, doc-size: 18.08, op-cost: 0.0, total-cost: 12.53]
+                                        -- BTREE_SEARCH  |PARTITIONED|
+                                          exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                            order (ASC, $$119) [cardinality: 25.0, doc-size: 18.08, op-cost: 12.53, total-cost: 12.53]
+                                            -- STABLE_SORT [$$119(ASC)]  |PARTITIONED|
+                                              exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                project ([$$119]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                -- STREAM_PROJECT  |PARTITIONED|
+                                                  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                    data-scan []<-[$$119, $$sn] <- tpch.SelectedNation [cardinality: 11.0, doc-size: 9.0, op-cost: 5.51, total-cost: 5.51]
+                                                    -- DATASOURCE_SCAN  |PARTITIONED|
+                                                      exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                        empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                  -- HASH_PARTITION_EXCHANGE [$$124]  |PARTITIONED|
+                                    assign [$$131] <- [true] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                    -- ASSIGN  |PARTITIONED|
+                                      project ([$$110, $$115, $$124]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                      -- STREAM_PROJECT  |PARTITIONED|
+                                        exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                          join (eq($$126, $$121)) [cardinality: 1501.41, doc-size: 27.0, op-cost: 900.71, total-cost: 1878.39]
+                                          -- HYBRID_HASH_JOIN [$$126][$$121]  |PARTITIONED|
+                                            exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              assign [$$115, $$126, $$110] <- [$$orders.getField(4), $$orders.getField(1), $$orders.getField(3)] project: [$$110, $$115, $$126] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                              -- ASSIGN  |PARTITIONED|
+                                                project ([$$orders]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                -- STREAM_PROJECT  |PARTITIONED|
+                                                  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                    data-scan []<-[$$120, $$orders] <- tpch.Orders [cardinality: 1500.0, doc-size: 9.0, op-cost: 752.42, total-cost: 752.42]
+                                                    -- DATASOURCE_SCAN  |PARTITIONED|
+                                                      exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                        empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                            exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                            -- BROADCAST_EXCHANGE  |PARTITIONED|
+                                              assign [$$124] <- [$$customer.getField(3)] project: [$$124, $$121] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                              -- ASSIGN  |PARTITIONED|
+                                                exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                  data-scan []<-[$$121, $$customer] <- tpch.Customer [cardinality: 150.0, doc-size: 18.0, op-cost: 75.26, total-cost: 75.26]
+                                                  -- DATASOURCE_SCAN  |PARTITIONED|
+                                                    exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                      empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                                                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
index b86e50d..ed85582 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
@@ -12960,6 +12960,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="tpch-sql-sugar">
+      <compilation-unit name="nest_aggregate_parallel_sort">
+        <output-dir compare="Text">nest_aggregate_parallel_sort</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="tpch-sql-sugar">
       <compilation-unit name="query-issue638">
         <output-dir compare="Text">query-issue638</output-dir>
       </compilation-unit>

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21991?usp=email
To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: Icc6666dd1a22af3c793006e87322d76e401b4486
Gerrit-Change-Number: 21991
Gerrit-PatchSet: 1
Gerrit-Owner: Janhavi Tripurwar <ja...@apache.org>