== 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 default.web_sales (1)
                        :              :     +- ReusedExchange (4)
                        :              +- BroadcastExchange (10)
                        :                 +- * Filter (9)
                        :                    +- * ColumnarToRow (8)
                        :                       +- Scan parquet 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 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 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 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), [id=#9]

(11) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [ws_item_sk#1]
Right keys [1]: [i_item_sk#6]
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#10]
Results [3]: [i_category#8, i_class#7, sum#11]

(14) Exchange
Input [3]: [i_category#8, i_class#7, sum#11]
Arguments: hashpartitioning(i_category#8, i_class#7, 5), ENSURE_REQUIREMENTS, [id=#12]

(15) HashAggregate [codegen id : 4]
Input [3]: [i_category#8, i_class#7, sum#11]
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))#13]
Results [6]: [cast(MakeDecimal(sum(UnscaledValue(ws_net_paid#2))#13,17,2) as decimal(27,2)) AS total_sum#14, i_category#8, i_class#7, 0 AS g_category#15, 0 AS g_class#16, 0 AS lochierarchy#17]

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

(17) HashAggregate [codegen id : 8]
Input [3]: [i_category#8, i_class#7, sum#18]
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))#13]
Results [2]: [MakeDecimal(sum(UnscaledValue(ws_net_paid#2))#13,17,2) AS total_sum#19, i_category#8]

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

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

(20) HashAggregate [codegen id : 9]
Input [3]: [i_category#8, sum#22, isEmpty#23]
Keys [1]: [i_category#8]
Functions [1]: [sum(total_sum#19)]
Aggregate Attributes [1]: [sum(total_sum#19)#25]
Results [6]: [sum(total_sum#19)#25 AS total_sum#26, i_category#8, 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#8, i_class#7, sum#31]

(22) HashAggregate [codegen id : 13]
Input [3]: [i_category#8, i_class#7, sum#31]
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))#13]
Results [1]: [MakeDecimal(sum(UnscaledValue(ws_net_paid#2))#13,17,2) AS total_sum#19]

(23) HashAggregate [codegen id : 13]
Input [1]: [total_sum#19]
Keys: []
Functions [1]: [partial_sum(total_sum#19)]
Aggregate Attributes [2]: [sum#32, isEmpty#33]
Results [2]: [sum#34, isEmpty#35]

(24) Exchange
Input [2]: [sum#34, isEmpty#35]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, [id=#36]

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

(26) Union

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

(28) Exchange
Input [6]: [total_sum#14, i_category#8, i_class#7, g_category#15, g_class#16, lochierarchy#17]
Arguments: hashpartitioning(total_sum#14, i_category#8, i_class#7, g_category#15, g_class#16, lochierarchy#17, 5), ENSURE_REQUIREMENTS, [id=#44]

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

(30) Exchange
Input [5]: [total_sum#14, i_category#8, i_class#7, lochierarchy#17, _w0#45]
Arguments: hashpartitioning(lochierarchy#17, _w0#45, 5), ENSURE_REQUIREMENTS, [id=#46]

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

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

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

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

===== 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 default.date_dim (35)


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

(37) Filter [codegen id : 1]
Input [2]: [d_date_sk#5, d_month_seq#48]
Condition : (((isnotnull(d_month_seq#48) AND (d_month_seq#48 >= 1212)) AND (d_month_seq#48 <= 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#48]

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


