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


(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), dynamicpruningexpression(ws_sold_date_sk#3 IN dynamicpruning#4)]
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) ReusedExchange [Reuses operator id: 39]
Output [1]: [d_date_sk#5]

(5) BroadcastHashJoin [codegen id : 3]
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 : 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#5]

(7) 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>

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

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

(10) 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=1]

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

(12) 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]

(13) 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]

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

(15) 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]

(16) ReusedExchange [Reuses operator id: 14]
Output [3]: [i_category#16, i_class#17, sum#18]

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

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

(19) Exchange
Input [3]: [i_category#16, sum#23, isEmpty#24]
Arguments: hashpartitioning(i_category#16, 5), ENSURE_REQUIREMENTS, [plan_id=3]

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

(21) ReusedExchange [Reuses operator id: 14]
Output [3]: [i_category#31, i_class#32, sum#33]

(22) HashAggregate [codegen id : 13]
Input [3]: [i_category#31, i_class#32, sum#33]
Keys [2]: [i_category#31, i_class#32]
Functions [1]: [sum(UnscaledValue(ws_net_paid#34))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_net_paid#34))#11]
Results [1]: [MakeDecimal(sum(UnscaledValue(ws_net_paid#34))#11,17,2) AS total_sum#35]

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

(24) Exchange
Input [2]: [sum#38, isEmpty#39]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, [plan_id=4]

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

(26) Union

(27) 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]

(28) 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=5]

(29) 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#47]

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

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

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

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

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

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ws_sold_date_sk#3 IN dynamicpruning#4
BroadcastExchange (39)
+- * Project (38)
   +- * Filter (37)
      +- * ColumnarToRow (36)
         +- Scan parquet spark_catalog.default.date_dim (35)


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

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

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

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

(39) BroadcastExchange
Input [1]: [d_date_sk#5]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=7]


