== Physical Plan ==
TakeOrderedAndProject (22)
+- * HashAggregate (21)
   +- Exchange (20)
      +- * HashAggregate (19)
         +- * Expand (18)
            +- * Project (17)
               +- * BroadcastNestedLoopJoin Inner BuildRight (16)
                  :- * Project (12)
                  :  +- * BroadcastHashJoin Inner BuildRight (11)
                  :     :- * Project (6)
                  :     :  +- * BroadcastHashJoin Inner BuildRight (5)
                  :     :     :- * Filter (3)
                  :     :     :  +- * ColumnarToRow (2)
                  :     :     :     +- Scan parquet spark_catalog.default.inventory (1)
                  :     :     +- ReusedExchange (4)
                  :     +- BroadcastExchange (10)
                  :        +- * Filter (9)
                  :           +- * ColumnarToRow (8)
                  :              +- Scan parquet spark_catalog.default.item (7)
                  +- BroadcastExchange (15)
                     +- * ColumnarToRow (14)
                        +- Scan parquet spark_catalog.default.warehouse (13)


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

(2) ColumnarToRow [codegen id : 4]
Input [3]: [inv_item_sk#1, inv_quantity_on_hand#2, inv_date_sk#3]

(3) Filter [codegen id : 4]
Input [3]: [inv_item_sk#1, inv_quantity_on_hand#2, inv_date_sk#3]
Condition : isnotnull(inv_item_sk#1)

(4) ReusedExchange [Reuses operator id: 27]
Output [1]: [d_date_sk#5]

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

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

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

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

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

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

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

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

(14) ColumnarToRow [codegen id : 3]
Input: []

(15) BroadcastExchange
Input: []
Arguments: IdentityBroadcastMode, [plan_id=2]

(16) BroadcastNestedLoopJoin [codegen id : 4]
Join type: Inner
Join condition: None

(17) Project [codegen id : 4]
Output [5]: [inv_quantity_on_hand#2, i_product_name#10, i_brand#7, i_class#8, i_category#9]
Input [5]: [inv_quantity_on_hand#2, i_brand#7, i_class#8, i_category#9, i_product_name#10]

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

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

(20) Exchange
Input [7]: [i_product_name#11, i_brand#12, i_class#13, i_category#14, spark_grouping_id#15, sum#18, count#19]
Arguments: hashpartitioning(i_product_name#11, i_brand#12, i_class#13, i_category#14, spark_grouping_id#15, 5), ENSURE_REQUIREMENTS, [plan_id=3]

(21) HashAggregate [codegen id : 5]
Input [7]: [i_product_name#11, i_brand#12, i_class#13, i_category#14, spark_grouping_id#15, sum#18, count#19]
Keys [5]: [i_product_name#11, i_brand#12, i_class#13, i_category#14, spark_grouping_id#15]
Functions [1]: [avg(inv_quantity_on_hand#2)]
Aggregate Attributes [1]: [avg(inv_quantity_on_hand#2)#20]
Results [5]: [i_product_name#11, i_brand#12, i_class#13, i_category#14, avg(inv_quantity_on_hand#2)#20 AS qoh#21]

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

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = inv_date_sk#3 IN dynamicpruning#4
BroadcastExchange (27)
+- * Project (26)
   +- * Filter (25)
      +- * ColumnarToRow (24)
         +- Scan parquet spark_catalog.default.date_dim (23)


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

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

(25) Filter [codegen id : 1]
Input [2]: [d_date_sk#5, d_month_seq#22]
Condition : (((isnotnull(d_month_seq#22) AND (d_month_seq#22 >= 1200)) AND (d_month_seq#22 <= 1211)) AND isnotnull(d_date_sk#5))

(26) Project [codegen id : 1]
Output [1]: [d_date_sk#5]
Input [2]: [d_date_sk#5, d_month_seq#22]

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


