This is an automated email from the ASF dual-hosted git repository.

peter-toth pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.x by this push:
     new 31a1507bf878 [SPARK-61534][SQL] Estimate the statistics of an 
existence join from its left side
31a1507bf878 is described below

commit 31a1507bf8785e2a6c4f42b7f049fa844fa77576
Author: Peter Toth <[email protected]>
AuthorDate: Fri Nov 13 09:36:50 2026 +0100

    [SPARK-61534][SQL] Estimate the statistics of an existence join from its 
left side
    
    ### What changes were proposed in this pull request?
    
    `SizeInBytesOnlyStatsPlanVisitor` now estimates an existence join from its 
left side. Such a join outputs each row of the left side once, with a boolean 
column added. So its size is the left side's, scaled by the row widths as for a 
`Project`, and its row count and column stats are the left side's.
    
    With CBO, `JoinEstimation` does not support an existence join, and falls 
back to the same visitor. It does not estimate it as it does a left semi join, 
from the left side's row count and column stats: without `avgLen`, as for a 
materialized AQE stage, that size can be far below the left side's.
    
    Before, an existence join fell to `default`, which multiplies the sizes of 
the two sides.
    
    ### Why are the changes needed?
    
    `RewritePredicateSubquery` plans an existence join for an `EXISTS` or `IN` 
subquery that cannot become a semi or anti join, e.g. one under an `OR`, in a 
`SELECT` list, or in a join condition. With the product, the joins above see 
that side as far bigger than it is, and can miss a broadcast. In TPC-DS q10 at 
scale factor 100, the side with the two existence joins on `customer` is now 
broadcast to the join with `customer_demographics`, which was a sort-merge join 
before.
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes. A plan above an existence join can change, as in q10 above. The 
results do not.
    
    ### How was this patch tested?
    
    - New test in `BasicStatsEstimationSuite`: the estimate of an existence 
join, with CBO on and off, on a left side whose size is not its row count times 
its row width. It fails without the change, when the estimate takes the right 
side, and when CBO estimates the size from the column stats.
    - The `q10.sf100` approved plans of the TPC-DS plan stability suites, 
regenerated. No other approved plan changed.
    - `SubquerySuite`, `ExistenceJoinSuite`, `BroadcastJoinSuite`, 
`AdaptiveQueryExecSuite`, `StatisticsCollectionSuite`, `JoinSuite`, 
`InjectRuntimeFilterSuite` and the stats estimation suites pass.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code with Claude Opus 5.5
    
    Closes #60390 from peter-toth/SPARK-61534-existence-join-size-estimate.
    
    Authored-by: Peter Toth <[email protected]>
    Signed-off-by: Peter Toth <[email protected]>
    
    (cherry picked from commit 13be2edb7d5382f25ab8fb98db6e9c7ce68eed23)
    Signed-off-by: Peter Toth <[email protected]>
    
    
    skip-checks: true
---
 .../SizeInBytesOnlyStatsPlanVisitor.scala          |  12 +-
 .../BasicStatsEstimationSuite.scala                |  19 +-
 .../approved-plans-v1_4/q10.sf100/explain.txt      | 193 ++++++++++-----------
 .../approved-plans-v1_4/q10.sf100/simplified.txt   | 169 +++++++++---------
 4 files changed, 196 insertions(+), 197 deletions(-)

diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/SizeInBytesOnlyStatsPlanVisitor.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/SizeInBytesOnlyStatsPlanVisitor.scala
index 223d081b8d14..d8b94b6bba9a 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/SizeInBytesOnlyStatsPlanVisitor.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/SizeInBytesOnlyStatsPlanVisitor.scala
@@ -116,9 +116,15 @@ object SizeInBytesOnlyStatsPlanVisitor extends 
LogicalPlanVisitor[Statistics] {
 
   override def visitJoin(p: Join): Statistics = {
     p.joinType match {
-      case LeftAnti | LeftSemi =>
-        // LeftSemi and LeftAnti won't ever be bigger than left
-        p.left.stats
+      case LeftExistence(_) =>
+        // A left semi or anti join outputs each row of the left side at most 
once, so the left
+        // side's statistics bound it. An existence join outputs each row of 
the left side once,
+        // with a boolean column added, so they are exact for it, with the 
size scaled by the row
+        // widths. The scaling changes nothing for a left semi or anti join.
+        val leftStats = p.left.stats
+        val sizeInBytes = leftStats.sizeInBytes * 
EstimationUtils.getSizePerRow(p.output) /
+          EstimationUtils.getSizePerRow(p.left.output)
+        leftStats.copy(sizeInBytes = sizeInBytes)
       case Inner | LeftOuter | RightOuter | FullOuter =>
         p match {
           case ExtractEquiJoinKeys(_, leftKeys, rightKeys, _, _, left, right, 
_)
diff --git 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/BasicStatsEstimationSuite.scala
 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/BasicStatsEstimationSuite.scala
index 7d1e8b3082b1..8d73e487aa8c 100644
--- 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/BasicStatsEstimationSuite.scala
+++ 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/BasicStatsEstimationSuite.scala
@@ -23,7 +23,7 @@ import 
org.apache.spark.sql.catalyst.analysis.ResolvedNamespace
 import org.apache.spark.sql.catalyst.dsl.expressions._
 import org.apache.spark.sql.catalyst.dsl.plans._
 import org.apache.spark.sql.catalyst.expressions.{Ascending, Attribute, 
AttributeMap, AttributeReference, Literal, SortOrder}
-import org.apache.spark.sql.catalyst.plans.{Inner, PlanTest}
+import org.apache.spark.sql.catalyst.plans.{ExistenceJoin, Inner, PlanTest}
 import org.apache.spark.sql.catalyst.plans.logical._
 import org.apache.spark.sql.connector.catalog.SupportsNamespaces
 import org.apache.spark.sql.internal.SQLConf
@@ -385,6 +385,23 @@ test("range with invalid long value") {
       expectedStatsCboOff = Statistics(sizeInBytes = 4059900 * 2))
   }
 
+  test("SPARK-61534: an existence join is estimated from its left side") {
+    // It outputs each of the 10 rows of `left` once, with a boolean column 
added. The size of
+    // `left` is twice its row count times its row width, so a size computed 
from the row count
+    // and the column stats, as `JoinEstimation` computes it for a left semi 
join, would be half.
+    val left = plan.copy(size = Some(2 * 10 * (8 + 4)))
+    val otherKey = attr("other")
+    val other = StatsTestPlan(outputList = Seq(otherKey), rowCount = 1000,
+      attributeStats = AttributeMap(Seq(otherKey -> colStat)), size = 
Some(1000 * (8 + 4)))
+    val exists = AttributeReference("exists", BooleanType, nullable = false)()
+    val join = Join(left, other, ExistenceJoin(exists), Some(attribute === 
otherKey),
+      JoinHint.NONE)
+    checkStats(join, Statistics(
+      sizeInBytes = 2 * 10 * (8 + 4 + 1),
+      rowCount = Some(10),
+      attributeStats = AttributeMap(Seq(attribute -> colStat))))
+  }
+
   test("row size and column stats estimation for sort") {
     val columnInfo = AttributeMap(
       Seq(
diff --git 
a/sql/core/src/test/resources/tpcds-plan-stability/approved-plans-v1_4/q10.sf100/explain.txt
 
b/sql/core/src/test/resources/tpcds-plan-stability/approved-plans-v1_4/q10.sf100/explain.txt
index cc4a5c82a474..493846edf0ec 100644
--- 
a/sql/core/src/test/resources/tpcds-plan-stability/approved-plans-v1_4/q10.sf100/explain.txt
+++ 
b/sql/core/src/test/resources/tpcds-plan-stability/approved-plans-v1_4/q10.sf100/explain.txt
@@ -1,55 +1,52 @@
 == Physical Plan ==
-TakeOrderedAndProject (51)
-+- * HashAggregate (50)
-   +- Exchange (49)
-      +- * HashAggregate (48)
-         +- * Project (47)
-            +- * SortMergeJoin Inner (46)
-               :- * Sort (40)
-               :  +- Exchange (39)
-               :     +- * Project (38)
-               :        +- * BroadcastHashJoin Inner BuildRight (37)
-               :           :- * Project (31)
-               :           :  +- * Filter (30)
-               :           :     +- * SortMergeJoin ExistenceJoin(exists#1) 
(29)
-               :           :        :- * SortMergeJoin ExistenceJoin(exists#2) 
(21)
-               :           :        :  :- * SortMergeJoin LeftSemi (13)
-               :           :        :  :  :- * Sort (5)
-               :           :        :  :  :  +- Exchange (4)
-               :           :        :  :  :     +- * Filter (3)
-               :           :        :  :  :        +- * ColumnarToRow (2)
-               :           :        :  :  :           +- Scan parquet 
spark_catalog.default.customer (1)
-               :           :        :  :  +- * Sort (12)
-               :           :        :  :     +- Exchange (11)
-               :           :        :  :        +- * Project (10)
-               :           :        :  :           +- * BroadcastHashJoin 
Inner BuildRight (9)
-               :           :        :  :              :- * ColumnarToRow (7)
-               :           :        :  :              :  +- Scan parquet 
spark_catalog.default.store_sales (6)
-               :           :        :  :              +- ReusedExchange (8)
-               :           :        :  +- * Sort (20)
-               :           :        :     +- Exchange (19)
-               :           :        :        +- * Project (18)
-               :           :        :           +- * BroadcastHashJoin Inner 
BuildRight (17)
-               :           :        :              :- * ColumnarToRow (15)
-               :           :        :              :  +- Scan parquet 
spark_catalog.default.web_sales (14)
-               :           :        :              +- ReusedExchange (16)
-               :           :        +- * Sort (28)
-               :           :           +- Exchange (27)
-               :           :              +- * Project (26)
-               :           :                 +- * BroadcastHashJoin Inner 
BuildRight (25)
-               :           :                    :- * ColumnarToRow (23)
-               :           :                    :  +- Scan parquet 
spark_catalog.default.catalog_sales (22)
-               :           :                    +- ReusedExchange (24)
-               :           +- BroadcastExchange (36)
-               :              +- * Project (35)
-               :                 +- * Filter (34)
-               :                    +- * ColumnarToRow (33)
-               :                       +- Scan parquet 
spark_catalog.default.customer_address (32)
-               +- * Sort (45)
-                  +- Exchange (44)
-                     +- * Filter (43)
-                        +- * ColumnarToRow (42)
-                           +- Scan parquet 
spark_catalog.default.customer_demographics (41)
+TakeOrderedAndProject (48)
++- * HashAggregate (47)
+   +- Exchange (46)
+      +- * HashAggregate (45)
+         +- * Project (44)
+            +- * BroadcastHashJoin Inner BuildLeft (43)
+               :- BroadcastExchange (39)
+               :  +- * Project (38)
+               :     +- * BroadcastHashJoin Inner BuildRight (37)
+               :        :- * Project (31)
+               :        :  +- * Filter (30)
+               :        :     +- * SortMergeJoin ExistenceJoin(exists#1) (29)
+               :        :        :- * SortMergeJoin ExistenceJoin(exists#2) 
(21)
+               :        :        :  :- * SortMergeJoin LeftSemi (13)
+               :        :        :  :  :- * Sort (5)
+               :        :        :  :  :  +- Exchange (4)
+               :        :        :  :  :     +- * Filter (3)
+               :        :        :  :  :        +- * ColumnarToRow (2)
+               :        :        :  :  :           +- Scan parquet 
spark_catalog.default.customer (1)
+               :        :        :  :  +- * Sort (12)
+               :        :        :  :     +- Exchange (11)
+               :        :        :  :        +- * Project (10)
+               :        :        :  :           +- * BroadcastHashJoin Inner 
BuildRight (9)
+               :        :        :  :              :- * ColumnarToRow (7)
+               :        :        :  :              :  +- Scan parquet 
spark_catalog.default.store_sales (6)
+               :        :        :  :              +- ReusedExchange (8)
+               :        :        :  +- * Sort (20)
+               :        :        :     +- Exchange (19)
+               :        :        :        +- * Project (18)
+               :        :        :           +- * BroadcastHashJoin Inner 
BuildRight (17)
+               :        :        :              :- * ColumnarToRow (15)
+               :        :        :              :  +- Scan parquet 
spark_catalog.default.web_sales (14)
+               :        :        :              +- ReusedExchange (16)
+               :        :        +- * Sort (28)
+               :        :           +- Exchange (27)
+               :        :              +- * Project (26)
+               :        :                 +- * BroadcastHashJoin Inner 
BuildRight (25)
+               :        :                    :- * ColumnarToRow (23)
+               :        :                    :  +- Scan parquet 
spark_catalog.default.catalog_sales (22)
+               :        :                    +- ReusedExchange (24)
+               :        +- BroadcastExchange (36)
+               :           +- * Project (35)
+               :              +- * Filter (34)
+               :                 +- * ColumnarToRow (33)
+               :                    +- Scan parquet 
spark_catalog.default.customer_address (32)
+               +- * Filter (42)
+                  +- * ColumnarToRow (41)
+                     +- Scan parquet 
spark_catalog.default.customer_demographics (40)
 
 
 (1) Scan parquet spark_catalog.default.customer
@@ -84,7 +81,7 @@ ReadSchema: struct<ss_customer_sk:int>
 (7) ColumnarToRow [codegen id : 4]
 Input [2]: [ss_customer_sk#7, ss_sold_date_sk#8]
 
-(8) ReusedExchange [Reuses operator id: 63]
+(8) ReusedExchange [Reuses operator id: 60]
 Output [1]: [d_date_sk#10]
 
 (9) BroadcastHashJoin [codegen id : 4]
@@ -121,7 +118,7 @@ ReadSchema: struct<ws_bill_customer_sk:int>
 (15) ColumnarToRow [codegen id : 8]
 Input [2]: [ws_bill_customer_sk#11, ws_sold_date_sk#12]
 
-(16) ReusedExchange [Reuses operator id: 63]
+(16) ReusedExchange [Reuses operator id: 60]
 Output [1]: [d_date_sk#13]
 
 (17) BroadcastHashJoin [codegen id : 8]
@@ -158,7 +155,7 @@ ReadSchema: struct<cs_ship_customer_sk:int>
 (23) ColumnarToRow [codegen id : 12]
 Input [2]: [cs_ship_customer_sk#14, cs_sold_date_sk#15]
 
-(24) ReusedExchange [Reuses operator id: 63]
+(24) ReusedExchange [Reuses operator id: 60]
 Output [1]: [d_date_sk#16]
 
 (25) BroadcastHashJoin [codegen id : 12]
@@ -225,110 +222,98 @@ Join condition: None
 Output [1]: [c_current_cdemo_sk#4]
 Input [3]: [c_current_cdemo_sk#4, c_current_addr_sk#5, ca_address_sk#17]
 
-(39) Exchange
+(39) BroadcastExchange
 Input [1]: [c_current_cdemo_sk#4]
-Arguments: hashpartitioning(c_current_cdemo_sk#4, 5), ENSURE_REQUIREMENTS, 
[plan_id=7]
+Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as 
bigint)),false), [plan_id=7]
 
-(40) Sort [codegen id : 16]
-Input [1]: [c_current_cdemo_sk#4]
-Arguments: [c_current_cdemo_sk#4 ASC NULLS FIRST], false, 0
-
-(41) Scan parquet spark_catalog.default.customer_demographics
+(40) Scan parquet spark_catalog.default.customer_demographics
 Output [9]: [cd_demo_sk#19, cd_gender#20, cd_marital_status#21, 
cd_education_status#22, cd_purchase_estimate#23, cd_credit_rating#24, 
cd_dep_count#25, cd_dep_employed_count#26, cd_dep_college_count#27]
 Batched: true
 Location [not included in comparison]/{warehouse_dir}/customer_demographics]
 PushedFilters: [IsNotNull(cd_demo_sk)]
 ReadSchema: 
struct<cd_demo_sk:int,cd_gender:string,cd_marital_status:string,cd_education_status:string,cd_purchase_estimate:int,cd_credit_rating:string,cd_dep_count:int,cd_dep_employed_count:int,cd_dep_college_count:int>
 
-(42) ColumnarToRow [codegen id : 17]
+(41) ColumnarToRow
 Input [9]: [cd_demo_sk#19, cd_gender#20, cd_marital_status#21, 
cd_education_status#22, cd_purchase_estimate#23, cd_credit_rating#24, 
cd_dep_count#25, cd_dep_employed_count#26, cd_dep_college_count#27]
 
-(43) Filter [codegen id : 17]
+(42) Filter
 Input [9]: [cd_demo_sk#19, cd_gender#20, cd_marital_status#21, 
cd_education_status#22, cd_purchase_estimate#23, cd_credit_rating#24, 
cd_dep_count#25, cd_dep_employed_count#26, cd_dep_college_count#27]
 Condition : isnotnull(cd_demo_sk#19)
 
-(44) Exchange
-Input [9]: [cd_demo_sk#19, cd_gender#20, cd_marital_status#21, 
cd_education_status#22, cd_purchase_estimate#23, cd_credit_rating#24, 
cd_dep_count#25, cd_dep_employed_count#26, cd_dep_college_count#27]
-Arguments: hashpartitioning(cd_demo_sk#19, 5), ENSURE_REQUIREMENTS, [plan_id=8]
-
-(45) Sort [codegen id : 18]
-Input [9]: [cd_demo_sk#19, cd_gender#20, cd_marital_status#21, 
cd_education_status#22, cd_purchase_estimate#23, cd_credit_rating#24, 
cd_dep_count#25, cd_dep_employed_count#26, cd_dep_college_count#27]
-Arguments: [cd_demo_sk#19 ASC NULLS FIRST], false, 0
-
-(46) SortMergeJoin [codegen id : 19]
+(43) BroadcastHashJoin [codegen id : 16]
 Left keys [1]: [c_current_cdemo_sk#4]
 Right keys [1]: [cd_demo_sk#19]
 Join type: Inner
 Join condition: None
 
-(47) Project [codegen id : 19]
+(44) Project [codegen id : 16]
 Output [8]: [cd_gender#20, cd_marital_status#21, cd_education_status#22, 
cd_purchase_estimate#23, cd_credit_rating#24, cd_dep_count#25, 
cd_dep_employed_count#26, cd_dep_college_count#27]
 Input [10]: [c_current_cdemo_sk#4, cd_demo_sk#19, cd_gender#20, 
cd_marital_status#21, cd_education_status#22, cd_purchase_estimate#23, 
cd_credit_rating#24, cd_dep_count#25, cd_dep_employed_count#26, 
cd_dep_college_count#27]
 
-(48) HashAggregate [codegen id : 19]
+(45) HashAggregate [codegen id : 16]
 Input [8]: [cd_gender#20, cd_marital_status#21, cd_education_status#22, 
cd_purchase_estimate#23, cd_credit_rating#24, cd_dep_count#25, 
cd_dep_employed_count#26, cd_dep_college_count#27]
 Keys [8]: [cd_gender#20, cd_marital_status#21, cd_education_status#22, 
cd_purchase_estimate#23, cd_credit_rating#24, cd_dep_count#25, 
cd_dep_employed_count#26, cd_dep_college_count#27]
 Functions [1]: [partial_count(1)]
 Aggregate Attributes [1]: [count#28]
 Results [9]: [cd_gender#20, cd_marital_status#21, cd_education_status#22, 
cd_purchase_estimate#23, cd_credit_rating#24, cd_dep_count#25, 
cd_dep_employed_count#26, cd_dep_college_count#27, count#29]
 
-(49) Exchange
+(46) Exchange
 Input [9]: [cd_gender#20, cd_marital_status#21, cd_education_status#22, 
cd_purchase_estimate#23, cd_credit_rating#24, cd_dep_count#25, 
cd_dep_employed_count#26, cd_dep_college_count#27, count#29]
-Arguments: hashpartitioning(cd_gender#20, cd_marital_status#21, 
cd_education_status#22, cd_purchase_estimate#23, cd_credit_rating#24, 
cd_dep_count#25, cd_dep_employed_count#26, cd_dep_college_count#27, 5), 
ENSURE_REQUIREMENTS, [plan_id=9]
+Arguments: hashpartitioning(cd_gender#20, cd_marital_status#21, 
cd_education_status#22, cd_purchase_estimate#23, cd_credit_rating#24, 
cd_dep_count#25, cd_dep_employed_count#26, cd_dep_college_count#27, 5), 
ENSURE_REQUIREMENTS, [plan_id=8]
 
-(50) HashAggregate [codegen id : 20]
+(47) HashAggregate [codegen id : 17]
 Input [9]: [cd_gender#20, cd_marital_status#21, cd_education_status#22, 
cd_purchase_estimate#23, cd_credit_rating#24, cd_dep_count#25, 
cd_dep_employed_count#26, cd_dep_college_count#27, count#29]
 Keys [8]: [cd_gender#20, cd_marital_status#21, cd_education_status#22, 
cd_purchase_estimate#23, cd_credit_rating#24, cd_dep_count#25, 
cd_dep_employed_count#26, cd_dep_college_count#27]
 Functions [1]: [count(1)]
 Aggregate Attributes [1]: [count(1)#30]
 Results [14]: [cd_gender#20, cd_marital_status#21, cd_education_status#22, 
count(1)#30 AS cnt1#31, cd_purchase_estimate#23, count(1)#30 AS cnt2#32, 
cd_credit_rating#24, count(1)#30 AS cnt3#33, cd_dep_count#25, count(1)#30 AS 
cnt4#34, cd_dep_employed_count#26, count(1)#30 AS cnt5#35, 
cd_dep_college_count#27, count(1)#30 AS cnt6#36]
 
-(51) TakeOrderedAndProject
+(48) TakeOrderedAndProject
 Input [14]: [cd_gender#20, cd_marital_status#21, cd_education_status#22, 
cnt1#31, cd_purchase_estimate#23, cnt2#32, cd_credit_rating#24, cnt3#33, 
cd_dep_count#25, cnt4#34, cd_dep_employed_count#26, cnt5#35, 
cd_dep_college_count#27, cnt6#36]
 Arguments: 100, [cd_gender#20 ASC NULLS FIRST, cd_marital_status#21 ASC NULLS 
FIRST, cd_education_status#22 ASC NULLS FIRST, cd_purchase_estimate#23 ASC 
NULLS FIRST, cd_credit_rating#24 ASC NULLS FIRST, cd_dep_count#25 ASC NULLS 
FIRST, cd_dep_employed_count#26 ASC NULLS FIRST, cd_dep_college_count#27 ASC 
NULLS FIRST], [cd_gender#20, cd_marital_status#21, cd_education_status#22, 
cnt1#31, cd_purchase_estimate#23, cnt2#32, cd_credit_rating#24, cnt3#33, 
cd_dep_count#25, cnt4#34, cd_dep_emplo [...]
 
 ===== Subqueries =====
 
 Subquery:1 Hosting operator id = 3 Hosting Expression = Subquery 
scalar-subquery#6, [id=#1]
-ObjectHashAggregate (58)
-+- Exchange (57)
-   +- ObjectHashAggregate (56)
-      +- * Project (55)
-         +- * Filter (54)
-            +- * ColumnarToRow (53)
-               +- Scan parquet spark_catalog.default.customer_address (52)
+ObjectHashAggregate (55)
++- Exchange (54)
+   +- ObjectHashAggregate (53)
+      +- * Project (52)
+         +- * Filter (51)
+            +- * ColumnarToRow (50)
+               +- Scan parquet spark_catalog.default.customer_address (49)
 
 
-(52) Scan parquet spark_catalog.default.customer_address
+(49) Scan parquet spark_catalog.default.customer_address
 Output [2]: [ca_address_sk#17, ca_county#18]
 Batched: true
 Location [not included in comparison]/{warehouse_dir}/customer_address]
 PushedFilters: [In(ca_county, [Dona Ana County,Jefferson County,La Porte 
County,Rush County,Toole County]), IsNotNull(ca_address_sk)]
 ReadSchema: struct<ca_address_sk:int,ca_county:string>
 
-(53) ColumnarToRow [codegen id : 1]
+(50) ColumnarToRow [codegen id : 1]
 Input [2]: [ca_address_sk#17, ca_county#18]
 
-(54) Filter [codegen id : 1]
+(51) Filter [codegen id : 1]
 Input [2]: [ca_address_sk#17, ca_county#18]
 Condition : (ca_county#18 IN (Rush County,Toole County,Jefferson County,Dona 
Ana County,La Porte County) AND isnotnull(ca_address_sk#17))
 
-(55) Project [codegen id : 1]
+(52) Project [codegen id : 1]
 Output [1]: [ca_address_sk#17]
 Input [2]: [ca_address_sk#17, ca_county#18]
 
-(56) ObjectHashAggregate
+(53) ObjectHashAggregate
 Input [1]: [ca_address_sk#17]
 Keys: []
 Functions [1]: [partial_bloom_filter_agg(xxhash64(ca_address_sk#17, 42), 2555, 
57765, 0, 0)]
 Aggregate Attributes [1]: [buf#37]
 Results [1]: [buf#38]
 
-(57) Exchange
+(54) Exchange
 Input [1]: [buf#38]
-Arguments: SinglePartition, ENSURE_REQUIREMENTS, [plan_id=10]
+Arguments: SinglePartition, ENSURE_REQUIREMENTS, [plan_id=9]
 
-(58) ObjectHashAggregate
+(55) ObjectHashAggregate
 Input [1]: [buf#38]
 Keys: []
 Functions [1]: [bloom_filter_agg(xxhash64(ca_address_sk#17, 42), 2555, 57765, 
0, 0)]
@@ -336,34 +321,34 @@ Aggregate Attributes [1]: 
[bloom_filter_agg(xxhash64(ca_address_sk#17, 42), 2555
 Results [1]: [bloom_filter_agg(xxhash64(ca_address_sk#17, 42), 2555, 57765, 0, 
0)#39 AS bloomFilter#40]
 
 Subquery:2 Hosting operator id = 6 Hosting Expression = ss_sold_date_sk#8 IN 
dynamicpruning#9
-BroadcastExchange (63)
-+- * Project (62)
-   +- * Filter (61)
-      +- * ColumnarToRow (60)
-         +- Scan parquet spark_catalog.default.date_dim (59)
+BroadcastExchange (60)
++- * Project (59)
+   +- * Filter (58)
+      +- * ColumnarToRow (57)
+         +- Scan parquet spark_catalog.default.date_dim (56)
 
 
-(59) Scan parquet spark_catalog.default.date_dim
+(56) Scan parquet spark_catalog.default.date_dim
 Output [3]: [d_date_sk#10, d_year#41, d_moy#42]
 Batched: true
 Location [not included in comparison]/{warehouse_dir}/date_dim]
 PushedFilters: [IsNotNull(d_year), IsNotNull(d_moy), EqualTo(d_year,2002), 
GreaterThanOrEqual(d_moy,1), LessThanOrEqual(d_moy,4), IsNotNull(d_date_sk)]
 ReadSchema: struct<d_date_sk:int,d_year:int,d_moy:int>
 
-(60) ColumnarToRow [codegen id : 1]
+(57) ColumnarToRow [codegen id : 1]
 Input [3]: [d_date_sk#10, d_year#41, d_moy#42]
 
-(61) Filter [codegen id : 1]
+(58) Filter [codegen id : 1]
 Input [3]: [d_date_sk#10, d_year#41, d_moy#42]
 Condition : (((((isnotnull(d_year#41) AND isnotnull(d_moy#42)) AND (d_year#41 
= 2002)) AND (d_moy#42 >= 1)) AND (d_moy#42 <= 4)) AND isnotnull(d_date_sk#10))
 
-(62) Project [codegen id : 1]
+(59) Project [codegen id : 1]
 Output [1]: [d_date_sk#10]
 Input [3]: [d_date_sk#10, d_year#41, d_moy#42]
 
-(63) BroadcastExchange
+(60) BroadcastExchange
 Input [1]: [d_date_sk#10]
-Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as 
bigint)),false), [plan_id=11]
+Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as 
bigint)),false), [plan_id=10]
 
 Subquery:3 Hosting operator id = 14 Hosting Expression = ws_sold_date_sk#12 IN 
dynamicpruning#9
 
diff --git 
a/sql/core/src/test/resources/tpcds-plan-stability/approved-plans-v1_4/q10.sf100/simplified.txt
 
b/sql/core/src/test/resources/tpcds-plan-stability/approved-plans-v1_4/q10.sf100/simplified.txt
index 9528756e264b..9f3b2fc0d7e0 100644
--- 
a/sql/core/src/test/resources/tpcds-plan-stability/approved-plans-v1_4/q10.sf100/simplified.txt
+++ 
b/sql/core/src/test/resources/tpcds-plan-stability/approved-plans-v1_4/q10.sf100/simplified.txt
@@ -1,113 +1,104 @@
 TakeOrderedAndProject 
[cd_gender,cd_marital_status,cd_education_status,cd_purchase_estimate,cd_credit_rating,cd_dep_count,cd_dep_employed_count,cd_dep_college_count,cnt1,cnt2,cnt3,cnt4,cnt5,cnt6]
-  WholeStageCodegen (20)
+  WholeStageCodegen (17)
     HashAggregate 
[cd_gender,cd_marital_status,cd_education_status,cd_purchase_estimate,cd_credit_rating,cd_dep_count,cd_dep_employed_count,cd_dep_college_count,count]
 [count(1),cnt1,cnt2,cnt3,cnt4,cnt5,cnt6,count]
       InputAdapter
         Exchange 
[cd_gender,cd_marital_status,cd_education_status,cd_purchase_estimate,cd_credit_rating,cd_dep_count,cd_dep_employed_count,cd_dep_college_count]
 #1
-          WholeStageCodegen (19)
+          WholeStageCodegen (16)
             HashAggregate 
[cd_gender,cd_marital_status,cd_education_status,cd_purchase_estimate,cd_credit_rating,cd_dep_count,cd_dep_employed_count,cd_dep_college_count]
 [count,count]
               Project 
[cd_gender,cd_marital_status,cd_education_status,cd_purchase_estimate,cd_credit_rating,cd_dep_count,cd_dep_employed_count,cd_dep_college_count]
-                SortMergeJoin [c_current_cdemo_sk,cd_demo_sk]
+                BroadcastHashJoin [c_current_cdemo_sk,cd_demo_sk]
                   InputAdapter
-                    WholeStageCodegen (16)
-                      Sort [c_current_cdemo_sk]
-                        InputAdapter
-                          Exchange [c_current_cdemo_sk] #2
-                            WholeStageCodegen (15)
-                              Project [c_current_cdemo_sk]
-                                BroadcastHashJoin 
[c_current_addr_sk,ca_address_sk]
-                                  Project 
[c_current_cdemo_sk,c_current_addr_sk]
-                                    Filter [exists,exists]
-                                      SortMergeJoin 
[c_customer_sk,cs_ship_customer_sk]
+                    BroadcastExchange #2
+                      WholeStageCodegen (15)
+                        Project [c_current_cdemo_sk]
+                          BroadcastHashJoin [c_current_addr_sk,ca_address_sk]
+                            Project [c_current_cdemo_sk,c_current_addr_sk]
+                              Filter [exists,exists]
+                                SortMergeJoin 
[c_customer_sk,cs_ship_customer_sk]
+                                  InputAdapter
+                                    WholeStageCodegen (10)
+                                      SortMergeJoin 
[c_customer_sk,ws_bill_customer_sk]
                                         InputAdapter
-                                          WholeStageCodegen (10)
-                                            SortMergeJoin 
[c_customer_sk,ws_bill_customer_sk]
+                                          WholeStageCodegen (6)
+                                            SortMergeJoin 
[c_customer_sk,ss_customer_sk]
                                               InputAdapter
-                                                WholeStageCodegen (6)
-                                                  SortMergeJoin 
[c_customer_sk,ss_customer_sk]
-                                                    InputAdapter
-                                                      WholeStageCodegen (2)
-                                                        Sort [c_customer_sk]
-                                                          InputAdapter
-                                                            Exchange 
[c_customer_sk] #3
-                                                              
WholeStageCodegen (1)
-                                                                Filter 
[c_current_addr_sk,c_current_cdemo_sk]
-                                                                  Subquery #1
-                                                                    
ObjectHashAggregate [buf] [bloom_filter_agg(xxhash64(ca_address_sk, 42), 2555, 
57765, 0, 0),bloomFilter,buf]
-                                                                      Exchange 
#4
-                                                                        
ObjectHashAggregate [ca_address_sk] [buf,buf]
-                                                                          
WholeStageCodegen (1)
-                                                                            
Project [ca_address_sk]
-                                                                              
Filter [ca_county,ca_address_sk]
-                                                                               
 ColumnarToRow
-                                                                               
   InputAdapter
-                                                                               
     Scan parquet spark_catalog.default.customer_address 
[ca_address_sk,ca_county]
-                                                                  ColumnarToRow
-                                                                    
InputAdapter
-                                                                      Scan 
parquet spark_catalog.default.customer 
[c_customer_sk,c_current_cdemo_sk,c_current_addr_sk]
+                                                WholeStageCodegen (2)
+                                                  Sort [c_customer_sk]
                                                     InputAdapter
-                                                      WholeStageCodegen (5)
-                                                        Sort [ss_customer_sk]
-                                                          InputAdapter
-                                                            Exchange 
[ss_customer_sk] #5
-                                                              
WholeStageCodegen (4)
-                                                                Project 
[ss_customer_sk]
-                                                                  
BroadcastHashJoin [ss_sold_date_sk,d_date_sk]
-                                                                    
ColumnarToRow
-                                                                      
InputAdapter
-                                                                        Scan 
parquet spark_catalog.default.store_sales [ss_customer_sk,ss_sold_date_sk]
-                                                                          
SubqueryBroadcast [d_date_sk] #2
-                                                                            
BroadcastExchange #6
-                                                                              
WholeStageCodegen (1)
-                                                                               
 Project [d_date_sk]
-                                                                               
   Filter [d_year,d_moy,d_date_sk]
-                                                                               
     ColumnarToRow
-                                                                               
       InputAdapter
-                                                                               
         Scan parquet spark_catalog.default.date_dim [d_date_sk,d_year,d_moy]
-                                                                    
InputAdapter
-                                                                      
ReusedExchange [d_date_sk] #6
+                                                      Exchange [c_customer_sk] 
#3
+                                                        WholeStageCodegen (1)
+                                                          Filter 
[c_current_addr_sk,c_current_cdemo_sk]
+                                                            Subquery #1
+                                                              
ObjectHashAggregate [buf] [bloom_filter_agg(xxhash64(ca_address_sk, 42), 2555, 
57765, 0, 0),bloomFilter,buf]
+                                                                Exchange #4
+                                                                  
ObjectHashAggregate [ca_address_sk] [buf,buf]
+                                                                    
WholeStageCodegen (1)
+                                                                      Project 
[ca_address_sk]
+                                                                        Filter 
[ca_county,ca_address_sk]
+                                                                          
ColumnarToRow
+                                                                            
InputAdapter
+                                                                              
Scan parquet spark_catalog.default.customer_address [ca_address_sk,ca_county]
+                                                            ColumnarToRow
+                                                              InputAdapter
+                                                                Scan parquet 
spark_catalog.default.customer 
[c_customer_sk,c_current_cdemo_sk,c_current_addr_sk]
                                               InputAdapter
-                                                WholeStageCodegen (9)
-                                                  Sort [ws_bill_customer_sk]
+                                                WholeStageCodegen (5)
+                                                  Sort [ss_customer_sk]
                                                     InputAdapter
-                                                      Exchange 
[ws_bill_customer_sk] #7
-                                                        WholeStageCodegen (8)
-                                                          Project 
[ws_bill_customer_sk]
-                                                            BroadcastHashJoin 
[ws_sold_date_sk,d_date_sk]
+                                                      Exchange 
[ss_customer_sk] #5
+                                                        WholeStageCodegen (4)
+                                                          Project 
[ss_customer_sk]
+                                                            BroadcastHashJoin 
[ss_sold_date_sk,d_date_sk]
                                                               ColumnarToRow
                                                                 InputAdapter
-                                                                  Scan parquet 
spark_catalog.default.web_sales [ws_bill_customer_sk,ws_sold_date_sk]
-                                                                    
ReusedSubquery [d_date_sk] #2
+                                                                  Scan parquet 
spark_catalog.default.store_sales [ss_customer_sk,ss_sold_date_sk]
+                                                                    
SubqueryBroadcast [d_date_sk] #2
+                                                                      
BroadcastExchange #6
+                                                                        
WholeStageCodegen (1)
+                                                                          
Project [d_date_sk]
+                                                                            
Filter [d_year,d_moy,d_date_sk]
+                                                                              
ColumnarToRow
+                                                                               
 InputAdapter
+                                                                               
   Scan parquet spark_catalog.default.date_dim [d_date_sk,d_year,d_moy]
                                                               InputAdapter
                                                                 ReusedExchange 
[d_date_sk] #6
                                         InputAdapter
-                                          WholeStageCodegen (13)
-                                            Sort [cs_ship_customer_sk]
+                                          WholeStageCodegen (9)
+                                            Sort [ws_bill_customer_sk]
                                               InputAdapter
-                                                Exchange [cs_ship_customer_sk] 
#8
-                                                  WholeStageCodegen (12)
-                                                    Project 
[cs_ship_customer_sk]
-                                                      BroadcastHashJoin 
[cs_sold_date_sk,d_date_sk]
+                                                Exchange [ws_bill_customer_sk] 
#7
+                                                  WholeStageCodegen (8)
+                                                    Project 
[ws_bill_customer_sk]
+                                                      BroadcastHashJoin 
[ws_sold_date_sk,d_date_sk]
                                                         ColumnarToRow
                                                           InputAdapter
-                                                            Scan parquet 
spark_catalog.default.catalog_sales [cs_ship_customer_sk,cs_sold_date_sk]
+                                                            Scan parquet 
spark_catalog.default.web_sales [ws_bill_customer_sk,ws_sold_date_sk]
                                                               ReusedSubquery 
[d_date_sk] #2
                                                         InputAdapter
                                                           ReusedExchange 
[d_date_sk] #6
                                   InputAdapter
-                                    BroadcastExchange #9
-                                      WholeStageCodegen (14)
-                                        Project [ca_address_sk]
-                                          Filter [ca_county,ca_address_sk]
-                                            ColumnarToRow
-                                              InputAdapter
-                                                Scan parquet 
spark_catalog.default.customer_address [ca_address_sk,ca_county]
-                  InputAdapter
-                    WholeStageCodegen (18)
-                      Sort [cd_demo_sk]
-                        InputAdapter
-                          Exchange [cd_demo_sk] #10
-                            WholeStageCodegen (17)
-                              Filter [cd_demo_sk]
-                                ColumnarToRow
-                                  InputAdapter
-                                    Scan parquet 
spark_catalog.default.customer_demographics 
[cd_demo_sk,cd_gender,cd_marital_status,cd_education_status,cd_purchase_estimate,cd_credit_rating,cd_dep_count,cd_dep_employed_count,cd_dep_college_count]
+                                    WholeStageCodegen (13)
+                                      Sort [cs_ship_customer_sk]
+                                        InputAdapter
+                                          Exchange [cs_ship_customer_sk] #8
+                                            WholeStageCodegen (12)
+                                              Project [cs_ship_customer_sk]
+                                                BroadcastHashJoin 
[cs_sold_date_sk,d_date_sk]
+                                                  ColumnarToRow
+                                                    InputAdapter
+                                                      Scan parquet 
spark_catalog.default.catalog_sales [cs_ship_customer_sk,cs_sold_date_sk]
+                                                        ReusedSubquery 
[d_date_sk] #2
+                                                  InputAdapter
+                                                    ReusedExchange [d_date_sk] 
#6
+                            InputAdapter
+                              BroadcastExchange #9
+                                WholeStageCodegen (14)
+                                  Project [ca_address_sk]
+                                    Filter [ca_county,ca_address_sk]
+                                      ColumnarToRow
+                                        InputAdapter
+                                          Scan parquet 
spark_catalog.default.customer_address [ca_address_sk,ca_county]
+                  Filter [cd_demo_sk]
+                    ColumnarToRow
+                      InputAdapter
+                        Scan parquet 
spark_catalog.default.customer_demographics 
[cd_demo_sk,cd_gender,cd_marital_status,cd_education_status,cd_purchase_estimate,cd_credit_rating,cd_dep_count,cd_dep_employed_count,cd_dep_college_count]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to