== Physical Plan ==
TakeOrderedAndProject (38)
+- * Project (37)
   +- Window (36)
      +- * Sort (35)
         +- Exchange (34)
            +- * HashAggregate (33)
               +- Exchange (32)
                  +- * HashAggregate (31)
                     +- Union (30)
                        :- * HashAggregate (19)
                        :  +- Exchange (18)
                        :     +- * HashAggregate (17)
                        :        +- * Project (16)
                        :           +- * BroadcastHashJoin Inner BuildRight (15)
                        :              :- * Project (10)
                        :              :  +- * BroadcastHashJoin Inner BuildRight (9)
                        :              :     :- * Filter (3)
                        :              :     :  +- * ColumnarToRow (2)
                        :              :     :     +- Scan parquet spark_catalog.default.web_sales (1)
                        :              :     +- BroadcastExchange (8)
                        :              :        +- * Project (7)
                        :              :           +- * Filter (6)
                        :              :              +- * ColumnarToRow (5)
                        :              :                 +- Scan parquet spark_catalog.default.date_dim (4)
                        :              +- BroadcastExchange (14)
                        :                 +- * Filter (13)
                        :                    +- * ColumnarToRow (12)
                        :                       +- Scan parquet spark_catalog.default.item (11)
                        :- * HashAggregate (24)
                        :  +- Exchange (23)
                        :     +- * HashAggregate (22)
                        :        +- * HashAggregate (21)
                        :           +- ReusedExchange (20)
                        +- * HashAggregate (29)
                           +- Exchange (28)
                              +- * HashAggregate (27)
                                 +- * HashAggregate (26)
                                    +- ReusedExchange (25)


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

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

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

(4) Scan parquet spark_catalog.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), [plan_id=1]

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

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

(11) Scan parquet spark_catalog.default.item
Output [3]: [i_item_sk#6, i_class#7, i_category#8]
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#6, i_class#7, i_category#8]

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

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

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

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

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

(18) Exchange
Input [3]: [i_category#8, i_class#7, sum#10]
Arguments: hashpartitioning(i_category#8, i_class#7, 5), ENSURE_REQUIREMENTS, [plan_id=3]

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

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

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

(22) HashAggregate [codegen id : 8]
Input [2]: [total_sum#17, i_category#8]
Keys [1]: [i_category#8]
Functions [1]: [partial_sum(total_sum#17)]
Aggregate Attributes [2]: [sum#18, isEmpty#19]
Results [3]: [i_category#8, sum#20, isEmpty#21]

(23) Exchange
Input [3]: [i_category#8, sum#20, isEmpty#21]
Arguments: hashpartitioning(i_category#8, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(24) HashAggregate [codegen id : 9]
Input [3]: [i_category#8, sum#20, isEmpty#21]
Keys [1]: [i_category#8]
Functions [1]: [sum(total_sum#17)]
Aggregate Attributes [1]: [sum(total_sum#17)#22]
Results [6]: [sum(total_sum#17)#22 AS total_sum#23, i_category#8, null AS i_class#24, 0 AS g_category#25, 1 AS g_class#26, 1 AS lochierarchy#27]

(25) ReusedExchange [Reuses operator id: 18]
Output [3]: [i_category#8, i_class#7, sum#28]

(26) HashAggregate [codegen id : 13]
Input [3]: [i_category#8, i_class#7, sum#28]
Keys [2]: [i_category#8, i_class#7]
Functions [1]: [sum(UnscaledValue(ws_net_paid#2))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_net_paid#2))#11]
Results [1]: [MakeDecimal(sum(UnscaledValue(ws_net_paid#2))#11,17,2) AS total_sum#17]

(27) HashAggregate [codegen id : 13]
Input [1]: [total_sum#17]
Keys: []
Functions [1]: [partial_sum(total_sum#17)]
Aggregate Attributes [2]: [sum#29, isEmpty#30]
Results [2]: [sum#31, isEmpty#32]

(28) Exchange
Input [2]: [sum#31, isEmpty#32]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, [plan_id=5]

(29) HashAggregate [codegen id : 14]
Input [2]: [sum#31, isEmpty#32]
Keys: []
Functions [1]: [sum(total_sum#17)]
Aggregate Attributes [1]: [sum(total_sum#17)#33]
Results [6]: [sum(total_sum#17)#33 AS total_sum#34, null AS i_category#35, null AS i_class#36, 1 AS g_category#37, 1 AS g_class#38, 2 AS lochierarchy#39]

(30) Union

(31) HashAggregate [codegen id : 15]
Input [6]: [total_sum#12, i_category#8, i_class#7, g_category#13, g_class#14, lochierarchy#15]
Keys [6]: [total_sum#12, i_category#8, i_class#7, g_category#13, g_class#14, lochierarchy#15]
Functions: []
Aggregate Attributes: []
Results [6]: [total_sum#12, i_category#8, i_class#7, g_category#13, g_class#14, lochierarchy#15]

(32) Exchange
Input [6]: [total_sum#12, i_category#8, i_class#7, g_category#13, g_class#14, lochierarchy#15]
Arguments: hashpartitioning(total_sum#12, i_category#8, i_class#7, g_category#13, g_class#14, lochierarchy#15, 5), ENSURE_REQUIREMENTS, [plan_id=6]

(33) HashAggregate [codegen id : 16]
Input [6]: [total_sum#12, i_category#8, i_class#7, g_category#13, g_class#14, lochierarchy#15]
Keys [6]: [total_sum#12, i_category#8, i_class#7, g_category#13, g_class#14, lochierarchy#15]
Functions: []
Aggregate Attributes: []
Results [5]: [total_sum#12, i_category#8, i_class#7, lochierarchy#15, CASE WHEN (g_class#14 = 0) THEN i_category#8 END AS _w0#40]

(34) Exchange
Input [5]: [total_sum#12, i_category#8, i_class#7, lochierarchy#15, _w0#40]
Arguments: hashpartitioning(lochierarchy#15, _w0#40, 5), ENSURE_REQUIREMENTS, [plan_id=7]

(35) Sort [codegen id : 17]
Input [5]: [total_sum#12, i_category#8, i_class#7, lochierarchy#15, _w0#40]
Arguments: [lochierarchy#15 ASC NULLS FIRST, _w0#40 ASC NULLS FIRST, total_sum#12 DESC NULLS LAST], false, 0

(36) Window
Input [5]: [total_sum#12, i_category#8, i_class#7, lochierarchy#15, _w0#40]
Arguments: [rank(total_sum#12) windowspecdefinition(lochierarchy#15, _w0#40, total_sum#12 DESC NULLS LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rank_within_parent#41], [lochierarchy#15, _w0#40], [total_sum#12 DESC NULLS LAST]

(37) Project [codegen id : 18]
Output [5]: [total_sum#12, i_category#8, i_class#7, lochierarchy#15, rank_within_parent#41]
Input [6]: [total_sum#12, i_category#8, i_class#7, lochierarchy#15, _w0#40, rank_within_parent#41]

(38) TakeOrderedAndProject
Input [5]: [total_sum#12, i_category#8, i_class#7, lochierarchy#15, rank_within_parent#41]
Arguments: 100, [lochierarchy#15 DESC NULLS LAST, CASE WHEN (lochierarchy#15 = 0) THEN i_category#8 END ASC NULLS FIRST, rank_within_parent#41 ASC NULLS FIRST], [total_sum#12, i_category#8, i_class#7, lochierarchy#15, rank_within_parent#41]

