spark-test commented on code in PR #60553:
URL: https://github.com/apache/spark/pull/60553#discussion_r4613404269


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/PushDownShuffleExchangeThroughUnionSuite.scala:
##########
@@ -201,6 +213,38 @@ class PushDownShuffleExchangeThroughUnionSuite extends 
QueryTest with SharedSpar
       spark.sql(sql).collect().toSeq
     }
 
+  test("SPARK-61785: a query on the defaults keeps its shuffle") {
+    // The suite opens every opt-in for the rest of its tests. Here each goes 
back to its declared
+    // default, with only AQE turned on, so flipping a default changes this 
plan and the answer.

Review Comment:
   Thanks, the test now puts the rule's flag back to its declared default and 
fails if that default flips. This review raises one small follow-up: the 
comment that explains the new query names the wrong union leg for the 
repartition hint.
   
   <!-- SPARK_DEV_REVIEW_REPLY 
{"feedback_id":"inline:4600231289","thread_id":"inline:4600231289","verdict_sha256":"e3e3ff7df2f6968227b8f3c34d068950a3def78393e36f5d5bf39b2c6e00bdeb"}
 -->



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala:
##########
@@ -9001,26 +9001,39 @@ object SQLConf {
   val PUSH_DOWN_SHUFFLE_THROUGH_UNION_ENABLED =
     buildConf("spark.sql.adaptive.pushDownShuffleThroughUnion.enabled")
       .internal()
-      .doc("When true, pushes an EnsureRequirements hash shuffle below a union 
during AQE " +
-        "query stage preparation. Eligible children already reporting the 
selected layout " +
-        "are retained; other children are retargeted or receive a new 
exchange. The target " +
-        "partition count must be at least the smaller of the replaced 
exchange's count and " +
-        "the effective initial shuffle count, including " +
-        s"${COALESCE_PARTITIONS_INITIAL_PARTITION_NUM.key} when set, and at 
most a bounded " +
-        "multiple of the larger of the two. Requires " +
-        s"${UNION_OUTPUT_PARTITIONING.key} to be enabled. Removing the union's 
direct shuffle " +
-        "stage can reduce AQE skew handling and join conversion opportunities. 
Retaining a " +
-        "shuffled join's layout can make skew optimization or local reads 
violate ancestor " +
-        "requirements; AQE may reject the optimization or add a shuffle when 
skew optimization " +
-        "is forced. Join inputs and join branches are opt-in. Cost 
compensation applies only " +
-        "to SimpleCostEvaluator. Custom evaluators should account for one 
union exchange " +
-        "becoming multiple branch exchanges; otherwise AQE may reject a 
re-plan and its other " +
-        "runtime optimizations due to the increased exchange count.")
+      .doc("When true, pushes an EnsureRequirements shuffle below a union 
during AQE query " +
+        "stage preparation. The shuffle and the target are hash or V2 keyed 
layouts. Children " +

Review Comment:
   Thanks, the eligibility qualifier is back. This review raises one more case 
on the same sentence: for a V2 keyed target the rule also keeps some children 
that do not report the target, which the sentence's 'every other child' rules 
out.
   
   <!-- SPARK_DEV_REVIEW_REPLY 
{"feedback_id":"inline:4600231301","thread_id":"inline:4600231301","verdict_sha256":"e3e3ff7df2f6968227b8f3c34d068950a3def78393e36f5d5bf39b2c6e00bdeb"}
 -->



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/PushDownShuffleExchangeThroughUnion.scala:
##########
@@ -240,56 +322,77 @@ case class PushDownShuffleExchangeThroughUnion(
       maxUnionChildren: Int,
       maxTargetPartitionNumFactor: Double,
       keepJoinBranches: Boolean,
+      allowV2Bucketing: Boolean,
       allowSubsetTargets: Boolean,
       preferRemovedLayout: Boolean = false)
 
-  /** Lazily discover and rank layouts once per site for both joint and 
fallback attempts. */
-  private class PreparedChild(val pushable: PushableChild, policy: 
LayoutPolicy) {
+  /** Lazily discover the reported layouts and rank the targets once per site 
for both attempts. */
+  private class PreparedChild(
+      val pushable: PushableChild,
+      required: ClusteredDistribution,
+      policy: LayoutPolicy) {
     /**
-     * Eligible child layouts in child order, expressed in the union's output 
attributes.
-     * Collections offer their hash members; a child offering nothing takes a 
shuffle.
-     * Equality follows UnionExec's comparison after prepareOutputPartitioning 
rebinding.
+     * The hash or keyed layouts each child reports, in child order, expressed 
in the union's output
+     * attributes. A collection offers its hash members; a keyed layout offers 
itself when it is
+     * grouped and its grouped form when it is not, the form 
`EnsureRequirements` plans. A child
+     * offering nothing takes a shuffle.
+     *
+     * A marked leg is offered only when the union can merge it: it has to 
declare the target's

Review Comment:
   Thanks, the layouts doc now points to reportsDomain for the marked-leg rule, 
and reportsDomain's reason holds for every target. This review raises a small 
follow-up on the new layouts sentence: not every layout it offers can become 
the target.
   
   <!-- SPARK_DEV_REVIEW_REPLY 
{"feedback_id":"inline:4600231310","thread_id":"inline:4600231310","verdict_sha256":"e3e3ff7df2f6968227b8f3c34d068950a3def78393e36f5d5bf39b2c6e00bdeb"}
 -->



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