== Physical Plan ==
TakeOrderedAndProject (46)
+- Union (45)
   :- * HashAggregate (24)
   :  +- * HashAggregate (23)
   :     +- * HashAggregate (22)
   :        +- Exchange (21)
   :           +- * ColumnarToRow (20)
   :              +- CometHashAggregate (19)
   :                 +- CometProject (18)
   :                    +- CometBroadcastHashJoin (17)
   :                       :- CometProject (13)
   :                       :  +- CometBroadcastHashJoin (12)
   :                       :     :- CometProject (8)
   :                       :     :  +- CometBroadcastHashJoin (7)
   :                       :     :     :- CometFilter (2)
   :                       :     :     :  +- CometScan parquet spark_catalog.default.inventory (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)
   :                       +- CometBroadcastExchange (16)
   :                          +- CometFilter (15)
   :                             +- CometScan parquet spark_catalog.default.warehouse (14)
   :- * HashAggregate (29)
   :  +- Exchange (28)
   :     +- * HashAggregate (27)
   :        +- * HashAggregate (26)
   :           +- ReusedExchange (25)
   :- * HashAggregate (34)
   :  +- Exchange (33)
   :     +- * HashAggregate (32)
   :        +- * HashAggregate (31)
   :           +- ReusedExchange (30)
   :- * HashAggregate (39)
   :  +- Exchange (38)
   :     +- * HashAggregate (37)
   :        +- * HashAggregate (36)
   :           +- ReusedExchange (35)
   +- * HashAggregate (44)
      +- Exchange (43)
         +- * HashAggregate (42)
            +- * HashAggregate (41)
               +- ReusedExchange (40)


(1) Scan parquet spark_catalog.default.inventory
Output [4]: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3, inv_date_sk#4]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(inv_date_sk#4), dynamicpruningexpression(inv_date_sk#4 IN dynamicpruning#5)]
PushedFilters: [IsNotNull(inv_item_sk), IsNotNull(inv_warehouse_sk)]
ReadSchema: struct<inv_item_sk:int,inv_warehouse_sk:int,inv_quantity_on_hand:int>

(2) CometFilter
Input [4]: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3, inv_date_sk#4]
Condition : (isnotnull(inv_item_sk#1) AND isnotnull(inv_warehouse_sk#2))

(3) Scan parquet spark_catalog.default.date_dim
Output [2]: [d_date_sk#6, d_month_seq#7]
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#6, d_month_seq#7]
Condition : (((isnotnull(d_month_seq#7) AND (d_month_seq#7 >= 1212)) AND (d_month_seq#7 <= 1223)) AND isnotnull(d_date_sk#6))

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

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

(7) CometBroadcastHashJoin
Left output [4]: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3, inv_date_sk#4]
Right output [1]: [d_date_sk#6]
Arguments: [inv_date_sk#4], [d_date_sk#6], Inner, BuildRight

(8) CometProject
Input [5]: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3, inv_date_sk#4, d_date_sk#6]
Arguments: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3], [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3]

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

(10) CometFilter
Input [5]: [i_item_sk#8, i_brand#9, i_class#10, i_category#11, i_product_name#12]
Condition : isnotnull(i_item_sk#8)

(11) CometBroadcastExchange
Input [5]: [i_item_sk#8, i_brand#9, i_class#10, i_category#11, i_product_name#12]
Arguments: [i_item_sk#8, i_brand#9, i_class#10, i_category#11, i_product_name#12]

(12) CometBroadcastHashJoin
Left output [3]: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3]
Right output [5]: [i_item_sk#8, i_brand#9, i_class#10, i_category#11, i_product_name#12]
Arguments: [inv_item_sk#1], [i_item_sk#8], Inner, BuildRight

(13) CometProject
Input [8]: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3, i_item_sk#8, i_brand#9, i_class#10, i_category#11, i_product_name#12]
Arguments: [inv_warehouse_sk#2, inv_quantity_on_hand#3, i_brand#9, i_class#10, i_category#11, i_product_name#12], [inv_warehouse_sk#2, inv_quantity_on_hand#3, i_brand#9, i_class#10, i_category#11, i_product_name#12]

(14) Scan parquet spark_catalog.default.warehouse
Output [1]: [w_warehouse_sk#13]
Batched: true
Location [not included in comparison]/{warehouse_dir}/warehouse]
PushedFilters: [IsNotNull(w_warehouse_sk)]
ReadSchema: struct<w_warehouse_sk:int>

(15) CometFilter
Input [1]: [w_warehouse_sk#13]
Condition : isnotnull(w_warehouse_sk#13)

(16) CometBroadcastExchange
Input [1]: [w_warehouse_sk#13]
Arguments: [w_warehouse_sk#13]

(17) CometBroadcastHashJoin
Left output [6]: [inv_warehouse_sk#2, inv_quantity_on_hand#3, i_brand#9, i_class#10, i_category#11, i_product_name#12]
Right output [1]: [w_warehouse_sk#13]
Arguments: [inv_warehouse_sk#2], [w_warehouse_sk#13], Inner, BuildRight

(18) CometProject
Input [7]: [inv_warehouse_sk#2, inv_quantity_on_hand#3, i_brand#9, i_class#10, i_category#11, i_product_name#12, w_warehouse_sk#13]
Arguments: [inv_quantity_on_hand#3, i_brand#9, i_class#10, i_category#11, i_product_name#12], [inv_quantity_on_hand#3, i_brand#9, i_class#10, i_category#11, i_product_name#12]

(19) CometHashAggregate
Input [5]: [inv_quantity_on_hand#3, i_brand#9, i_class#10, i_category#11, i_product_name#12]
Keys [4]: [i_product_name#12, i_brand#9, i_class#10, i_category#11]
Functions [1]: [partial_avg(inv_quantity_on_hand#3)]

(20) ColumnarToRow [codegen id : 1]
Input [6]: [i_product_name#12, i_brand#9, i_class#10, i_category#11, sum#14, count#15]

(21) Exchange
Input [6]: [i_product_name#12, i_brand#9, i_class#10, i_category#11, sum#14, count#15]
Arguments: hashpartitioning(i_product_name#12, i_brand#9, i_class#10, i_category#11, 5), ENSURE_REQUIREMENTS, [plan_id=1]

(22) HashAggregate [codegen id : 2]
Input [6]: [i_product_name#12, i_brand#9, i_class#10, i_category#11, sum#14, count#15]
Keys [4]: [i_product_name#12, i_brand#9, i_class#10, i_category#11]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#16]
Results [5]: [i_product_name#12, i_brand#9, i_class#10, i_category#11, avg(inv_quantity_on_hand#3)#16 AS qoh#17]

(23) HashAggregate [codegen id : 2]
Input [5]: [i_product_name#12, i_brand#9, i_class#10, i_category#11, qoh#17]
Keys [4]: [i_product_name#12, i_brand#9, i_class#10, i_category#11]
Functions [1]: [partial_avg(qoh#17)]
Aggregate Attributes [2]: [sum#18, count#19]
Results [6]: [i_product_name#12, i_brand#9, i_class#10, i_category#11, sum#20, count#21]

(24) HashAggregate [codegen id : 2]
Input [6]: [i_product_name#12, i_brand#9, i_class#10, i_category#11, sum#20, count#21]
Keys [4]: [i_product_name#12, i_brand#9, i_class#10, i_category#11]
Functions [1]: [avg(qoh#17)]
Aggregate Attributes [1]: [avg(qoh#17)#22]
Results [5]: [i_product_name#12, i_brand#9, i_class#10, i_category#11, avg(qoh#17)#22 AS qoh#23]

(25) ReusedExchange [Reuses operator id: 21]
Output [6]: [i_product_name#24, i_brand#25, i_class#26, i_category#27, sum#28, count#29]

(26) HashAggregate [codegen id : 4]
Input [6]: [i_product_name#24, i_brand#25, i_class#26, i_category#27, sum#28, count#29]
Keys [4]: [i_product_name#24, i_brand#25, i_class#26, i_category#27]
Functions [1]: [avg(inv_quantity_on_hand#30)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#30)#16]
Results [4]: [i_product_name#24, i_brand#25, i_class#26, avg(inv_quantity_on_hand#30)#16 AS qoh#31]

(27) HashAggregate [codegen id : 4]
Input [4]: [i_product_name#24, i_brand#25, i_class#26, qoh#31]
Keys [3]: [i_product_name#24, i_brand#25, i_class#26]
Functions [1]: [partial_avg(qoh#31)]
Aggregate Attributes [2]: [sum#32, count#33]
Results [5]: [i_product_name#24, i_brand#25, i_class#26, sum#34, count#35]

(28) Exchange
Input [5]: [i_product_name#24, i_brand#25, i_class#26, sum#34, count#35]
Arguments: hashpartitioning(i_product_name#24, i_brand#25, i_class#26, 5), ENSURE_REQUIREMENTS, [plan_id=2]

(29) HashAggregate [codegen id : 5]
Input [5]: [i_product_name#24, i_brand#25, i_class#26, sum#34, count#35]
Keys [3]: [i_product_name#24, i_brand#25, i_class#26]
Functions [1]: [avg(qoh#31)]
Aggregate Attributes [1]: [avg(qoh#31)#36]
Results [5]: [i_product_name#24, i_brand#25, i_class#26, null AS i_category#37, avg(qoh#31)#36 AS qoh#38]

(30) ReusedExchange [Reuses operator id: 21]
Output [6]: [i_product_name#39, i_brand#40, i_class#41, i_category#42, sum#43, count#44]

(31) HashAggregate [codegen id : 7]
Input [6]: [i_product_name#39, i_brand#40, i_class#41, i_category#42, sum#43, count#44]
Keys [4]: [i_product_name#39, i_brand#40, i_class#41, i_category#42]
Functions [1]: [avg(inv_quantity_on_hand#45)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#45)#16]
Results [3]: [i_product_name#39, i_brand#40, avg(inv_quantity_on_hand#45)#16 AS qoh#46]

(32) HashAggregate [codegen id : 7]
Input [3]: [i_product_name#39, i_brand#40, qoh#46]
Keys [2]: [i_product_name#39, i_brand#40]
Functions [1]: [partial_avg(qoh#46)]
Aggregate Attributes [2]: [sum#47, count#48]
Results [4]: [i_product_name#39, i_brand#40, sum#49, count#50]

(33) Exchange
Input [4]: [i_product_name#39, i_brand#40, sum#49, count#50]
Arguments: hashpartitioning(i_product_name#39, i_brand#40, 5), ENSURE_REQUIREMENTS, [plan_id=3]

(34) HashAggregate [codegen id : 8]
Input [4]: [i_product_name#39, i_brand#40, sum#49, count#50]
Keys [2]: [i_product_name#39, i_brand#40]
Functions [1]: [avg(qoh#46)]
Aggregate Attributes [1]: [avg(qoh#46)#51]
Results [5]: [i_product_name#39, i_brand#40, null AS i_class#52, null AS i_category#53, avg(qoh#46)#51 AS qoh#54]

(35) ReusedExchange [Reuses operator id: 21]
Output [6]: [i_product_name#55, i_brand#56, i_class#57, i_category#58, sum#59, count#60]

(36) HashAggregate [codegen id : 10]
Input [6]: [i_product_name#55, i_brand#56, i_class#57, i_category#58, sum#59, count#60]
Keys [4]: [i_product_name#55, i_brand#56, i_class#57, i_category#58]
Functions [1]: [avg(inv_quantity_on_hand#61)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#61)#16]
Results [2]: [i_product_name#55, avg(inv_quantity_on_hand#61)#16 AS qoh#62]

(37) HashAggregate [codegen id : 10]
Input [2]: [i_product_name#55, qoh#62]
Keys [1]: [i_product_name#55]
Functions [1]: [partial_avg(qoh#62)]
Aggregate Attributes [2]: [sum#63, count#64]
Results [3]: [i_product_name#55, sum#65, count#66]

(38) Exchange
Input [3]: [i_product_name#55, sum#65, count#66]
Arguments: hashpartitioning(i_product_name#55, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(39) HashAggregate [codegen id : 11]
Input [3]: [i_product_name#55, sum#65, count#66]
Keys [1]: [i_product_name#55]
Functions [1]: [avg(qoh#62)]
Aggregate Attributes [1]: [avg(qoh#62)#67]
Results [5]: [i_product_name#55, null AS i_brand#68, null AS i_class#69, null AS i_category#70, avg(qoh#62)#67 AS qoh#71]

(40) ReusedExchange [Reuses operator id: 21]
Output [6]: [i_product_name#72, i_brand#73, i_class#74, i_category#75, sum#76, count#77]

(41) HashAggregate [codegen id : 13]
Input [6]: [i_product_name#72, i_brand#73, i_class#74, i_category#75, sum#76, count#77]
Keys [4]: [i_product_name#72, i_brand#73, i_class#74, i_category#75]
Functions [1]: [avg(inv_quantity_on_hand#78)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#78)#16]
Results [1]: [avg(inv_quantity_on_hand#78)#16 AS qoh#79]

(42) HashAggregate [codegen id : 13]
Input [1]: [qoh#79]
Keys: []
Functions [1]: [partial_avg(qoh#79)]
Aggregate Attributes [2]: [sum#80, count#81]
Results [2]: [sum#82, count#83]

(43) Exchange
Input [2]: [sum#82, count#83]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, [plan_id=5]

(44) HashAggregate [codegen id : 14]
Input [2]: [sum#82, count#83]
Keys: []
Functions [1]: [avg(qoh#79)]
Aggregate Attributes [1]: [avg(qoh#79)#84]
Results [5]: [null AS i_product_name#85, null AS i_brand#86, null AS i_class#87, null AS i_category#88, avg(qoh#79)#84 AS qoh#89]

(45) Union

(46) TakeOrderedAndProject
Input [5]: [i_product_name#12, i_brand#9, i_class#10, i_category#11, qoh#23]
Arguments: 100, [qoh#23 ASC NULLS FIRST, i_product_name#12 ASC NULLS FIRST, i_brand#9 ASC NULLS FIRST, i_class#10 ASC NULLS FIRST, i_category#11 ASC NULLS FIRST], [i_product_name#12, i_brand#9, i_class#10, i_category#11, qoh#23]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = inv_date_sk#4 IN dynamicpruning#5
BroadcastExchange (51)
+- * ColumnarToRow (50)
   +- CometProject (49)
      +- CometFilter (48)
         +- CometScan parquet spark_catalog.default.date_dim (47)


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

(48) CometFilter
Input [2]: [d_date_sk#6, d_month_seq#7]
Condition : (((isnotnull(d_month_seq#7) AND (d_month_seq#7 >= 1212)) AND (d_month_seq#7 <= 1223)) AND isnotnull(d_date_sk#6))

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

(50) ColumnarToRow [codegen id : 1]
Input [1]: [d_date_sk#6]

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


