== Physical Plan ==
TakeOrderedAndProject (26)
+- * HashAggregate (25)
   +- Exchange (24)
      +- * HashAggregate (23)
         +- * Expand (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 spark_catalog.default.inventory (1)
                  :           :     +- BroadcastExchange (7)
                  :           :        +- * Filter (6)
                  :           :           +- * ColumnarToRow (5)
                  :           :              +- Scan parquet spark_catalog.default.warehouse (4)
                  :           +- ReusedExchange (10)
                  +- * Sort (19)
                     +- Exchange (18)
                        +- * Filter (17)
                           +- * ColumnarToRow (16)
                              +- Scan parquet spark_catalog.default.item (15)


(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) 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 spark_catalog.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), [plan_id=1]

(8) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [inv_warehouse_sk#2]
Right keys [1]: [w_warehouse_sk#6]
Join type: Inner
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: 31]
Output [1]: [d_date_sk#7]

(11) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [inv_date_sk#4]
Right keys [1]: [d_date_sk#7]
Join type: Inner
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#7]

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

(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 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>

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

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

(18) Exchange
Input [5]: [i_item_sk#8, i_brand#9, i_class#10, i_category#11, i_product_name#12]
Arguments: hashpartitioning(i_item_sk#8, 5), ENSURE_REQUIREMENTS, [plan_id=3]

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

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

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

(22) Expand [codegen id : 7]
Input [5]: [inv_quantity_on_hand#3, i_product_name#12, i_brand#9, i_class#10, i_category#11]
Arguments: [[inv_quantity_on_hand#3, i_product_name#12, i_brand#9, i_class#10, i_category#11, 0], [inv_quantity_on_hand#3, i_product_name#12, i_brand#9, i_class#10, null, 1], [inv_quantity_on_hand#3, i_product_name#12, i_brand#9, null, null, 3], [inv_quantity_on_hand#3, i_product_name#12, null, null, null, 7], [inv_quantity_on_hand#3, null, null, null, null, 15]], [inv_quantity_on_hand#3, i_product_name#13, i_brand#14, i_class#15, i_category#16, spark_grouping_id#17]

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

(24) Exchange
Input [7]: [i_product_name#13, i_brand#14, i_class#15, i_category#16, spark_grouping_id#17, sum#20, count#21]
Arguments: hashpartitioning(i_product_name#13, i_brand#14, i_class#15, i_category#16, spark_grouping_id#17, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(25) HashAggregate [codegen id : 8]
Input [7]: [i_product_name#13, i_brand#14, i_class#15, i_category#16, spark_grouping_id#17, sum#20, count#21]
Keys [5]: [i_product_name#13, i_brand#14, i_class#15, i_category#16, spark_grouping_id#17]
Functions [1]: [avg(inv_quantity_on_hand#3)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#3)#22]
Results [5]: [i_product_name#13, i_brand#14, i_class#15, i_category#16, avg(inv_quantity_on_hand#3)#22 AS qoh#23]

(26) TakeOrderedAndProject
Input [5]: [i_product_name#13, i_brand#14, i_class#15, i_category#16, qoh#23]
Arguments: 100, [qoh#23 ASC NULLS FIRST, i_product_name#13 ASC NULLS FIRST, i_brand#14 ASC NULLS FIRST, i_class#15 ASC NULLS FIRST, i_category#16 ASC NULLS FIRST], [i_product_name#13, i_brand#14, i_class#15, i_category#16, qoh#23]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = inv_date_sk#4 IN dynamicpruning#5
BroadcastExchange (31)
+- * Project (30)
   +- * Filter (29)
      +- * ColumnarToRow (28)
         +- Scan parquet spark_catalog.default.date_dim (27)


(27) Scan parquet spark_catalog.default.date_dim
Output [2]: [d_date_sk#7, d_month_seq#24]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_month_seq), GreaterThanOrEqual(d_month_seq,1200), LessThanOrEqual(d_month_seq,1211), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_month_seq:int>

(28) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#7, d_month_seq#24]

(29) Filter [codegen id : 1]
Input [2]: [d_date_sk#7, d_month_seq#24]
Condition : (((isnotnull(d_month_seq#24) AND (d_month_seq#24 >= 1200)) AND (d_month_seq#24 <= 1211)) AND isnotnull(d_date_sk#7))

(30) Project [codegen id : 1]
Output [1]: [d_date_sk#7]
Input [2]: [d_date_sk#7, d_month_seq#24]

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


