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


(1) Scan parquet default.web_sales
Output [3]: [ws_sold_date_sk#1, ws_item_sk#2, ws_sales_price#3]
Batched: true
Location [not included in comparison]/{warehouse_dir}/web_sales]
PushedFilters: [IsNotNull(ws_item_sk), IsNotNull(ws_sold_date_sk)]
ReadSchema: struct<ws_sold_date_sk:int,ws_item_sk:int,ws_sales_price:decimal(7,2)>

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

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

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

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

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

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

(8) BroadcastExchange
Input [2]: [d_date_sk#4, d_date#5]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#7]

(9) BroadcastHashJoin [codegen id : 2]
Left keys [1]: [ws_sold_date_sk#1]
Right keys [1]: [d_date_sk#4]
Join condition: None

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

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

(12) Exchange
Input [3]: [ws_item_sk#2, d_date#5, sum#9]
Arguments: hashpartitioning(ws_item_sk#2, d_date#5, 5), true, [id=#10]

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

(14) Exchange
Input [4]: [item_sk#12, d_date#5, sumws#13, ws_item_sk#2]
Arguments: hashpartitioning(ws_item_sk#2, 5), true, [id=#14]

(15) Sort [codegen id : 4]
Input [4]: [item_sk#12, d_date#5, sumws#13, ws_item_sk#2]
Arguments: [ws_item_sk#2 ASC NULLS FIRST, d_date#5 ASC NULLS FIRST], false, 0

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

(17) Filter [codegen id : 5]
Input [5]: [item_sk#12, d_date#5, sumws#13, ws_item_sk#2, rk#15]
Condition : isnotnull(rk#15)

(18) Project [codegen id : 5]
Output [4]: [item_sk#12, d_date#5, sumws#13, rk#15]
Input [5]: [item_sk#12, d_date#5, sumws#13, ws_item_sk#2, rk#15]

(19) Exchange
Input [4]: [item_sk#12, d_date#5, sumws#13, rk#15]
Arguments: hashpartitioning(item_sk#12, 5), true, [id=#16]

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

(21) ReusedExchange [Reuses operator id: 14]
Output [4]: [item_sk#17, d_date#18, sumws#19, ws_item_sk#2]

(22) Sort [codegen id : 10]
Input [4]: [item_sk#17, d_date#18, sumws#19, ws_item_sk#2]
Arguments: [ws_item_sk#2 ASC NULLS FIRST, d_date#18 ASC NULLS FIRST], false, 0

(23) Window
Input [4]: [item_sk#17, d_date#18, sumws#19, ws_item_sk#2]
Arguments: [row_number() windowspecdefinition(ws_item_sk#2, d_date#18 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#20], [ws_item_sk#2], [d_date#18 ASC NULLS FIRST]

(24) Filter [codegen id : 11]
Input [5]: [item_sk#17, d_date#18, sumws#19, ws_item_sk#2, rk#20]
Condition : isnotnull(rk#20)

(25) Project [codegen id : 11]
Output [3]: [item_sk#17, sumws#19, rk#20]
Input [5]: [item_sk#17, d_date#18, sumws#19, ws_item_sk#2, rk#20]

(26) Exchange
Input [3]: [item_sk#17, sumws#19, rk#20]
Arguments: hashpartitioning(item_sk#17, 5), true, [id=#21]

(27) Sort [codegen id : 12]
Input [3]: [item_sk#17, sumws#19, rk#20]
Arguments: [item_sk#17 ASC NULLS FIRST], false, 0

(28) SortMergeJoin [codegen id : 13]
Left keys [1]: [item_sk#12]
Right keys [1]: [item_sk#17]
Join condition: (rk#15 >= rk#20)

(29) Project [codegen id : 13]
Output [4]: [item_sk#12, d_date#5, sumws#13, sumws#19]
Input [7]: [item_sk#12, d_date#5, sumws#13, rk#15, item_sk#17, sumws#19, rk#20]

(30) HashAggregate [codegen id : 13]
Input [4]: [item_sk#12, d_date#5, sumws#13, sumws#19]
Keys [3]: [item_sk#12, d_date#5, sumws#13]
Functions [1]: [partial_sum(sumws#19)]
Aggregate Attributes [2]: [sum#22, isEmpty#23]
Results [5]: [item_sk#12, d_date#5, sumws#13, sum#24, isEmpty#25]

(31) HashAggregate [codegen id : 13]
Input [5]: [item_sk#12, d_date#5, sumws#13, sum#24, isEmpty#25]
Keys [3]: [item_sk#12, d_date#5, sumws#13]
Functions [1]: [sum(sumws#19)]
Aggregate Attributes [1]: [sum(sumws#19)#26]
Results [3]: [item_sk#12, d_date#5, sum(sumws#19)#26 AS cume_sales#27]

(32) Exchange
Input [3]: [item_sk#12, d_date#5, cume_sales#27]
Arguments: hashpartitioning(item_sk#12, d_date#5, 5), true, [id=#28]

(33) Sort [codegen id : 14]
Input [3]: [item_sk#12, d_date#5, cume_sales#27]
Arguments: [item_sk#12 ASC NULLS FIRST, d_date#5 ASC NULLS FIRST], false, 0

(34) Scan parquet default.store_sales
Output [3]: [ss_sold_date_sk#29, ss_item_sk#30, ss_sales_price#31]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store_sales]
PushedFilters: [IsNotNull(ss_item_sk), IsNotNull(ss_sold_date_sk)]
ReadSchema: struct<ss_sold_date_sk:int,ss_item_sk:int,ss_sales_price:decimal(7,2)>

(35) ColumnarToRow [codegen id : 16]
Input [3]: [ss_sold_date_sk#29, ss_item_sk#30, ss_sales_price#31]

(36) Filter [codegen id : 16]
Input [3]: [ss_sold_date_sk#29, ss_item_sk#30, ss_sales_price#31]
Condition : (isnotnull(ss_item_sk#30) AND isnotnull(ss_sold_date_sk#29))

(37) ReusedExchange [Reuses operator id: 8]
Output [2]: [d_date_sk#32, d_date#33]

(38) BroadcastHashJoin [codegen id : 16]
Left keys [1]: [ss_sold_date_sk#29]
Right keys [1]: [d_date_sk#32]
Join condition: None

(39) Project [codegen id : 16]
Output [3]: [ss_item_sk#30, ss_sales_price#31, d_date#33]
Input [5]: [ss_sold_date_sk#29, ss_item_sk#30, ss_sales_price#31, d_date_sk#32, d_date#33]

(40) HashAggregate [codegen id : 16]
Input [3]: [ss_item_sk#30, ss_sales_price#31, d_date#33]
Keys [2]: [ss_item_sk#30, d_date#33]
Functions [1]: [partial_sum(UnscaledValue(ss_sales_price#31))]
Aggregate Attributes [1]: [sum#34]
Results [3]: [ss_item_sk#30, d_date#33, sum#35]

(41) Exchange
Input [3]: [ss_item_sk#30, d_date#33, sum#35]
Arguments: hashpartitioning(ss_item_sk#30, d_date#33, 5), true, [id=#36]

(42) HashAggregate [codegen id : 17]
Input [3]: [ss_item_sk#30, d_date#33, sum#35]
Keys [2]: [ss_item_sk#30, d_date#33]
Functions [1]: [sum(UnscaledValue(ss_sales_price#31))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_sales_price#31))#37]
Results [4]: [ss_item_sk#30 AS item_sk#38, d_date#33, MakeDecimal(sum(UnscaledValue(ss_sales_price#31))#37,17,2) AS sumss#39, ss_item_sk#30]

(43) Exchange
Input [4]: [item_sk#38, d_date#33, sumss#39, ss_item_sk#30]
Arguments: hashpartitioning(ss_item_sk#30, 5), true, [id=#40]

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

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

(46) Filter [codegen id : 19]
Input [5]: [item_sk#38, d_date#33, sumss#39, ss_item_sk#30, rk#41]
Condition : isnotnull(rk#41)

(47) Project [codegen id : 19]
Output [4]: [item_sk#38, d_date#33, sumss#39, rk#41]
Input [5]: [item_sk#38, d_date#33, sumss#39, ss_item_sk#30, rk#41]

(48) Exchange
Input [4]: [item_sk#38, d_date#33, sumss#39, rk#41]
Arguments: hashpartitioning(item_sk#38, 5), true, [id=#42]

(49) Sort [codegen id : 20]
Input [4]: [item_sk#38, d_date#33, sumss#39, rk#41]
Arguments: [item_sk#38 ASC NULLS FIRST], false, 0

(50) ReusedExchange [Reuses operator id: 43]
Output [4]: [item_sk#43, d_date#44, sumss#45, ss_item_sk#30]

(51) Sort [codegen id : 24]
Input [4]: [item_sk#43, d_date#44, sumss#45, ss_item_sk#30]
Arguments: [ss_item_sk#30 ASC NULLS FIRST, d_date#44 ASC NULLS FIRST], false, 0

(52) Window
Input [4]: [item_sk#43, d_date#44, sumss#45, ss_item_sk#30]
Arguments: [row_number() windowspecdefinition(ss_item_sk#30, d_date#44 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#46], [ss_item_sk#30], [d_date#44 ASC NULLS FIRST]

(53) Filter [codegen id : 25]
Input [5]: [item_sk#43, d_date#44, sumss#45, ss_item_sk#30, rk#46]
Condition : isnotnull(rk#46)

(54) Project [codegen id : 25]
Output [3]: [item_sk#43, sumss#45, rk#46]
Input [5]: [item_sk#43, d_date#44, sumss#45, ss_item_sk#30, rk#46]

(55) Exchange
Input [3]: [item_sk#43, sumss#45, rk#46]
Arguments: hashpartitioning(item_sk#43, 5), true, [id=#47]

(56) Sort [codegen id : 26]
Input [3]: [item_sk#43, sumss#45, rk#46]
Arguments: [item_sk#43 ASC NULLS FIRST], false, 0

(57) SortMergeJoin [codegen id : 27]
Left keys [1]: [item_sk#38]
Right keys [1]: [item_sk#43]
Join condition: (rk#41 >= rk#46)

(58) Project [codegen id : 27]
Output [4]: [item_sk#38, d_date#33, sumss#39, sumss#45]
Input [7]: [item_sk#38, d_date#33, sumss#39, rk#41, item_sk#43, sumss#45, rk#46]

(59) HashAggregate [codegen id : 27]
Input [4]: [item_sk#38, d_date#33, sumss#39, sumss#45]
Keys [3]: [item_sk#38, d_date#33, sumss#39]
Functions [1]: [partial_sum(sumss#45)]
Aggregate Attributes [2]: [sum#48, isEmpty#49]
Results [5]: [item_sk#38, d_date#33, sumss#39, sum#50, isEmpty#51]

(60) HashAggregate [codegen id : 27]
Input [5]: [item_sk#38, d_date#33, sumss#39, sum#50, isEmpty#51]
Keys [3]: [item_sk#38, d_date#33, sumss#39]
Functions [1]: [sum(sumss#45)]
Aggregate Attributes [1]: [sum(sumss#45)#52]
Results [3]: [item_sk#38, d_date#33, sum(sumss#45)#52 AS cume_sales#53]

(61) Exchange
Input [3]: [item_sk#38, d_date#33, cume_sales#53]
Arguments: hashpartitioning(item_sk#38, d_date#33, 5), true, [id=#54]

(62) Sort [codegen id : 28]
Input [3]: [item_sk#38, d_date#33, cume_sales#53]
Arguments: [item_sk#38 ASC NULLS FIRST, d_date#33 ASC NULLS FIRST], false, 0

(63) SortMergeJoin
Left keys [2]: [item_sk#12, d_date#5]
Right keys [2]: [item_sk#38, d_date#33]
Join condition: None

(64) Filter [codegen id : 29]
Input [6]: [item_sk#12, d_date#5, cume_sales#27, item_sk#38, d_date#33, cume_sales#53]
Condition : isnotnull(CASE WHEN isnotnull(item_sk#12) THEN item_sk#12 ELSE item_sk#38 END)

(65) Project [codegen id : 29]
Output [4]: [CASE WHEN isnotnull(item_sk#12) THEN item_sk#12 ELSE item_sk#38 END AS item_sk#55, CASE WHEN isnotnull(d_date#5) THEN d_date#5 ELSE d_date#33 END AS d_date#56, cume_sales#27 AS web_sales#57, cume_sales#53 AS store_sales#58]
Input [6]: [item_sk#12, d_date#5, cume_sales#27, item_sk#38, d_date#33, cume_sales#53]

(66) Exchange
Input [4]: [item_sk#55, d_date#56, web_sales#57, store_sales#58]
Arguments: hashpartitioning(item_sk#55, 5), true, [id=#59]

(67) Sort [codegen id : 30]
Input [4]: [item_sk#55, d_date#56, web_sales#57, store_sales#58]
Arguments: [item_sk#55 ASC NULLS FIRST, d_date#56 ASC NULLS FIRST], false, 0

(68) Window
Input [4]: [item_sk#55, d_date#56, web_sales#57, store_sales#58]
Arguments: [row_number() windowspecdefinition(item_sk#55, d_date#56 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#60], [item_sk#55], [d_date#56 ASC NULLS FIRST]

(69) Filter [codegen id : 31]
Input [5]: [item_sk#55, d_date#56, web_sales#57, store_sales#58, rk#60]
Condition : isnotnull(rk#60)

(70) ReusedExchange [Reuses operator id: 66]
Output [4]: [item_sk#61, d_date#62, web_sales#63, store_sales#64]

(71) Sort [codegen id : 61]
Input [4]: [item_sk#61, d_date#62, web_sales#63, store_sales#64]
Arguments: [item_sk#61 ASC NULLS FIRST, d_date#62 ASC NULLS FIRST], false, 0

(72) Window
Input [4]: [item_sk#61, d_date#62, web_sales#63, store_sales#64]
Arguments: [row_number() windowspecdefinition(item_sk#61, d_date#62 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rk#65], [item_sk#61], [d_date#62 ASC NULLS FIRST]

(73) Filter [codegen id : 62]
Input [5]: [item_sk#61, d_date#62, web_sales#63, store_sales#64, rk#65]
Condition : isnotnull(rk#65)

(74) Project [codegen id : 62]
Output [4]: [item_sk#61, web_sales#63, store_sales#64, rk#65]
Input [5]: [item_sk#61, d_date#62, web_sales#63, store_sales#64, rk#65]

(75) SortMergeJoin [codegen id : 63]
Left keys [1]: [item_sk#55]
Right keys [1]: [item_sk#61]
Join condition: (rk#60 >= rk#65)

(76) Project [codegen id : 63]
Output [6]: [item_sk#55, d_date#56, web_sales#57, store_sales#58, web_sales#63, store_sales#64]
Input [9]: [item_sk#55, d_date#56, web_sales#57, store_sales#58, rk#60, item_sk#61, web_sales#63, store_sales#64, rk#65]

(77) HashAggregate [codegen id : 63]
Input [6]: [item_sk#55, d_date#56, web_sales#57, store_sales#58, web_sales#63, store_sales#64]
Keys [4]: [item_sk#55, d_date#56, web_sales#57, store_sales#58]
Functions [2]: [partial_max(web_sales#63), partial_max(store_sales#64)]
Aggregate Attributes [2]: [max#66, max#67]
Results [6]: [item_sk#55, d_date#56, web_sales#57, store_sales#58, max#68, max#69]

(78) HashAggregate [codegen id : 63]
Input [6]: [item_sk#55, d_date#56, web_sales#57, store_sales#58, max#68, max#69]
Keys [4]: [item_sk#55, d_date#56, web_sales#57, store_sales#58]
Functions [2]: [max(web_sales#63), max(store_sales#64)]
Aggregate Attributes [2]: [max(web_sales#63)#70, max(store_sales#64)#71]
Results [6]: [item_sk#55, d_date#56, web_sales#57, store_sales#58, max(web_sales#63)#70 AS web_cumulative#72, max(store_sales#64)#71 AS store_cumulative#73]

(79) Filter [codegen id : 63]
Input [6]: [item_sk#55, d_date#56, web_sales#57, store_sales#58, web_cumulative#72, store_cumulative#73]
Condition : ((isnotnull(web_cumulative#72) AND isnotnull(store_cumulative#73)) AND (web_cumulative#72 > store_cumulative#73))

(80) TakeOrderedAndProject
Input [6]: [item_sk#55, d_date#56, web_sales#57, store_sales#58, web_cumulative#72, store_cumulative#73]
Arguments: 100, [item_sk#55 ASC NULLS FIRST, d_date#56 ASC NULLS FIRST], [item_sk#55, d_date#56, web_sales#57, store_sales#58, web_cumulative#72, store_cumulative#73]

