== Physical Plan ==
TakeOrderedAndProject (67)
+- * Filter (66)
   +- * HashAggregate (65)
      +- * Project (64)
         +- * SortMergeJoin Inner (63)
            :- Window (58)
            :  +- * Sort (57)
            :     +- Exchange (56)
            :        +- * Project (55)
            :           +- * Filter (54)
            :              +- * SortMergeJoin FullOuter (53)
            :                 :- * Sort (26)
            :                 :  +- Exchange (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 (52)
            :                    +- Exchange (51)
            :                       +- * HashAggregate (50)
            :                          +- * Project (49)
            :                             +- * SortMergeJoin Inner (48)
            :                                :- * Sort (41)
            :                                :  +- Exchange (40)
            :                                :     +- * Project (39)
            :                                :        +- Window (38)
            :                                :           +- * Sort (37)
            :                                :              +- Exchange (36)
            :                                :                 +- * HashAggregate (35)
            :                                :                    +- Exchange (34)
            :                                :                       +- * HashAggregate (33)
            :                                :                          +- * Project (32)
            :                                :                             +- * BroadcastHashJoin Inner BuildRight (31)
            :                                :                                :- * Filter (29)
            :                                :                                :  +- * ColumnarToRow (28)
            :                                :                                :     +- Scan parquet spark_catalog.default.store_sales (27)
            :                                :                                +- ReusedExchange (30)
            :                                +- * Sort (47)
            :                                   +- Exchange (46)
            :                                      +- * Project (45)
            :                                         +- Window (44)
            :                                            +- * Sort (43)
            :                                               +- ReusedExchange (42)
            +- * Project (62)
               +- Window (61)
                  +- * Sort (60)
                     +- ReusedExchange (59)


(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: 72]
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]: [sum(sumws#15)]
Aggregate Attributes [1]: [sum(sumws#15)#18]
Results [3]: [item_sk#10, d_date#6, sum(sumws#15)#18 AS cume_sales#19]

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

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

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

(28) ColumnarToRow [codegen id : 16]
Input [3]: [ss_item_sk#20, ss_sales_price#21, ss_sold_date_sk#22]

(29) Filter [codegen id : 16]
Input [3]: [ss_item_sk#20, ss_sales_price#21, ss_sold_date_sk#22]
Condition : isnotnull(ss_item_sk#20)

(30) ReusedExchange [Reuses operator id: 72]
Output [2]: [d_date_sk#23, d_date#24]

(31) BroadcastHashJoin [codegen id : 16]
Left keys [1]: [ss_sold_date_sk#22]
Right keys [1]: [d_date_sk#23]
Join type: Inner
Join condition: None

(32) Project [codegen id : 16]
Output [3]: [ss_item_sk#20, ss_sales_price#21, d_date#24]
Input [5]: [ss_item_sk#20, ss_sales_price#21, ss_sold_date_sk#22, d_date_sk#23, d_date#24]

(33) HashAggregate [codegen id : 16]
Input [3]: [ss_item_sk#20, ss_sales_price#21, d_date#24]
Keys [2]: [ss_item_sk#20, d_date#24]
Functions [1]: [partial_sum(UnscaledValue(ss_sales_price#21))]
Aggregate Attributes [1]: [sum#25]
Results [3]: [ss_item_sk#20, d_date#24, sum#26]

(34) Exchange
Input [3]: [ss_item_sk#20, d_date#24, sum#26]
Arguments: hashpartitioning(ss_item_sk#20, d_date#24, 5), ENSURE_REQUIREMENTS, [plan_id=6]

(35) HashAggregate [codegen id : 17]
Input [3]: [ss_item_sk#20, d_date#24, sum#26]
Keys [2]: [ss_item_sk#20, d_date#24]
Functions [1]: [sum(UnscaledValue(ss_sales_price#21))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_sales_price#21))#27]
Results [4]: [ss_item_sk#20 AS item_sk#28, d_date#24, MakeDecimal(sum(UnscaledValue(ss_sales_price#21))#27,17,2) AS sumss#29, ss_item_sk#20]

(36) Exchange
Input [4]: [item_sk#28, d_date#24, sumss#29, ss_item_sk#20]
Arguments: hashpartitioning(ss_item_sk#20, 5), ENSURE_REQUIREMENTS, [plan_id=7]

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

(38) Window
Input [4]: [item_sk#28, d_date#24, sumss#29, ss_item_sk#20]
Arguments: [row_number() windowspecdefinition(ss_item_sk#20, d_date#24 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#30], [ss_item_sk#20], [d_date#24 ASC NULLS FIRST]

(39) Project [codegen id : 19]
Output [4]: [item_sk#28, d_date#24, sumss#29, rk#30]
Input [5]: [item_sk#28, d_date#24, sumss#29, ss_item_sk#20, rk#30]

(40) Exchange
Input [4]: [item_sk#28, d_date#24, sumss#29, rk#30]
Arguments: hashpartitioning(item_sk#28, 5), ENSURE_REQUIREMENTS, [plan_id=8]

(41) Sort [codegen id : 20]
Input [4]: [item_sk#28, d_date#24, sumss#29, rk#30]
Arguments: [item_sk#28 ASC NULLS FIRST], false, 0

(42) ReusedExchange [Reuses operator id: 36]
Output [4]: [item_sk#31, d_date#32, sumss#33, ss_item_sk#34]

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

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

(45) Project [codegen id : 25]
Output [3]: [item_sk#31, sumss#33, rk#35]
Input [5]: [item_sk#31, d_date#32, sumss#33, ss_item_sk#34, rk#35]

(46) Exchange
Input [3]: [item_sk#31, sumss#33, rk#35]
Arguments: hashpartitioning(item_sk#31, 5), ENSURE_REQUIREMENTS, [plan_id=9]

(47) Sort [codegen id : 26]
Input [3]: [item_sk#31, sumss#33, rk#35]
Arguments: [item_sk#31 ASC NULLS FIRST], false, 0

(48) SortMergeJoin [codegen id : 27]
Left keys [1]: [item_sk#28]
Right keys [1]: [item_sk#31]
Join type: Inner
Join condition: (rk#30 >= rk#35)

(49) Project [codegen id : 27]
Output [4]: [item_sk#28, d_date#24, sumss#29, sumss#33]
Input [7]: [item_sk#28, d_date#24, sumss#29, rk#30, item_sk#31, sumss#33, rk#35]

(50) HashAggregate [codegen id : 27]
Input [4]: [item_sk#28, d_date#24, sumss#29, sumss#33]
Keys [3]: [item_sk#28, d_date#24, sumss#29]
Functions [1]: [sum(sumss#33)]
Aggregate Attributes [1]: [sum(sumss#33)#36]
Results [3]: [item_sk#28, d_date#24, sum(sumss#33)#36 AS cume_sales#37]

(51) Exchange
Input [3]: [item_sk#28, d_date#24, cume_sales#37]
Arguments: hashpartitioning(item_sk#28, d_date#24, 5), ENSURE_REQUIREMENTS, [plan_id=10]

(52) Sort [codegen id : 28]
Input [3]: [item_sk#28, d_date#24, cume_sales#37]
Arguments: [item_sk#28 ASC NULLS FIRST, d_date#24 ASC NULLS FIRST], false, 0

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

(54) Filter [codegen id : 29]
Input [6]: [item_sk#10, d_date#6, cume_sales#19, item_sk#28, d_date#24, cume_sales#37]
Condition : isnotnull(CASE WHEN isnotnull(item_sk#10) THEN item_sk#10 ELSE item_sk#28 END)

(55) Project [codegen id : 29]
Output [4]: [CASE WHEN isnotnull(item_sk#10) THEN item_sk#10 ELSE item_sk#28 END AS item_sk#38, CASE WHEN isnotnull(d_date#6) THEN d_date#6 ELSE d_date#24 END AS d_date#39, cume_sales#19 AS web_sales#40, cume_sales#37 AS store_sales#41]
Input [6]: [item_sk#10, d_date#6, cume_sales#19, item_sk#28, d_date#24, cume_sales#37]

(56) Exchange
Input [4]: [item_sk#38, d_date#39, web_sales#40, store_sales#41]
Arguments: hashpartitioning(item_sk#38, 5), ENSURE_REQUIREMENTS, [plan_id=11]

(57) Sort [codegen id : 30]
Input [4]: [item_sk#38, d_date#39, web_sales#40, store_sales#41]
Arguments: [item_sk#38 ASC NULLS FIRST, d_date#39 ASC NULLS FIRST], false, 0

(58) Window
Input [4]: [item_sk#38, d_date#39, web_sales#40, store_sales#41]
Arguments: [row_number() windowspecdefinition(item_sk#38, d_date#39 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#42], [item_sk#38], [d_date#39 ASC NULLS FIRST]

(59) ReusedExchange [Reuses operator id: 56]
Output [4]: [item_sk#43, d_date#44, web_sales#45, store_sales#46]

(60) Sort [codegen id : 60]
Input [4]: [item_sk#43, d_date#44, web_sales#45, store_sales#46]
Arguments: [item_sk#43 ASC NULLS FIRST, d_date#44 ASC NULLS FIRST], false, 0

(61) Window
Input [4]: [item_sk#43, d_date#44, web_sales#45, store_sales#46]
Arguments: [row_number() windowspecdefinition(item_sk#43, d_date#44 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#47], [item_sk#43], [d_date#44 ASC NULLS FIRST]

(62) Project [codegen id : 61]
Output [4]: [item_sk#43, web_sales#45, store_sales#46, rk#47]
Input [5]: [item_sk#43, d_date#44, web_sales#45, store_sales#46, rk#47]

(63) SortMergeJoin [codegen id : 62]
Left keys [1]: [item_sk#38]
Right keys [1]: [item_sk#43]
Join type: Inner
Join condition: (rk#42 >= rk#47)

(64) Project [codegen id : 62]
Output [6]: [item_sk#38, d_date#39, web_sales#40, store_sales#41, web_sales#45, store_sales#46]
Input [9]: [item_sk#38, d_date#39, web_sales#40, store_sales#41, rk#42, item_sk#43, web_sales#45, store_sales#46, rk#47]

(65) HashAggregate [codegen id : 62]
Input [6]: [item_sk#38, d_date#39, web_sales#40, store_sales#41, web_sales#45, store_sales#46]
Keys [4]: [item_sk#38, d_date#39, web_sales#40, store_sales#41]
Functions [2]: [max(web_sales#45), max(store_sales#46)]
Aggregate Attributes [2]: [max(web_sales#45)#48, max(store_sales#46)#49]
Results [6]: [item_sk#38, d_date#39, web_sales#40, store_sales#41, max(web_sales#45)#48 AS web_cumulative#50, max(store_sales#46)#49 AS store_cumulative#51]

(66) Filter [codegen id : 62]
Input [6]: [item_sk#38, d_date#39, web_sales#40, store_sales#41, web_cumulative#50, store_cumulative#51]
Condition : ((isnotnull(web_cumulative#50) AND isnotnull(store_cumulative#51)) AND (web_cumulative#50 > store_cumulative#51))

(67) TakeOrderedAndProject
Input [6]: [item_sk#38, d_date#39, web_sales#40, store_sales#41, web_cumulative#50, store_cumulative#51]
Arguments: 100, [item_sk#38 ASC NULLS FIRST, d_date#39 ASC NULLS FIRST], [item_sk#38, d_date#39, web_sales#40, store_sales#41, web_cumulative#50, store_cumulative#51]

===== Subqueries =====

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


(68) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_date_sk#5, d_date#6, d_month_seq#52]
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>

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

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

(71) 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#52]

(72) 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 = 27 Hosting Expression = ss_sold_date_sk#22 IN dynamicpruning#4


