== Physical Plan ==
TakeOrderedAndProject (70)
+- * Filter (69)
   +- * HashAggregate (68)
      +- * HashAggregate (67)
         +- * Project (66)
            +- * SortMergeJoin Inner (65)
               :- Window (60)
               :  +- * Sort (59)
               :     +- Exchange (58)
               :        +- * Project (57)
               :           +- * Filter (56)
               :              +- * SortMergeJoin FullOuter (55)
               :                 :- * Sort (27)
               :                 :  +- Exchange (26)
               :                 :     +- * HashAggregate (25)
               :                 :        +- * HashAggregate (24)
               :                 :           +- * Project (23)
               :                 :              +- * SortMergeJoin Inner (22)
               :                 :                 :- * Sort (15)
               :                 :                 :  +- Exchange (14)
               :                 :                 :     +- * Project (13)
               :                 :                 :        +- Window (12)
               :                 :                 :           +- * Sort (11)
               :                 :                 :              +- Exchange (10)
               :                 :                 :                 +- * HashAggregate (9)
               :                 :                 :                    +- Exchange (8)
               :                 :                 :                       +- * HashAggregate (7)
               :                 :                 :                          +- * Project (6)
               :                 :                 :                             +- * BroadcastHashJoin Inner BuildRight (5)
               :                 :                 :                                :- * Filter (3)
               :                 :                 :                                :  +- * ColumnarToRow (2)
               :                 :                 :                                :     +- Scan parquet spark_catalog.default.web_sales (1)
               :                 :                 :                                +- ReusedExchange (4)
               :                 :                 +- * Sort (21)
               :                 :                    +- Exchange (20)
               :                 :                       +- * Project (19)
               :                 :                          +- Window (18)
               :                 :                             +- * Sort (17)
               :                 :                                +- ReusedExchange (16)
               :                 +- * Sort (54)
               :                    +- Exchange (53)
               :                       +- * HashAggregate (52)
               :                          +- * HashAggregate (51)
               :                             +- * Project (50)
               :                                +- * SortMergeJoin Inner (49)
               :                                   :- * Sort (42)
               :                                   :  +- Exchange (41)
               :                                   :     +- * Project (40)
               :                                   :        +- Window (39)
               :                                   :           +- * Sort (38)
               :                                   :              +- Exchange (37)
               :                                   :                 +- * HashAggregate (36)
               :                                   :                    +- Exchange (35)
               :                                   :                       +- * HashAggregate (34)
               :                                   :                          +- * Project (33)
               :                                   :                             +- * BroadcastHashJoin Inner BuildRight (32)
               :                                   :                                :- * Filter (30)
               :                                   :                                :  +- * ColumnarToRow (29)
               :                                   :                                :     +- Scan parquet spark_catalog.default.store_sales (28)
               :                                   :                                +- ReusedExchange (31)
               :                                   +- * Sort (48)
               :                                      +- Exchange (47)
               :                                         +- * Project (46)
               :                                            +- Window (45)
               :                                               +- * Sort (44)
               :                                                  +- ReusedExchange (43)
               +- * Project (64)
                  +- Window (63)
                     +- * Sort (62)
                        +- ReusedExchange (61)


(1) Scan parquet spark_catalog.default.web_sales
Output [3]: [ws_item_sk#1, ws_sales_price#2, ws_sold_date_sk#3]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ws_sold_date_sk#3), dynamicpruningexpression(ws_sold_date_sk#3 IN dynamicpruning#4)]
PushedFilters: [IsNotNull(ws_item_sk)]
ReadSchema: struct<ws_item_sk:int,ws_sales_price:decimal(7,2)>

(2) ColumnarToRow [codegen id : 2]
Input [3]: [ws_item_sk#1, ws_sales_price#2, ws_sold_date_sk#3]

(3) Filter [codegen id : 2]
Input [3]: [ws_item_sk#1, ws_sales_price#2, ws_sold_date_sk#3]
Condition : isnotnull(ws_item_sk#1)

(4) ReusedExchange [Reuses operator id: 75]
Output [2]: [d_date_sk#5, d_date#6]

(5) BroadcastHashJoin [codegen id : 2]
Left keys [1]: [ws_sold_date_sk#3]
Right keys [1]: [d_date_sk#5]
Join type: Inner
Join condition: None

(6) Project [codegen id : 2]
Output [3]: [ws_item_sk#1, ws_sales_price#2, d_date#6]
Input [5]: [ws_item_sk#1, ws_sales_price#2, ws_sold_date_sk#3, d_date_sk#5, d_date#6]

(7) HashAggregate [codegen id : 2]
Input [3]: [ws_item_sk#1, ws_sales_price#2, d_date#6]
Keys [2]: [ws_item_sk#1, d_date#6]
Functions [1]: [partial_sum(UnscaledValue(ws_sales_price#2))]
Aggregate Attributes [1]: [sum#7]
Results [3]: [ws_item_sk#1, d_date#6, sum#8]

(8) Exchange
Input [3]: [ws_item_sk#1, d_date#6, sum#8]
Arguments: hashpartitioning(ws_item_sk#1, d_date#6, 5), ENSURE_REQUIREMENTS, [plan_id=1]

(9) HashAggregate [codegen id : 3]
Input [3]: [ws_item_sk#1, d_date#6, sum#8]
Keys [2]: [ws_item_sk#1, d_date#6]
Functions [1]: [sum(UnscaledValue(ws_sales_price#2))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_sales_price#2))#9]
Results [4]: [ws_item_sk#1 AS item_sk#10, d_date#6, MakeDecimal(sum(UnscaledValue(ws_sales_price#2))#9,17,2) AS sumws#11, ws_item_sk#1]

(10) Exchange
Input [4]: [item_sk#10, d_date#6, sumws#11, ws_item_sk#1]
Arguments: hashpartitioning(ws_item_sk#1, 5), ENSURE_REQUIREMENTS, [plan_id=2]

(11) Sort [codegen id : 4]
Input [4]: [item_sk#10, d_date#6, sumws#11, ws_item_sk#1]
Arguments: [ws_item_sk#1 ASC NULLS FIRST, d_date#6 ASC NULLS FIRST], false, 0

(12) Window
Input [4]: [item_sk#10, d_date#6, sumws#11, ws_item_sk#1]
Arguments: [row_number() windowspecdefinition(ws_item_sk#1, d_date#6 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#12], [ws_item_sk#1], [d_date#6 ASC NULLS FIRST]

(13) Project [codegen id : 5]
Output [4]: [item_sk#10, d_date#6, sumws#11, rk#12]
Input [5]: [item_sk#10, d_date#6, sumws#11, ws_item_sk#1, rk#12]

(14) Exchange
Input [4]: [item_sk#10, d_date#6, sumws#11, rk#12]
Arguments: hashpartitioning(item_sk#10, 5), ENSURE_REQUIREMENTS, [plan_id=3]

(15) Sort [codegen id : 6]
Input [4]: [item_sk#10, d_date#6, sumws#11, rk#12]
Arguments: [item_sk#10 ASC NULLS FIRST], false, 0

(16) ReusedExchange [Reuses operator id: 10]
Output [4]: [item_sk#13, d_date#14, sumws#15, ws_item_sk#16]

(17) Sort [codegen id : 10]
Input [4]: [item_sk#13, d_date#14, sumws#15, ws_item_sk#16]
Arguments: [ws_item_sk#16 ASC NULLS FIRST, d_date#14 ASC NULLS FIRST], false, 0

(18) Window
Input [4]: [item_sk#13, d_date#14, sumws#15, ws_item_sk#16]
Arguments: [row_number() windowspecdefinition(ws_item_sk#16, d_date#14 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#17], [ws_item_sk#16], [d_date#14 ASC NULLS FIRST]

(19) Project [codegen id : 11]
Output [3]: [item_sk#13, sumws#15, rk#17]
Input [5]: [item_sk#13, d_date#14, sumws#15, ws_item_sk#16, rk#17]

(20) Exchange
Input [3]: [item_sk#13, sumws#15, rk#17]
Arguments: hashpartitioning(item_sk#13, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(21) Sort [codegen id : 12]
Input [3]: [item_sk#13, sumws#15, rk#17]
Arguments: [item_sk#13 ASC NULLS FIRST], false, 0

(22) SortMergeJoin [codegen id : 13]
Left keys [1]: [item_sk#10]
Right keys [1]: [item_sk#13]
Join type: Inner
Join condition: (rk#12 >= rk#17)

(23) Project [codegen id : 13]
Output [4]: [item_sk#10, d_date#6, sumws#11, sumws#15]
Input [7]: [item_sk#10, d_date#6, sumws#11, rk#12, item_sk#13, sumws#15, rk#17]

(24) HashAggregate [codegen id : 13]
Input [4]: [item_sk#10, d_date#6, sumws#11, sumws#15]
Keys [3]: [item_sk#10, d_date#6, sumws#11]
Functions [1]: [partial_sum(sumws#15)]
Aggregate Attributes [2]: [sum#18, isEmpty#19]
Results [5]: [item_sk#10, d_date#6, sumws#11, sum#20, isEmpty#21]

(25) HashAggregate [codegen id : 13]
Input [5]: [item_sk#10, d_date#6, sumws#11, sum#20, isEmpty#21]
Keys [3]: [item_sk#10, d_date#6, sumws#11]
Functions [1]: [sum(sumws#15)]
Aggregate Attributes [1]: [sum(sumws#15)#22]
Results [3]: [item_sk#10, d_date#6, sum(sumws#15)#22 AS cume_sales#23]

(26) Exchange
Input [3]: [item_sk#10, d_date#6, cume_sales#23]
Arguments: hashpartitioning(item_sk#10, d_date#6, 5), ENSURE_REQUIREMENTS, [plan_id=5]

(27) Sort [codegen id : 14]
Input [3]: [item_sk#10, d_date#6, cume_sales#23]
Arguments: [item_sk#10 ASC NULLS FIRST, d_date#6 ASC NULLS FIRST], false, 0

(28) Scan parquet spark_catalog.default.store_sales
Output [3]: [ss_item_sk#24, ss_sales_price#25, ss_sold_date_sk#26]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#26), dynamicpruningexpression(ss_sold_date_sk#26 IN dynamicpruning#4)]
PushedFilters: [IsNotNull(ss_item_sk)]
ReadSchema: struct<ss_item_sk:int,ss_sales_price:decimal(7,2)>

(29) ColumnarToRow [codegen id : 16]
Input [3]: [ss_item_sk#24, ss_sales_price#25, ss_sold_date_sk#26]

(30) Filter [codegen id : 16]
Input [3]: [ss_item_sk#24, ss_sales_price#25, ss_sold_date_sk#26]
Condition : isnotnull(ss_item_sk#24)

(31) ReusedExchange [Reuses operator id: 75]
Output [2]: [d_date_sk#27, d_date#28]

(32) BroadcastHashJoin [codegen id : 16]
Left keys [1]: [ss_sold_date_sk#26]
Right keys [1]: [d_date_sk#27]
Join type: Inner
Join condition: None

(33) Project [codegen id : 16]
Output [3]: [ss_item_sk#24, ss_sales_price#25, d_date#28]
Input [5]: [ss_item_sk#24, ss_sales_price#25, ss_sold_date_sk#26, d_date_sk#27, d_date#28]

(34) HashAggregate [codegen id : 16]
Input [3]: [ss_item_sk#24, ss_sales_price#25, d_date#28]
Keys [2]: [ss_item_sk#24, d_date#28]
Functions [1]: [partial_sum(UnscaledValue(ss_sales_price#25))]
Aggregate Attributes [1]: [sum#29]
Results [3]: [ss_item_sk#24, d_date#28, sum#30]

(35) Exchange
Input [3]: [ss_item_sk#24, d_date#28, sum#30]
Arguments: hashpartitioning(ss_item_sk#24, d_date#28, 5), ENSURE_REQUIREMENTS, [plan_id=6]

(36) HashAggregate [codegen id : 17]
Input [3]: [ss_item_sk#24, d_date#28, sum#30]
Keys [2]: [ss_item_sk#24, d_date#28]
Functions [1]: [sum(UnscaledValue(ss_sales_price#25))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_sales_price#25))#31]
Results [4]: [ss_item_sk#24 AS item_sk#32, d_date#28, MakeDecimal(sum(UnscaledValue(ss_sales_price#25))#31,17,2) AS sumss#33, ss_item_sk#24]

(37) Exchange
Input [4]: [item_sk#32, d_date#28, sumss#33, ss_item_sk#24]
Arguments: hashpartitioning(ss_item_sk#24, 5), ENSURE_REQUIREMENTS, [plan_id=7]

(38) Sort [codegen id : 18]
Input [4]: [item_sk#32, d_date#28, sumss#33, ss_item_sk#24]
Arguments: [ss_item_sk#24 ASC NULLS FIRST, d_date#28 ASC NULLS FIRST], false, 0

(39) Window
Input [4]: [item_sk#32, d_date#28, sumss#33, ss_item_sk#24]
Arguments: [row_number() windowspecdefinition(ss_item_sk#24, d_date#28 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#34], [ss_item_sk#24], [d_date#28 ASC NULLS FIRST]

(40) Project [codegen id : 19]
Output [4]: [item_sk#32, d_date#28, sumss#33, rk#34]
Input [5]: [item_sk#32, d_date#28, sumss#33, ss_item_sk#24, rk#34]

(41) Exchange
Input [4]: [item_sk#32, d_date#28, sumss#33, rk#34]
Arguments: hashpartitioning(item_sk#32, 5), ENSURE_REQUIREMENTS, [plan_id=8]

(42) Sort [codegen id : 20]
Input [4]: [item_sk#32, d_date#28, sumss#33, rk#34]
Arguments: [item_sk#32 ASC NULLS FIRST], false, 0

(43) ReusedExchange [Reuses operator id: 37]
Output [4]: [item_sk#35, d_date#36, sumss#37, ss_item_sk#38]

(44) Sort [codegen id : 24]
Input [4]: [item_sk#35, d_date#36, sumss#37, ss_item_sk#38]
Arguments: [ss_item_sk#38 ASC NULLS FIRST, d_date#36 ASC NULLS FIRST], false, 0

(45) Window
Input [4]: [item_sk#35, d_date#36, sumss#37, ss_item_sk#38]
Arguments: [row_number() windowspecdefinition(ss_item_sk#38, d_date#36 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#39], [ss_item_sk#38], [d_date#36 ASC NULLS FIRST]

(46) Project [codegen id : 25]
Output [3]: [item_sk#35, sumss#37, rk#39]
Input [5]: [item_sk#35, d_date#36, sumss#37, ss_item_sk#38, rk#39]

(47) Exchange
Input [3]: [item_sk#35, sumss#37, rk#39]
Arguments: hashpartitioning(item_sk#35, 5), ENSURE_REQUIREMENTS, [plan_id=9]

(48) Sort [codegen id : 26]
Input [3]: [item_sk#35, sumss#37, rk#39]
Arguments: [item_sk#35 ASC NULLS FIRST], false, 0

(49) SortMergeJoin [codegen id : 27]
Left keys [1]: [item_sk#32]
Right keys [1]: [item_sk#35]
Join type: Inner
Join condition: (rk#34 >= rk#39)

(50) Project [codegen id : 27]
Output [4]: [item_sk#32, d_date#28, sumss#33, sumss#37]
Input [7]: [item_sk#32, d_date#28, sumss#33, rk#34, item_sk#35, sumss#37, rk#39]

(51) HashAggregate [codegen id : 27]
Input [4]: [item_sk#32, d_date#28, sumss#33, sumss#37]
Keys [3]: [item_sk#32, d_date#28, sumss#33]
Functions [1]: [partial_sum(sumss#37)]
Aggregate Attributes [2]: [sum#40, isEmpty#41]
Results [5]: [item_sk#32, d_date#28, sumss#33, sum#42, isEmpty#43]

(52) HashAggregate [codegen id : 27]
Input [5]: [item_sk#32, d_date#28, sumss#33, sum#42, isEmpty#43]
Keys [3]: [item_sk#32, d_date#28, sumss#33]
Functions [1]: [sum(sumss#37)]
Aggregate Attributes [1]: [sum(sumss#37)#44]
Results [3]: [item_sk#32, d_date#28, sum(sumss#37)#44 AS cume_sales#45]

(53) Exchange
Input [3]: [item_sk#32, d_date#28, cume_sales#45]
Arguments: hashpartitioning(item_sk#32, d_date#28, 5), ENSURE_REQUIREMENTS, [plan_id=10]

(54) Sort [codegen id : 28]
Input [3]: [item_sk#32, d_date#28, cume_sales#45]
Arguments: [item_sk#32 ASC NULLS FIRST, d_date#28 ASC NULLS FIRST], false, 0

(55) SortMergeJoin [codegen id : 29]
Left keys [2]: [item_sk#10, d_date#6]
Right keys [2]: [item_sk#32, d_date#28]
Join type: FullOuter
Join condition: None

(56) Filter [codegen id : 29]
Input [6]: [item_sk#10, d_date#6, cume_sales#23, item_sk#32, d_date#28, cume_sales#45]
Condition : isnotnull(CASE WHEN isnotnull(item_sk#10) THEN item_sk#10 ELSE item_sk#32 END)

(57) Project [codegen id : 29]
Output [4]: [CASE WHEN isnotnull(item_sk#10) THEN item_sk#10 ELSE item_sk#32 END AS item_sk#46, CASE WHEN isnotnull(d_date#6) THEN d_date#6 ELSE d_date#28 END AS d_date#47, cume_sales#23 AS web_sales#48, cume_sales#45 AS store_sales#49]
Input [6]: [item_sk#10, d_date#6, cume_sales#23, item_sk#32, d_date#28, cume_sales#45]

(58) Exchange
Input [4]: [item_sk#46, d_date#47, web_sales#48, store_sales#49]
Arguments: hashpartitioning(item_sk#46, 5), ENSURE_REQUIREMENTS, [plan_id=11]

(59) Sort [codegen id : 30]
Input [4]: [item_sk#46, d_date#47, web_sales#48, store_sales#49]
Arguments: [item_sk#46 ASC NULLS FIRST, d_date#47 ASC NULLS FIRST], false, 0

(60) Window
Input [4]: [item_sk#46, d_date#47, web_sales#48, store_sales#49]
Arguments: [row_number() windowspecdefinition(item_sk#46, d_date#47 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#50], [item_sk#46], [d_date#47 ASC NULLS FIRST]

(61) ReusedExchange [Reuses operator id: 58]
Output [4]: [item_sk#51, d_date#52, web_sales#53, store_sales#54]

(62) Sort [codegen id : 60]
Input [4]: [item_sk#51, d_date#52, web_sales#53, store_sales#54]
Arguments: [item_sk#51 ASC NULLS FIRST, d_date#52 ASC NULLS FIRST], false, 0

(63) Window
Input [4]: [item_sk#51, d_date#52, web_sales#53, store_sales#54]
Arguments: [row_number() windowspecdefinition(item_sk#51, d_date#52 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#55], [item_sk#51], [d_date#52 ASC NULLS FIRST]

(64) Project [codegen id : 61]
Output [4]: [item_sk#51, web_sales#53, store_sales#54, rk#55]
Input [5]: [item_sk#51, d_date#52, web_sales#53, store_sales#54, rk#55]

(65) SortMergeJoin [codegen id : 62]
Left keys [1]: [item_sk#46]
Right keys [1]: [item_sk#51]
Join type: Inner
Join condition: (rk#50 >= rk#55)

(66) Project [codegen id : 62]
Output [6]: [item_sk#46, d_date#47, web_sales#48, store_sales#49, web_sales#53, store_sales#54]
Input [9]: [item_sk#46, d_date#47, web_sales#48, store_sales#49, rk#50, item_sk#51, web_sales#53, store_sales#54, rk#55]

(67) HashAggregate [codegen id : 62]
Input [6]: [item_sk#46, d_date#47, web_sales#48, store_sales#49, web_sales#53, store_sales#54]
Keys [4]: [item_sk#46, d_date#47, web_sales#48, store_sales#49]
Functions [2]: [partial_max(web_sales#53), partial_max(store_sales#54)]
Aggregate Attributes [2]: [max#56, max#57]
Results [6]: [item_sk#46, d_date#47, web_sales#48, store_sales#49, max#58, max#59]

(68) HashAggregate [codegen id : 62]
Input [6]: [item_sk#46, d_date#47, web_sales#48, store_sales#49, max#58, max#59]
Keys [4]: [item_sk#46, d_date#47, web_sales#48, store_sales#49]
Functions [2]: [max(web_sales#53), max(store_sales#54)]
Aggregate Attributes [2]: [max(web_sales#53)#60, max(store_sales#54)#61]
Results [6]: [item_sk#46, d_date#47, web_sales#48, store_sales#49, max(web_sales#53)#60 AS web_cumulative#62, max(store_sales#54)#61 AS store_cumulative#63]

(69) Filter [codegen id : 62]
Input [6]: [item_sk#46, d_date#47, web_sales#48, store_sales#49, web_cumulative#62, store_cumulative#63]
Condition : ((isnotnull(web_cumulative#62) AND isnotnull(store_cumulative#63)) AND (web_cumulative#62 > store_cumulative#63))

(70) TakeOrderedAndProject
Input [6]: [item_sk#46, d_date#47, web_sales#48, store_sales#49, web_cumulative#62, store_cumulative#63]
Arguments: 100, [item_sk#46 ASC NULLS FIRST, d_date#47 ASC NULLS FIRST], [item_sk#46, d_date#47, web_sales#48, store_sales#49, web_cumulative#62, store_cumulative#63]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ws_sold_date_sk#3 IN dynamicpruning#4
BroadcastExchange (75)
+- * Project (74)
   +- * Filter (73)
      +- * ColumnarToRow (72)
         +- Scan parquet spark_catalog.default.date_dim (71)


(71) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_date_sk#5, d_date#6, d_month_seq#64]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_month_seq), GreaterThanOrEqual(d_month_seq,1212), LessThanOrEqual(d_month_seq,1223), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_date:date,d_month_seq:int>

(72) ColumnarToRow [codegen id : 1]
Input [3]: [d_date_sk#5, d_date#6, d_month_seq#64]

(73) Filter [codegen id : 1]
Input [3]: [d_date_sk#5, d_date#6, d_month_seq#64]
Condition : (((isnotnull(d_month_seq#64) AND (d_month_seq#64 >= 1212)) AND (d_month_seq#64 <= 1223)) AND isnotnull(d_date_sk#5))

(74) Project [codegen id : 1]
Output [2]: [d_date_sk#5, d_date#6]
Input [3]: [d_date_sk#5, d_date#6, d_month_seq#64]

(75) BroadcastExchange
Input [2]: [d_date_sk#5, d_date#6]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=12]

Subquery:2 Hosting operator id = 28 Hosting Expression = ss_sold_date_sk#26 IN dynamicpruning#4


