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


(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) CometFilter
Input [3]: [ws_item_sk#1, ws_net_paid#2, ws_sold_date_sk#3]
Condition : isnotnull(ws_item_sk#1)

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

(4) CometFilter
Input [2]: [d_date_sk#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#5))

(5) CometProject
Input [2]: [d_date_sk#5, d_month_seq#6]
Arguments: [d_date_sk#5], [d_date_sk#5]

(6) CometBroadcastExchange
Input [1]: [d_date_sk#5]
Arguments: [d_date_sk#5]

(7) CometBroadcastHashJoin
Left output [3]: [ws_item_sk#1, ws_net_paid#2, ws_sold_date_sk#3]
Right output [1]: [d_date_sk#5]
Arguments: [ws_sold_date_sk#3], [d_date_sk#5], Inner, BuildRight

(8) CometProject
Input [4]: [ws_item_sk#1, ws_net_paid#2, ws_sold_date_sk#3, d_date_sk#5]
Arguments: [ws_item_sk#1, ws_net_paid#2], [ws_item_sk#1, ws_net_paid#2]

(9) Scan parquet spark_catalog.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>

(10) CometFilter
Input [3]: [i_item_sk#7, i_class#8, i_category#9]
Condition : isnotnull(i_item_sk#7)

(11) CometBroadcastExchange
Input [3]: [i_item_sk#7, i_class#8, i_category#9]
Arguments: [i_item_sk#7, i_class#8, i_category#9]

(12) CometBroadcastHashJoin
Left output [2]: [ws_item_sk#1, ws_net_paid#2]
Right output [3]: [i_item_sk#7, i_class#8, i_category#9]
Arguments: [ws_item_sk#1], [i_item_sk#7], Inner, BuildRight

(13) CometProject
Input [5]: [ws_item_sk#1, ws_net_paid#2, i_item_sk#7, i_class#8, i_category#9]
Arguments: [ws_net_paid#2, i_class#8, i_category#9], [ws_net_paid#2, i_class#8, i_category#9]

(14) CometHashAggregate
Input [3]: [ws_net_paid#2, i_class#8, i_category#9]
Keys [2]: [i_category#9, i_class#8]
Functions [1]: [partial_sum(UnscaledValue(ws_net_paid#2))]

(15) ColumnarToRow [codegen id : 1]
Input [3]: [i_category#9, i_class#8, sum#10]

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

(17) HashAggregate [codegen id : 2]
Input [3]: [i_category#9, i_class#8, sum#10]
Keys [2]: [i_category#9, i_class#8]
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#9, i_class#8, 0 AS g_category#13, 0 AS g_class#14, 0 AS lochierarchy#15]

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

(19) HashAggregate [codegen id : 4]
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]

(20) HashAggregate [codegen id : 4]
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]

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

(22) HashAggregate [codegen id : 5]
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]

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

(24) HashAggregate [codegen id : 7]
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]

(25) HashAggregate [codegen id : 7]
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]

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

(27) HashAggregate [codegen id : 8]
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]

(28) Union

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

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

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

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

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

(34) Window
Input [5]: [total_sum#12, i_category#9, i_class#8, 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]

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

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

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ws_sold_date_sk#3 IN dynamicpruning#4
BroadcastExchange (41)
+- * ColumnarToRow (40)
   +- CometProject (39)
      +- CometFilter (38)
         +- CometScan parquet spark_catalog.default.date_dim (37)


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

(38) CometFilter
Input [2]: [d_date_sk#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#5))

(39) CometProject
Input [2]: [d_date_sk#5, d_month_seq#6]
Arguments: [d_date_sk#5], [d_date_sk#5]

(40) ColumnarToRow [codegen id : 1]
Input [1]: [d_date_sk#5]

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


