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


(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 : 4]
Input [4]: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3, inv_date_sk#4]

(3) Filter [codegen id : 4]
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) ReusedExchange [Reuses operator id: 50]
Output [1]: [d_date_sk#6]

(5) BroadcastHashJoin [codegen id : 4]
Left keys [1]: [inv_date_sk#4]
Right keys [1]: [d_date_sk#6]
Join condition: None

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

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

(8) ColumnarToRow [codegen id : 2]
Input [5]: [i_item_sk#7, i_brand#8, i_class#9, i_category#10, i_product_name#11]

(9) Filter [codegen id : 2]
Input [5]: [i_item_sk#7, i_brand#8, i_class#9, i_category#10, i_product_name#11]
Condition : isnotnull(i_item_sk#7)

(10) BroadcastExchange
Input [5]: [i_item_sk#7, i_brand#8, i_class#9, i_category#10, i_product_name#11]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#12]

(11) BroadcastHashJoin [codegen id : 4]
Left keys [1]: [inv_item_sk#1]
Right keys [1]: [i_item_sk#7]
Join condition: None

(12) Project [codegen id : 4]
Output [6]: [inv_warehouse_sk#2, inv_quantity_on_hand#3, i_brand#8, i_class#9, i_category#10, i_product_name#11]
Input [8]: [inv_item_sk#1, inv_warehouse_sk#2, inv_quantity_on_hand#3, i_item_sk#7, i_brand#8, i_class#9, i_category#10, i_product_name#11]

(13) Scan parquet 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>

(14) ColumnarToRow [codegen id : 3]
Input [1]: [w_warehouse_sk#13]

(15) Filter [codegen id : 3]
Input [1]: [w_warehouse_sk#13]
Condition : isnotnull(w_warehouse_sk#13)

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

(17) BroadcastHashJoin [codegen id : 4]
Left keys [1]: [inv_warehouse_sk#2]
Right keys [1]: [w_warehouse_sk#13]
Join condition: None

(18) Project [codegen id : 4]
Output [5]: [inv_quantity_on_hand#3, i_brand#8, i_class#9, i_category#10, i_product_name#11]
Input [7]: [inv_warehouse_sk#2, inv_quantity_on_hand#3, i_brand#8, i_class#9, i_category#10, i_product_name#11, w_warehouse_sk#13]

(19) HashAggregate [codegen id : 4]
Input [5]: [inv_quantity_on_hand#3, i_brand#8, i_class#9, i_category#10, i_product_name#11]
Keys [4]: [i_product_name#11, i_brand#8, i_class#9, i_category#10]
Functions [1]: [partial_avg(inv_quantity_on_hand#3)]
Aggregate Attributes [2]: [sum#15, count#16]
Results [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#17, count#18]

(20) Exchange
Input [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#17, count#18]
Arguments: hashpartitioning(i_product_name#11, i_brand#8, i_class#9, i_category#10, 5), ENSURE_REQUIREMENTS, [id=#19]

(21) HashAggregate [codegen id : 5]
Input [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#17, count#18]
Keys [4]: [i_product_name#11, i_brand#8, i_class#9, i_category#10]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#20]
Results [5]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, avg(inv_quantity_on_hand#3)#20 AS qoh#21]

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

(23) HashAggregate [codegen id : 5]
Input [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#24, count#25]
Keys [4]: [i_product_name#11, i_brand#8, i_class#9, i_category#10]
Functions [1]: [avg(qoh#21)]
Aggregate Attributes [1]: [avg(qoh#21)#26]
Results [5]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, avg(qoh#21)#26 AS qoh#27]

(24) ReusedExchange [Reuses operator id: 20]
Output [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#17, count#18]

(25) HashAggregate [codegen id : 10]
Input [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#17, count#18]
Keys [4]: [i_product_name#11, i_brand#8, i_class#9, i_category#10]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#20]
Results [4]: [i_product_name#11, i_brand#8, i_class#9, avg(inv_quantity_on_hand#3)#20 AS qoh#21]

(26) HashAggregate [codegen id : 10]
Input [4]: [i_product_name#11, i_brand#8, i_class#9, qoh#21]
Keys [3]: [i_product_name#11, i_brand#8, i_class#9]
Functions [1]: [partial_avg(qoh#21)]
Aggregate Attributes [2]: [sum#28, count#29]
Results [5]: [i_product_name#11, i_brand#8, i_class#9, sum#30, count#31]

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

(28) HashAggregate [codegen id : 11]
Input [5]: [i_product_name#11, i_brand#8, i_class#9, sum#30, count#31]
Keys [3]: [i_product_name#11, i_brand#8, i_class#9]
Functions [1]: [avg(qoh#21)]
Aggregate Attributes [1]: [avg(qoh#21)#33]
Results [5]: [i_product_name#11, i_brand#8, i_class#9, null AS i_category#34, avg(qoh#21)#33 AS qoh#35]

(29) ReusedExchange [Reuses operator id: 20]
Output [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#17, count#18]

(30) HashAggregate [codegen id : 16]
Input [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#17, count#18]
Keys [4]: [i_product_name#11, i_brand#8, i_class#9, i_category#10]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#20]
Results [3]: [i_product_name#11, i_brand#8, avg(inv_quantity_on_hand#3)#20 AS qoh#21]

(31) HashAggregate [codegen id : 16]
Input [3]: [i_product_name#11, i_brand#8, qoh#21]
Keys [2]: [i_product_name#11, i_brand#8]
Functions [1]: [partial_avg(qoh#21)]
Aggregate Attributes [2]: [sum#36, count#37]
Results [4]: [i_product_name#11, i_brand#8, sum#38, count#39]

(32) Exchange
Input [4]: [i_product_name#11, i_brand#8, sum#38, count#39]
Arguments: hashpartitioning(i_product_name#11, i_brand#8, 5), ENSURE_REQUIREMENTS, [id=#40]

(33) HashAggregate [codegen id : 17]
Input [4]: [i_product_name#11, i_brand#8, sum#38, count#39]
Keys [2]: [i_product_name#11, i_brand#8]
Functions [1]: [avg(qoh#21)]
Aggregate Attributes [1]: [avg(qoh#21)#41]
Results [5]: [i_product_name#11, i_brand#8, null AS i_class#42, null AS i_category#43, avg(qoh#21)#41 AS qoh#44]

(34) ReusedExchange [Reuses operator id: 20]
Output [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#17, count#18]

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

(36) HashAggregate [codegen id : 22]
Input [2]: [i_product_name#11, qoh#21]
Keys [1]: [i_product_name#11]
Functions [1]: [partial_avg(qoh#21)]
Aggregate Attributes [2]: [sum#45, count#46]
Results [3]: [i_product_name#11, sum#47, count#48]

(37) Exchange
Input [3]: [i_product_name#11, sum#47, count#48]
Arguments: hashpartitioning(i_product_name#11, 5), ENSURE_REQUIREMENTS, [id=#49]

(38) HashAggregate [codegen id : 23]
Input [3]: [i_product_name#11, sum#47, count#48]
Keys [1]: [i_product_name#11]
Functions [1]: [avg(qoh#21)]
Aggregate Attributes [1]: [avg(qoh#21)#50]
Results [5]: [i_product_name#11, null AS i_brand#51, null AS i_class#52, null AS i_category#53, avg(qoh#21)#50 AS qoh#54]

(39) ReusedExchange [Reuses operator id: 20]
Output [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#17, count#18]

(40) HashAggregate [codegen id : 28]
Input [6]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, sum#17, count#18]
Keys [4]: [i_product_name#11, i_brand#8, i_class#9, i_category#10]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#20]
Results [1]: [avg(inv_quantity_on_hand#3)#20 AS qoh#21]

(41) HashAggregate [codegen id : 28]
Input [1]: [qoh#21]
Keys: []
Functions [1]: [partial_avg(qoh#21)]
Aggregate Attributes [2]: [sum#55, count#56]
Results [2]: [sum#57, count#58]

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

(43) HashAggregate [codegen id : 29]
Input [2]: [sum#57, count#58]
Keys: []
Functions [1]: [avg(qoh#21)]
Aggregate Attributes [1]: [avg(qoh#21)#60]
Results [5]: [null AS i_product_name#61, null AS i_brand#62, null AS i_class#63, null AS i_category#64, avg(qoh#21)#60 AS qoh#65]

(44) Union

(45) TakeOrderedAndProject
Input [5]: [i_product_name#11, i_brand#8, i_class#9, i_category#10, qoh#27]
Arguments: 100, [qoh#27 ASC NULLS FIRST, i_product_name#11 ASC NULLS FIRST, i_brand#8 ASC NULLS FIRST, i_class#9 ASC NULLS FIRST, i_category#10 ASC NULLS FIRST], [i_product_name#11, i_brand#8, i_class#9, i_category#10, qoh#27]

===== Subqueries =====

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


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

(47) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#6, d_month_seq#66]

(48) Filter [codegen id : 1]
Input [2]: [d_date_sk#6, d_month_seq#66]
Condition : (((isnotnull(d_month_seq#66) AND (d_month_seq#66 >= 1212)) AND (d_month_seq#66 <= 1223)) AND isnotnull(d_date_sk#6))

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

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


