github-actions[bot] commented on code in PR #62628:
URL: https://github.com/apache/doris/pull/62628#discussion_r3123281661


##########
regression-test/suites/nereids_p0/hash_shuffle_key_prune/distinct_mixed.groovy:
##########
@@ -0,0 +1,154 @@
+// 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.
+
+suite("distinct_mixed", "agg_shuffle_prune_func") {
+    sql """set enable_nereids_planner=true;"""
+    sql """set enable_fallback_to_original_planner=false;"""
+    sql """set enable_sql_cache=false;"""
+    sql """set enable_query_cache=false;"""
+    sql """set agg_phase=0;"""
+
+    def dbName = context.config.getDbNameByFile(context.file)
+    sql "create database if not exists ${dbName};"
+    sql "use ${dbName};"
+
+    def tptn = 8
+    sql "set parallel_fragment_exec_instance_num=1;"
+    sql "set parallel_pipeline_task_num=${tptn};"
+    sql "set be_number_for_test=1;"
+
+    def rowCount = "480000"
+    def highNdv = (tptn * 512 + tptn * 64).toString()
+    def lowNdv = "4"
+    def esc = { Object v -> v == null ? "null" : v.toString().replace("\\", 
"\\\\").replace("'", "\\'") }
+    def norm = { rows -> rows.collect { r -> r.collect { v -> v == null ? 
"NULL" : v.toString() }.join("||") }.sort() }
+    def explainText = { String q -> (sql "explain physical plan " + q).collect 
{ it[0].toString() }.join("\n") }
+    def shuffleSigns = { String e ->
+        def signs = []
+        def matcher = (e =~ /orderedShuffledColumns=\[([0-9,\s-]*)\]/)
+        while (matcher.find()) {
+            signs << "[" + matcher.group(1).replaceAll("\\s+", "") + "]"
+        }
+        signs
+    }
+    def setStats = { String t, String c, String n, String nn, String ds, 
String mi, String ma, String hv ->
+        def hotValues = hv == null ? "" : ", 'hot_values'='${esc(hv)}'"
+        sql """alter table ${t} modify column ${c} set stats (
+                'row_count'='${rowCount}',
+                'ndv'='${esc(n)}',
+                'num_nulls'='${esc(nn)}',
+                'data_size'='${esc(ds)}',
+                'min_value'='${esc(mi)}',
+                'max_value'='${esc(ma)}'${hotValues});"""
+    }
+    def checkPlanChange = { String id, String q, boolean expectChange ->
+        sql "set enable_shuffle_key_prune=false;"
+        def explainOff = explainText(q)
+        sql "set enable_shuffle_key_prune=true;"
+        def explainOn = explainText(q)
+        if (expectChange) {

Review Comment:
   For the positive cases this helper only checks that some 
`orderedShuffledColumns` text changed. If the DISTINCT/global exchange were 
pruned to the wrong key/subset, or another exchange changed for an unrelated 
reason, the suite would still pass. Since this file is meant to be a focused 
property test, can we resolve the DISTINCT/global agg-child distribute (like 
`window_distinct_regression.groovy` does) and assert the selected shuffle 
key(s) explicitly?



##########
regression-test/suites/nereids_p0/hash_shuffle_key_prune/degrade_fallback.groovy:
##########
@@ -0,0 +1,252 @@
+// 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.
+
+// 
===========================================================================================
+// Category 04: Fallback and Conservative Logic — R01-R02, SK01, N01-N02, 
E01-E02
+// 
===========================================================================================
+//
+// Purpose
+//   Validate fallback (no optimization) behavior of Shuffle Key Pruning in 
special scenarios:
+//   1. ROLLUP/GROUPING SETS -> the Repeat operator produces multiple group-by 
key sets -> no pruning
+//   2. All candidate columns are skewed -> no safe column can be chosen -> no 
pruning
+//   3. Missing/partial statistics -> conservative fallback -> no pruning
+//   4. String fallback: when step 1 cannot pick a single key, step 2 removes 
string-typed columns
+//
+// Case List
+//   R01: GROUP BY ROLLUP(b,c,d,e,f) -> Repeat operator -> no pruning 
(negative)
+//   R02: GROUP BY GROUPING SETS -> same behavior -> no pruning (negative)
+//   SK01: k1~k5 all have hot_values=0.8 -> all skewed -> no pruning (negative)
+//   N01: Some partitions of a partitioned table have no stats -> conservative 
-> no pruning (negative)
+//   N02: Only column b is analyzed -> other columns miss stats -> no pruning 
(negative)
+//   E01: All non-string columns are skewed / low-NDV -> step 2 removes 
strings and keeps a 3-column composite key (positive)
+//   E02: Only string columns remain -> no usable key after removing strings 
-> no pruning (negative)
+//
+// Validation
+//   Check whether the plan changes and verify result consistency.
+// 
===========================================================================================
+suite("degrade_fallback", "agg_shuffle_prune_func") {

Review Comment:
   This suite flips `set global enable_auto_analyze` later in `N01`/`N02`, so 
it should not stay in the normal concurrent pool. The `finally` restore only 
happens after the suite finishes; another suite can still observe 
`enable_auto_analyze=false` in the meantime. `regression-test/README.md` asks 
global-variable cases to be marked `nonConcurrent`.
   
   ```suggestion
   suite("degrade_fallback", "agg_shuffle_prune_func,nonConcurrent") {
   ```
   



##########
regression-test/suites/nereids_p0/hash_shuffle_key_prune/window_distinct_regression.groovy:
##########
@@ -0,0 +1,284 @@
+// 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.
+
+// 
===========================================================================================
+// Category 09: Window / Distinct Regression — WD01-WD04
+// 
===========================================================================================
+//
+// Purpose
+//   Add a more focused regression set for window / distinct patterns:
+//   - Window guard: ensure pruning is not triggered incorrectly under window 
wrappers
+//   - Distinct + Window: ensure DISTINCT aggregation keeps the correct prune 
/ no-prune behavior when wrapped by a window
+//
+// Case List
+//   WD01: window over inner agg, child distribution already satisfied -> no 
pruning (negative)
+//   WD02: count(distinct) + window, high NDV -> pruning works (positive)
+//   WD03: count(distinct) + avg + window, high NDV -> pruning still works 
(positive)
+//   WD04: count(distinct) + window, low NDV -> no pruning (negative)
+// 
===========================================================================================
+suite("window_distinct_regression", "agg_shuffle_prune_func") {
+    sql """set enable_nereids_planner=true;"""
+    sql """set enable_fallback_to_original_planner=false;"""
+    sql """set enable_sql_cache=false;"""
+    sql """set enable_query_cache=false;"""
+    sql """set agg_phase=0;"""
+    sql """set agg_shuffle_use_parent_key=false;"""
+    sql """set 
detail_shape_nodes='PhysicalHashAggregate,PhysicalDistribute,PhysicalWindow';"""
+
+    def dbName = context.config.getDbNameByFile(context.file)
+    sql "create database if not exists ${dbName};"
+    sql "use ${dbName};"
+
+    def tptn = 8
+    sql "set parallel_fragment_exec_instance_num=1;"
+    sql "set parallel_pipeline_task_num=${tptn};"
+    sql "set be_number_for_test=1;"
+
+    def highNdv = (tptn * 512 + tptn * 64).toString()
+    def lowNdv = "4"
+    def rowCount = "480000"
+    def esc = { Object v -> v == null ? "null" : v.toString().replace("\\", 
"\\\\").replace("'", "\\'") }
+    def ss = { String t, String c, String n, String nn, String ds, String mi, 
String ma, String hv ->
+        def hvc = hv == null ? "" : ", 'hot_values'='${esc(hv)}'"
+        sql "alter table ${t} modify column ${c} set stats 
('row_count'='${rowCount}','ndv'='${esc(n)}','num_nulls'='${esc(nn)}','data_size'='${esc(ds)}','min_value'='${esc(mi)}','max_value'='${esc(ma)}'${hvc});"
+    }
+    def extractSigns = { String e ->
+        def s = []
+        def m = (e =~ /orderedShuffledColumns=\[([0-9,\s-]*)\]/)
+        while (m.find()) {
+            s << "[" + m.group(1).replaceAll("\\s+", "") + "]"
+        }
+        s
+    }
+    def extractSingle = { String e ->
+        def ids = []
+        def m = (e =~ /orderedShuffledColumns=\[([0-9,\s-]*)\]/)
+        while (m.find()) {
+            def r = m.group(1).trim()
+            if (r.length() == 0) continue
+            def p = r.split(",").collect { it.trim() }.findAll { it.length() > 
0 }
+            if (p.size() == 1) ids << Integer.parseInt(p[0])
+        }
+        ids
+    }
+    def extractIdLists = { String e ->
+        def ids = []
+        def m = (e =~ /orderedShuffledColumns=\[([0-9,\s-]*)\]/)
+        while (m.find()) {
+            def r = m.group(1).trim()
+            ids << (r.length() == 0 ? [] : r.split(",").collect { it.trim() 
}.findAll { it.length() > 0 }.collect { Integer.parseInt(it) })
+        }
+        ids
+    }
+    def exprId = { String e, String c ->
+        def m = (e =~ ("\\b" + java.util.regex.Pattern.quote(c) + 
"#(\\d+)\\b"))
+        m.find() ? Integer.parseInt(m.group(1)) : null
+    }
+    def subtreeText = { List<String> lines, int rootIndex ->
+        int rootIndent = lines[rootIndex].indexOf("Physical")
+        def collected = []
+        for (int i = rootIndex; i < lines.size(); i++) {
+            def line = lines[i]
+            int indent = line.indexOf("Physical")
+            if (i > rootIndex && indent >= 0 && indent <= rootIndent) {
+                break
+            }
+            collected << line
+        }
+        collected.join("\n")
+    }
+    def parseOrderedIds = { String line ->
+        def m = (line =~ /orderedShuffledColumns=\[([0-9,\s-]*)\]/)
+        if (!m.find()) {
+            return null
+        }
+        def r = m.group(1).trim()
+        return (r.length() == 0 ? [] : r.split(",").collect { it.trim() 
}.findAll { it.length() > 0 }.collect { Integer.parseInt(it) })
+    }
+    def findDistinctAggChildDistributes = { String e ->
+        def lines = e.readLines()
+        def ctxs = []
+        for (int i = 0; i < lines.size(); i++) {
+            def line = lines[i]
+            if (!(line.contains("PhysicalHashAggregate")
+                    && (line.contains("aggPhase=DISTINCT_GLOBAL") || 
line.contains("aggPhase=GLOBAL")))) {
+                continue
+            }
+            int aggIndent = line.indexOf("PhysicalHashAggregate")
+            for (int j = i + 1; j < lines.size(); j++) {
+                def childLine = lines[j]
+                int childIndent = childLine.indexOf("Physical")
+                if (childIndent < 0) {
+                    continue
+                }
+                if (childIndent <= aggIndent) {
+                    break
+                }
+                if (childLine.contains("PhysicalDistribute") && 
childLine.contains("orderedShuffledColumns=")) {
+                    ctxs << [ids: parseOrderedIds(childLine), subtree: 
subtreeText(lines, j)]
+                    break
+                }
+            }
+        }
+        ctxs
+    }
+    def findScopedExprId = { String e, String c ->
+        def m = (e =~ ("\\b" + java.util.regex.Pattern.quote(c) + 
"#(\\d+)\\b"))
+        m.find() ? Integer.parseInt(m.group(1)) : null
+    }
+    def assertDistinctShufflePrunedToSingle = { String id, String eOff, String 
eOn, String c ->
+        def offCtxs = findDistinctAggChildDistributes(eOff)
+        def onCtxs = findDistinctAggChildDistributes(eOn)
+        assertTrue(!offCtxs.isEmpty() && !onCtxs.isEmpty(), "${id}: missing 
DISTINCT/global agg-child distribute ids, off=${offCtxs}, on=${onCtxs}")
+        assertTrue(offCtxs.size() == onCtxs.size(), "${id}: expected matching 
DISTINCT/global agg-child distribute counts, off=${offCtxs}, on=${onCtxs}")
+        def target = findScopedExprId(onCtxs[0].subtree, c)
+        assertTrue(target != null, "${id}: missing exprId for ${c}")
+        assertTrue(offCtxs.any { it.ids.size() > 1 && it.ids.contains(target) 
},
+            "${id}: expected at least one multi-key DISTINCT/global agg-child 
shuffle containing ${c}/${target} before pruning, got off=${offCtxs}")
+        assertTrue(onCtxs.every { it.ids.size() == 1 && it.ids[0] == target },
+            "${id}: expected all DISTINCT/global agg-child shuffles to prune 
to [${c}]/${target}, got on=${onCtxs}")
+    }
+    def norm = { rows ->
+        rows.collect { r -> r.collect { v -> v == null ? "NULL" : v.toString() 
}.join("||") }.sort()
+    }
+    def explainText = { String q -> (sql "explain physical plan " + q).collect 
{ it[0].toString() }.join("\n") }
+    def runCase = { String id, String q, boolean expectChange, int ap, String 
selectedCol ->
+        sql "set agg_phase=${ap};"
+        sql "set enable_shuffle_key_prune=false;"
+        def eOff = explainText(q)
+        def oS = extractSigns(eOff)
+        sql "set enable_shuffle_key_prune=true;"
+        def eOn = explainText(q)
+        def nS = extractSigns(eOn)
+        def changed = (eOff != eOn)

Review Comment:
   For `WD01`/`WD04` this uses whole-plan text equality rather than the 
extracted DISTINCT/global agg-child distribute info. That is much more brittle 
than the actual contract being tested: harmless explain churn (expr-id 
renumbering, formatting/detail-node changes, etc.) can make `eOff != eOn` even 
when shuffle-key-prune behavior is unchanged. Since this file already has 
`findDistinctAggChildDistributes`, can the negative cases compare those 
IDs/signs instead?



##########
regression-test/suites/nereids_p0/hash_shuffle_key_prune/join_key_prune.groovy:
##########
@@ -0,0 +1,281 @@
+// 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.
+
+// 
===========================================================================================
+// Category 07: Pure Join Shuffle Key Optimization — JK01-JK08
+// 
===========================================================================================
+//
+// Purpose
+//   Validate pure Join shuffle-key optimization outside Agg scenarios.
+//   When two tables use Shuffle Hash Join and the join key contains multiple 
columns,
+//   pruning can reduce the number of columns participating in hash 
computation and lower shuffle cost.
+//
+// Note
+//   Join shuffle-key pruning is cost-based, but we keep the environment 
deterministic with fixed statistics
+//   and be_number_for_test=1, then use hard assertions for validation.
+//
+// Case List
+//   JK01: All join keys on both sides have high NDV + no skew -> can be 
pruned (positive)
+//   JK02: All join keys are skewed, but step 2 still removes the string key 
when numeric combined NDV is high -> pruning works (positive)
+//   JK03: Numeric columns are skewed while varchar is balanced -> single-key 
selection can still prune on varchar (positive)
+//   JK04: Left table lacks statistics -> conservative -> no pruning (negative)
+//   JK05: Left table has hot_values=null -> not sampled -> conservative -> no 
pruning (negative)
+//   JK06: Verify the switch works -> OFF keeps the full join shuffle key, ON 
can prune
+//   JK07: join [shuffle[skew(...)] ] hint -> explicit skew guard -> no 
pruning (negative)
+//   JK08: All keys are skewed and numeric combined NDV is too low for step 2 
-> no pruning (negative)
+//
+// Validation
+//   Fix join reorder and turn off runtime filters to keep the plan stable.
+//   Compare OFF/ON plan changes and result consistency.
+// 
===========================================================================================
+suite("join_key_prune", "agg_shuffle_prune_func") {
+    sql """set enable_nereids_planner=true;"""
+    sql """set enable_fallback_to_original_planner=false;"""
+    sql """set enable_sql_cache=false;"""
+    sql """set enable_query_cache=false;"""
+    sql """set agg_phase=0;"""
+
+    def dbName = context.config.getDbNameByFile(context.file)
+    sql "create database if not exists ${dbName};"
+    sql "use ${dbName};"
+
+    def tptn = 8
+    sql "set parallel_fragment_exec_instance_num=1;"
+    sql "set parallel_pipeline_task_num=${tptn};"
+    sql "set be_number_for_test=1;"
+
+    def qn = (tptn*512 + tptn*64).toString()
+    def R = "480000"
+    def esc = { Object v -> 
v==null?"null":v.toString().replace("\\","\\\\").replace("'","\\'") }
+    def ss = { String t,String c,String n,String nn,String ds,String mi,String 
ma,String hv ->
+        def hvc = hv==null ? "" : ", 'hot_values'='${esc(hv)}'"
+        sql "alter table ${t} modify column ${c} set stats 
('row_count'='${R}','ndv'='${esc(n)}','num_nulls'='${esc(nn)}','data_size'='${esc(ds)}','min_value'='${esc(mi)}','max_value'='${esc(ma)}'${hvc});"
+    }
+    def extractSigns = { String e ->
+        def s=[]; def m=(e=~/orderedShuffledColumns=\[([0-9,\s-]*)\]/); 
while(m.find()){s<<"["+m.group(1).replaceAll("\\s+","")+"]"}; s
+    }
+    def extractKeyCounts = { String e ->
+        def c=[]; def m=(e=~/orderedShuffledColumns=\[([0-9,\s-]*)\]/)
+        while(m.find()){
+            def r=m.group(1).trim()
+            def p=r.length()==0 ? [] : 
r.split(",").collect{it.trim()}.findAll{it.length()>0}
+            c<<p.size()
+        }
+        c
+    }
+    def parseOrderedIds = { String line ->
+        def m = (line =~ /orderedShuffledColumns=\[([0-9,\s-]*)\]/)
+        if (!m.find()) {
+            return null
+        }
+        def r = m.group(1).trim()
+        return (r.length()==0 ? [] : 
r.split(",").collect{it.trim()}.findAll{it.length()>0}.collect{Integer.parseInt(it)})
+    }
+    def subtreeText = { List<String> lines, int rootIndex, int stopIndent ->
+        int rootIndent = lines[rootIndex].indexOf("Physical")
+        def collected = []
+        for (int i = rootIndex; i < lines.size(); i++) {
+            def line = lines[i]
+            int indent = line.indexOf("Physical")
+            if (i > rootIndex && indent >= 0 && indent <= stopIndent) {
+                break
+            }
+            collected << line
+        }
+        collected.join("\n")
+    }
+    def findScopedExprId = { String e,String c ->
+        def m=(e=~("\\b"+java.util.regex.Pattern.quote(c)+"#(\\d+)\\b"))
+        m.find()?Integer.parseInt(m.group(1)):null
+    }
+    def findFirstJoinChildShuffleCtxs = { String e ->
+        def lines = e.readLines()
+        int joinIndex = -1
+        for (int i = 0; i < lines.size(); i++) {
+            if (lines[i].contains("PhysicalHashJoin")) {
+                joinIndex = i
+                break
+            }
+        }
+        if (joinIndex < 0) {
+            return null
+        }
+        int joinIndent = lines[joinIndex].indexOf("PhysicalHashJoin")
+        def childRootIndices = []
+        Integer childRootIndent = null
+        for (int i = joinIndex + 1; i < lines.size(); i++) {
+            def line = lines[i]
+            int indent = line.indexOf("Physical")
+            if (indent < 0) {
+                continue
+            }
+            if (indent <= joinIndent) {
+                break
+            }
+            if (childRootIndent == null) {
+                childRootIndent = indent
+            }
+            if (indent == childRootIndent) {
+                childRootIndices << i
+            }
+        }
+        assertTrue(childRootIndices.size() >= 2, "missing join child roots in 
plan:\n${e}")
+        def childCtxs = childRootIndices.take(2).collect { idx ->
+            def childText = subtreeText(lines, idx, joinIndent)
+            def childLines = childText.readLines()
+            def distLine = childLines.find { it.contains("PhysicalDistribute") 
&& it.contains("orderedShuffledColumns=") }
+            assertTrue(distLine != null, "missing distribute under join 
child:\n${childText}")
+            [ids: parseOrderedIds(distLine), subtree: childText]
+        }
+        [left: childCtxs[0], right: childCtxs[1]]
+    }
+    def assertJoinChildCols = { String id, Map ctx, List<String> cols, String 
side ->
+        def expectedIds = cols.collect { c ->
+            def eid = findScopedExprId(ctx.subtree, c)
+            assertTrue(eid != null, "${id}: missing exprId for ${side}.${c}")
+            eid
+        }
+        assertTrue(ctx.ids.size() == expectedIds.size() && ctx.ids == 
expectedIds,
+            "${id}: expected ${side} shuffle cols ${cols}/${expectedIds}, got 
${ctx.ids}")
+    }
+    def norm = { rows -> 
rows.collect{r->r.collect{v->v==null?"NULL":v.toString()}.join("||")}.sort() }
+    def explainText = { String q -> (sql "explain physical plan " + q).collect 
{ it[0].toString() }.join("\n") }
+
+    // Join shuffle-key prune test helper
+    def runJoin = { String id,String q,boolean expChg,List<String> 
offLeftCols,List<String> offRightCols,List<String> onLeftCols,List<String> 
onRightCols ->
+        sql "set enable_shuffle_key_prune=false;"
+        def eOff=explainText(q); def oS=extractSigns(eOff); def 
offCtx=findFirstJoinChildShuffleCtxs(eOff)
+        sql "set enable_shuffle_key_prune=true;"
+        def eOn=explainText(q); def nS=extractSigns(eOn); def 
onCtx=findFirstJoinChildShuffleCtxs(eOn)
+        def changed=(eOff!=eOn)
+        logger.info("${id}: oS=${oS}, nS=${nS}, offCtx=${offCtx}, 
onCtx=${onCtx}, changed=${changed}")
+        assertJoinChildCols(id + "-OFF", offCtx.left, offLeftCols, "left")
+        assertJoinChildCols(id + "-OFF", offCtx.right, offRightCols, "right")
+        assertJoinChildCols(id + "-ON", onCtx.left, onLeftCols, "left")
+        assertJoinChildCols(id + "-ON", onCtx.right, onRightCols, "right")
+        if(expChg){assertTrue(changed,"${id}: signs should change")}
+        else{assertTrue(oS.toString()==nS.toString(),"${id}: should stay 
unchanged")}
+        sql "set enable_shuffle_key_prune=false;"; def rOff=sql q
+        sql "set enable_shuffle_key_prune=true;"; def rOn=sql q
+        assertTrue(norm(rOff)==norm(rOn),"${id}: results differ")
+    }
+    def runJoinSizesStable = { String id,String q ->
+        sql "set enable_shuffle_key_prune=false;"
+        def eOff=explainText(q); def offCtx=findFirstJoinChildShuffleCtxs(eOff)
+        sql "set enable_shuffle_key_prune=true;"
+        def eOn=explainText(q); def onCtx=findFirstJoinChildShuffleCtxs(eOn)
+        def offSizes = [offCtx.left.ids.size(), offCtx.right.ids.size()]
+        def onSizes = [onCtx.left.ids.size(), onCtx.right.ids.size()]
+        logger.info("${id}: offSizes=${offSizes}, onSizes=${onSizes}, 
offCtx=${offCtx}, onCtx=${onCtx}")
+        assertTrue(offSizes == onSizes, "${id}: shuffle-key sizes should stay 
unchanged, off=${offSizes}, on=${onSizes}")

Review Comment:
   This only compares shuffle-key arity. A buggy rewrite under the skew hint 
that keeps the same number of keys but changes the actual shuffled columns 
would still pass here, so `JK07` does not really prove that the hint blocked 
shuffle-key pruning. Can we assert the preserved key set more directly, even if 
we have to ignore the extra internal skew expr?



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