== Physical Plan ==
TakeOrderedAndProject (42)
+- * Project (41)
   +- Window (40)
      +- * Sort (39)
         +- Exchange (38)
            +- * HashAggregate (37)
               +- Exchange (36)
                  +- * HashAggregate (35)
                     +- Union (34)
                        :- * HashAggregate (28)
                        :  +- Exchange (27)
                        :     +- * HashAggregate (26)
                        :        +- Union (25)
                        :           :- * HashAggregate (19)
                        :           :  +- Exchange (18)
                        :           :     +- * HashAggregate (17)
                        :           :        +- * Project (16)
                        :           :           +- * BroadcastHashJoin Inner BuildRight (15)
                        :           :              :- * 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)
                        :           :              +- BroadcastExchange (14)
                        :           :                 +- * Filter (13)
                        :           :                    +- * ColumnarToRow (12)
                        :           :                       +- Scan parquet default.item (11)
                        :           +- * HashAggregate (24)
                        :              +- Exchange (23)
                        :                 +- * HashAggregate (22)
                        :                    +- * HashAggregate (21)
                        :                       +- ReusedExchange (20)
                        +- * HashAggregate (33)
                           +- Exchange (32)
                              +- * HashAggregate (31)
                                 +- * HashAggregate (30)
                                    +- ReusedExchange (29)


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

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

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

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

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

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

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

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

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

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

(11) Scan parquet default.item
Output [3]: [i_item_sk#7, i_class#8, i_category#9]
Batched: true
Location [not included in comparison]/{warehouse_dir}/item]
PushedFilters: [IsNotNull(i_item_sk)]
ReadSchema: struct<i_item_sk:int,i_class:string,i_category:string>

(12) ColumnarToRow [codegen id : 2]
Input [3]: [i_item_sk#7, i_class#8, i_category#9]

(13) Filter [codegen id : 2]
Input [3]: [i_item_sk#7, i_class#8, i_category#9]
Condition : isnotnull(i_item_sk#7)

(14) BroadcastExchange
Input [3]: [i_item_sk#7, i_class#8, i_category#9]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#10]

(15) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [ws_item_sk#2]
Right keys [1]: [i_item_sk#7]
Join condition: None

(16) Project [codegen id : 3]
Output [3]: [ws_net_paid#3, i_class#8, i_category#9]
Input [5]: [ws_item_sk#2, ws_net_paid#3, i_item_sk#7, i_class#8, i_category#9]

(17) HashAggregate [codegen id : 3]
Input [3]: [ws_net_paid#3, i_class#8, i_category#9]
Keys [2]: [i_category#9, i_class#8]
Functions [1]: [partial_sum(UnscaledValue(ws_net_paid#3))]
Aggregate Attributes [1]: [sum#11]
Results [3]: [i_category#9, i_class#8, sum#12]

(18) Exchange
Input [3]: [i_category#9, i_class#8, sum#12]
Arguments: hashpartitioning(i_category#9, i_class#8, 5), true, [id=#13]

(19) HashAggregate [codegen id : 4]
Input [3]: [i_category#9, i_class#8, sum#12]
Keys [2]: [i_category#9, i_class#8]
Functions [1]: [sum(UnscaledValue(ws_net_paid#3))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_net_paid#3))#14]
Results [6]: [cast(MakeDecimal(sum(UnscaledValue(ws_net_paid#3))#14,17,2) as decimal(27,2)) AS total_sum#15, i_category#9, i_class#8, 0 AS g_category#16, 0 AS g_class#17, 0 AS lochierarchy#18]

(20) ReusedExchange [Reuses operator id: 18]
Output [3]: [i_category#9, i_class#8, sum#19]

(21) HashAggregate [codegen id : 8]
Input [3]: [i_category#9, i_class#8, sum#19]
Keys [2]: [i_category#9, i_class#8]
Functions [1]: [sum(UnscaledValue(ws_net_paid#3))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_net_paid#3))#20]
Results [2]: [MakeDecimal(sum(UnscaledValue(ws_net_paid#3))#20,17,2) AS total_sum#21, i_category#9]

(22) HashAggregate [codegen id : 8]
Input [2]: [total_sum#21, i_category#9]
Keys [1]: [i_category#9]
Functions [1]: [partial_sum(total_sum#21)]
Aggregate Attributes [2]: [sum#22, isEmpty#23]
Results [3]: [i_category#9, sum#24, isEmpty#25]

(23) Exchange
Input [3]: [i_category#9, sum#24, isEmpty#25]
Arguments: hashpartitioning(i_category#9, 5), true, [id=#26]

(24) HashAggregate [codegen id : 9]
Input [3]: [i_category#9, sum#24, isEmpty#25]
Keys [1]: [i_category#9]
Functions [1]: [sum(total_sum#21)]
Aggregate Attributes [1]: [sum(total_sum#21)#27]
Results [6]: [sum(total_sum#21)#27 AS total_sum#28, i_category#9, null AS i_class#29, 0 AS g_category#30, 1 AS g_class#31, 1 AS lochierarchy#32]

(25) Union

(26) HashAggregate [codegen id : 10]
Input [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]
Keys [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]
Functions: []
Aggregate Attributes: []
Results [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]

(27) Exchange
Input [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]
Arguments: hashpartitioning(total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18, 5), true, [id=#33]

(28) HashAggregate [codegen id : 11]
Input [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]
Keys [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]
Functions: []
Aggregate Attributes: []
Results [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]

(29) ReusedExchange [Reuses operator id: 18]
Output [3]: [i_category#9, i_class#8, sum#34]

(30) HashAggregate [codegen id : 15]
Input [3]: [i_category#9, i_class#8, sum#34]
Keys [2]: [i_category#9, i_class#8]
Functions [1]: [sum(UnscaledValue(ws_net_paid#3))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_net_paid#3))#35]
Results [1]: [MakeDecimal(sum(UnscaledValue(ws_net_paid#3))#35,17,2) AS total_sum#21]

(31) HashAggregate [codegen id : 15]
Input [1]: [total_sum#21]
Keys: []
Functions [1]: [partial_sum(total_sum#21)]
Aggregate Attributes [2]: [sum#36, isEmpty#37]
Results [2]: [sum#38, isEmpty#39]

(32) Exchange
Input [2]: [sum#38, isEmpty#39]
Arguments: SinglePartition, true, [id=#40]

(33) HashAggregate [codegen id : 16]
Input [2]: [sum#38, isEmpty#39]
Keys: []
Functions [1]: [sum(total_sum#21)]
Aggregate Attributes [1]: [sum(total_sum#21)#41]
Results [6]: [sum(total_sum#21)#41 AS total_sum#42, null AS i_category#43, null AS i_class#44, 1 AS g_category#45, 1 AS g_class#46, 2 AS lochierarchy#47]

(34) Union

(35) HashAggregate [codegen id : 17]
Input [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]
Keys [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]
Functions: []
Aggregate Attributes: []
Results [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]

(36) Exchange
Input [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]
Arguments: hashpartitioning(total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18, 5), true, [id=#48]

(37) HashAggregate [codegen id : 18]
Input [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]
Keys [6]: [total_sum#15, i_category#9, i_class#8, g_category#16, g_class#17, lochierarchy#18]
Functions: []
Aggregate Attributes: []
Results [5]: [total_sum#15, i_category#9, i_class#8, lochierarchy#18, CASE WHEN (g_class#17 = 0) THEN i_category#9 END AS _w0#49]

(38) Exchange
Input [5]: [total_sum#15, i_category#9, i_class#8, lochierarchy#18, _w0#49]
Arguments: hashpartitioning(lochierarchy#18, _w0#49, 5), true, [id=#50]

(39) Sort [codegen id : 19]
Input [5]: [total_sum#15, i_category#9, i_class#8, lochierarchy#18, _w0#49]
Arguments: [lochierarchy#18 ASC NULLS FIRST, _w0#49 ASC NULLS FIRST, total_sum#15 DESC NULLS LAST], false, 0

(40) Window
Input [5]: [total_sum#15, i_category#9, i_class#8, lochierarchy#18, _w0#49]
Arguments: [rank(total_sum#15) windowspecdefinition(lochierarchy#18, _w0#49, total_sum#15 DESC NULLS LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rank_within_parent#51], [lochierarchy#18, _w0#49], [total_sum#15 DESC NULLS LAST]

(41) Project [codegen id : 20]
Output [5]: [total_sum#15, i_category#9, i_class#8, lochierarchy#18, rank_within_parent#51]
Input [6]: [total_sum#15, i_category#9, i_class#8, lochierarchy#18, _w0#49, rank_within_parent#51]

(42) TakeOrderedAndProject
Input [5]: [total_sum#15, i_category#9, i_class#8, lochierarchy#18, rank_within_parent#51]
Arguments: 100, [lochierarchy#18 DESC NULLS LAST, CASE WHEN (lochierarchy#18 = 0) THEN i_category#9 END ASC NULLS FIRST, rank_within_parent#51 ASC NULLS FIRST], [total_sum#15, i_category#9, i_class#8, lochierarchy#18, rank_within_parent#51]

