== Physical Plan ==
TakeOrderedAndProject (48)
+- Union (47)
   :- * HashAggregate (26)
   :  +- * HashAggregate (25)
   :     +- * HashAggregate (24)
   :        +- Exchange (23)
   :           +- * HashAggregate (22)
   :              +- * Project (21)
   :                 +- * SortMergeJoin Inner (20)
   :                    :- * Sort (14)
   :                    :  +- Exchange (13)
   :                    :     +- * Project (12)
   :                    :        +- * BroadcastHashJoin Inner BuildRight (11)
   :                    :           :- * Project (9)
   :                    :           :  +- * BroadcastHashJoin Inner BuildRight (8)
   :                    :           :     :- * Filter (3)
   :                    :           :     :  +- * ColumnarToRow (2)
   :                    :           :     :     +- Scan parquet default.inventory (1)
   :                    :           :     +- BroadcastExchange (7)
   :                    :           :        +- * Filter (6)
   :                    :           :           +- * ColumnarToRow (5)
   :                    :           :              +- Scan parquet default.warehouse (4)
   :                    :           +- ReusedExchange (10)
   :                    +- * Sort (19)
   :                       +- Exchange (18)
   :                          +- * Filter (17)
   :                             +- * ColumnarToRow (16)
   :                                +- Scan parquet default.item (15)
   :- * HashAggregate (31)
   :  +- Exchange (30)
   :     +- * HashAggregate (29)
   :        +- * HashAggregate (28)
   :           +- ReusedExchange (27)
   :- * HashAggregate (36)
   :  +- Exchange (35)
   :     +- * HashAggregate (34)
   :        +- * HashAggregate (33)
   :           +- ReusedExchange (32)
   :- * HashAggregate (41)
   :  +- Exchange (40)
   :     +- * HashAggregate (39)
   :        +- * HashAggregate (38)
   :           +- ReusedExchange (37)
   +- * HashAggregate (46)
      +- Exchange (45)
         +- * HashAggregate (44)
            +- * HashAggregate (43)
               +- ReusedExchange (42)


(1) Scan parquet 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) ColumnarToRow [codegen id : 3]
Input [4]: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3, inv_date_sk#4]

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

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

(5) ColumnarToRow [codegen id : 1]
Input [1]: [w_warehouse_sk#6]

(6) Filter [codegen id : 1]
Input [1]: [w_warehouse_sk#6]
Condition : isnotnull(w_warehouse_sk#6)

(7) BroadcastExchange
Input [1]: [w_warehouse_sk#6]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#7]

(8) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [inv_warehouse_sk#2]
Right keys [1]: [w_warehouse_sk#6]
Join condition: None

(9) Project [codegen id : 3]
Output [3]: [inv_item_sk#1, inv_quantity_on_hand#3, inv_date_sk#4]
Input [5]: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3, inv_date_sk#4, w_warehouse_sk#6]

(10) ReusedExchange [Reuses operator id: 53]
Output [1]: [d_date_sk#8]

(11) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [inv_date_sk#4]
Right keys [1]: [d_date_sk#8]
Join condition: None

(12) Project [codegen id : 3]
Output [2]: [inv_item_sk#1, inv_quantity_on_hand#3]
Input [4]: [inv_item_sk#1, inv_quantity_on_hand#3, inv_date_sk#4, d_date_sk#8]

(13) Exchange
Input [2]: [inv_item_sk#1, inv_quantity_on_hand#3]
Arguments: hashpartitioning(inv_item_sk#1, 5), ENSURE_REQUIREMENTS, [id=#9]

(14) Sort [codegen id : 4]
Input [2]: [inv_item_sk#1, inv_quantity_on_hand#3]
Arguments: [inv_item_sk#1 ASC NULLS FIRST], false, 0

(15) Scan parquet default.item
Output [5]: [i_item_sk#10, i_brand#11, i_class#12, i_category#13, i_product_name#14]
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>

(16) ColumnarToRow [codegen id : 5]
Input [5]: [i_item_sk#10, i_brand#11, i_class#12, i_category#13, i_product_name#14]

(17) Filter [codegen id : 5]
Input [5]: [i_item_sk#10, i_brand#11, i_class#12, i_category#13, i_product_name#14]
Condition : isnotnull(i_item_sk#10)

(18) Exchange
Input [5]: [i_item_sk#10, i_brand#11, i_class#12, i_category#13, i_product_name#14]
Arguments: hashpartitioning(i_item_sk#10, 5), ENSURE_REQUIREMENTS, [id=#15]

(19) Sort [codegen id : 6]
Input [5]: [i_item_sk#10, i_brand#11, i_class#12, i_category#13, i_product_name#14]
Arguments: [i_item_sk#10 ASC NULLS FIRST], false, 0

(20) SortMergeJoin [codegen id : 7]
Left keys [1]: [inv_item_sk#1]
Right keys [1]: [i_item_sk#10]
Join condition: None

(21) Project [codegen id : 7]
Output [5]: [inv_quantity_on_hand#3, i_brand#11, i_class#12, i_category#13, i_product_name#14]
Input [7]: [inv_item_sk#1, inv_quantity_on_hand#3, i_item_sk#10, i_brand#11, i_class#12, i_category#13, i_product_name#14]

(22) HashAggregate [codegen id : 7]
Input [5]: [inv_quantity_on_hand#3, i_brand#11, i_class#12, i_category#13, i_product_name#14]
Keys [4]: [i_product_name#14, i_brand#11, i_class#12, i_category#13]
Functions [1]: [partial_avg(inv_quantity_on_hand#3)]
Aggregate Attributes [2]: [sum#16, count#17]
Results [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]

(23) Exchange
Input [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]
Arguments: hashpartitioning(i_product_name#14, i_brand#11, i_class#12, i_category#13, 5), ENSURE_REQUIREMENTS, [id=#20]

(24) HashAggregate [codegen id : 8]
Input [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]
Keys [4]: [i_product_name#14, i_brand#11, i_class#12, i_category#13]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#21]
Results [5]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, avg(inv_quantity_on_hand#3)#21 AS qoh#22]

(25) HashAggregate [codegen id : 8]
Input [5]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, qoh#22]
Keys [4]: [i_product_name#14, i_brand#11, i_class#12, i_category#13]
Functions [1]: [partial_avg(qoh#22)]
Aggregate Attributes [2]: [sum#23, count#24]
Results [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#25, count#26]

(26) HashAggregate [codegen id : 8]
Input [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#25, count#26]
Keys [4]: [i_product_name#14, i_brand#11, i_class#12, i_category#13]
Functions [1]: [avg(qoh#22)]
Aggregate Attributes [1]: [avg(qoh#22)#27]
Results [5]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, avg(qoh#22)#27 AS qoh#28]

(27) ReusedExchange [Reuses operator id: 23]
Output [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]

(28) HashAggregate [codegen id : 16]
Input [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]
Keys [4]: [i_product_name#14, i_brand#11, i_class#12, i_category#13]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#21]
Results [4]: [i_product_name#14, i_brand#11, i_class#12, avg(inv_quantity_on_hand#3)#21 AS qoh#22]

(29) HashAggregate [codegen id : 16]
Input [4]: [i_product_name#14, i_brand#11, i_class#12, qoh#22]
Keys [3]: [i_product_name#14, i_brand#11, i_class#12]
Functions [1]: [partial_avg(qoh#22)]
Aggregate Attributes [2]: [sum#29, count#30]
Results [5]: [i_product_name#14, i_brand#11, i_class#12, sum#31, count#32]

(30) Exchange
Input [5]: [i_product_name#14, i_brand#11, i_class#12, sum#31, count#32]
Arguments: hashpartitioning(i_product_name#14, i_brand#11, i_class#12, 5), ENSURE_REQUIREMENTS, [id=#33]

(31) HashAggregate [codegen id : 17]
Input [5]: [i_product_name#14, i_brand#11, i_class#12, sum#31, count#32]
Keys [3]: [i_product_name#14, i_brand#11, i_class#12]
Functions [1]: [avg(qoh#22)]
Aggregate Attributes [1]: [avg(qoh#22)#34]
Results [5]: [i_product_name#14, i_brand#11, i_class#12, null AS i_category#35, avg(qoh#22)#34 AS qoh#36]

(32) ReusedExchange [Reuses operator id: 23]
Output [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]

(33) HashAggregate [codegen id : 25]
Input [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]
Keys [4]: [i_product_name#14, i_brand#11, i_class#12, i_category#13]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#21]
Results [3]: [i_product_name#14, i_brand#11, avg(inv_quantity_on_hand#3)#21 AS qoh#22]

(34) HashAggregate [codegen id : 25]
Input [3]: [i_product_name#14, i_brand#11, qoh#22]
Keys [2]: [i_product_name#14, i_brand#11]
Functions [1]: [partial_avg(qoh#22)]
Aggregate Attributes [2]: [sum#37, count#38]
Results [4]: [i_product_name#14, i_brand#11, sum#39, count#40]

(35) Exchange
Input [4]: [i_product_name#14, i_brand#11, sum#39, count#40]
Arguments: hashpartitioning(i_product_name#14, i_brand#11, 5), ENSURE_REQUIREMENTS, [id=#41]

(36) HashAggregate [codegen id : 26]
Input [4]: [i_product_name#14, i_brand#11, sum#39, count#40]
Keys [2]: [i_product_name#14, i_brand#11]
Functions [1]: [avg(qoh#22)]
Aggregate Attributes [1]: [avg(qoh#22)#42]
Results [5]: [i_product_name#14, i_brand#11, null AS i_class#43, null AS i_category#44, avg(qoh#22)#42 AS qoh#45]

(37) ReusedExchange [Reuses operator id: 23]
Output [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]

(38) HashAggregate [codegen id : 34]
Input [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]
Keys [4]: [i_product_name#14, i_brand#11, i_class#12, i_category#13]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#21]
Results [2]: [i_product_name#14, avg(inv_quantity_on_hand#3)#21 AS qoh#22]

(39) HashAggregate [codegen id : 34]
Input [2]: [i_product_name#14, qoh#22]
Keys [1]: [i_product_name#14]
Functions [1]: [partial_avg(qoh#22)]
Aggregate Attributes [2]: [sum#46, count#47]
Results [3]: [i_product_name#14, sum#48, count#49]

(40) Exchange
Input [3]: [i_product_name#14, sum#48, count#49]
Arguments: hashpartitioning(i_product_name#14, 5), ENSURE_REQUIREMENTS, [id=#50]

(41) HashAggregate [codegen id : 35]
Input [3]: [i_product_name#14, sum#48, count#49]
Keys [1]: [i_product_name#14]
Functions [1]: [avg(qoh#22)]
Aggregate Attributes [1]: [avg(qoh#22)#51]
Results [5]: [i_product_name#14, null AS i_brand#52, null AS i_class#53, null AS i_category#54, avg(qoh#22)#51 AS qoh#55]

(42) ReusedExchange [Reuses operator id: 23]
Output [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]

(43) HashAggregate [codegen id : 43]
Input [6]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, sum#18, count#19]
Keys [4]: [i_product_name#14, i_brand#11, i_class#12, i_category#13]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#21]
Results [1]: [avg(inv_quantity_on_hand#3)#21 AS qoh#22]

(44) HashAggregate [codegen id : 43]
Input [1]: [qoh#22]
Keys: []
Functions [1]: [partial_avg(qoh#22)]
Aggregate Attributes [2]: [sum#56, count#57]
Results [2]: [sum#58, count#59]

(45) Exchange
Input [2]: [sum#58, count#59]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, [id=#60]

(46) HashAggregate [codegen id : 44]
Input [2]: [sum#58, count#59]
Keys: []
Functions [1]: [avg(qoh#22)]
Aggregate Attributes [1]: [avg(qoh#22)#61]
Results [5]: [null AS i_product_name#62, null AS i_brand#63, null AS i_class#64, null AS i_category#65, avg(qoh#22)#61 AS qoh#66]

(47) Union

(48) TakeOrderedAndProject
Input [5]: [i_product_name#14, i_brand#11, i_class#12, i_category#13, qoh#28]
Arguments: 100, [qoh#28 ASC NULLS FIRST, i_product_name#14 ASC NULLS FIRST, i_brand#11 ASC NULLS FIRST, i_class#12 ASC NULLS FIRST, i_category#13 ASC NULLS FIRST], [i_product_name#14, i_brand#11, i_class#12, i_category#13, qoh#28]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = inv_date_sk#4 IN dynamicpruning#5
BroadcastExchange (53)
+- * Project (52)
   +- * Filter (51)
      +- * ColumnarToRow (50)
         +- Scan parquet default.date_dim (49)


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

(50) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#8, d_month_seq#67]

(51) Filter [codegen id : 1]
Input [2]: [d_date_sk#8, d_month_seq#67]
Condition : (((isnotnull(d_month_seq#67) AND (d_month_seq#67 >= 1212)) AND (d_month_seq#67 <= 1223)) AND isnotnull(d_date_sk#8))

(52) Project [codegen id : 1]
Output [1]: [d_date_sk#8]
Input [2]: [d_date_sk#8, d_month_seq#67]

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


