== Physical Plan ==
TakeOrderedAndProject (30)
+- * HashAggregate (29)
   +- Exchange (28)
      +- * HashAggregate (27)
         +- * Project (26)
            +- * BroadcastHashJoin Inner BuildRight (25)
               :- * Project (20)
               :  +- * BroadcastHashJoin Inner BuildRight (19)
               :     :- * Project (13)
               :     :  +- * BroadcastHashJoin Inner BuildRight (12)
               :     :     :- * Project (6)
               :     :     :  +- * BroadcastHashJoin Inner BuildRight (5)
               :     :     :     :- * Filter (3)
               :     :     :     :  +- * ColumnarToRow (2)
               :     :     :     :     +- Scan parquet spark_catalog.default.store_sales (1)
               :     :     :     +- ReusedExchange (4)
               :     :     +- BroadcastExchange (11)
               :     :        +- * Project (10)
               :     :           +- * Filter (9)
               :     :              +- * ColumnarToRow (8)
               :     :                 +- Scan parquet spark_catalog.default.promotion (7)
               :     +- BroadcastExchange (18)
               :        +- * Project (17)
               :           +- * Filter (16)
               :              +- * ColumnarToRow (15)
               :                 +- Scan parquet spark_catalog.default.customer_demographics (14)
               +- BroadcastExchange (24)
                  +- * Filter (23)
                     +- * ColumnarToRow (22)
                        +- Scan parquet spark_catalog.default.item (21)


(1) Scan parquet spark_catalog.default.store_sales
Output [8]: [ss_item_sk#1, ss_cdemo_sk#2, ss_promo_sk#3, ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7, ss_sold_date_sk#8]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#8), (ss_sold_date_sk#8 >= 2450815), (ss_sold_date_sk#8 <= 2451179), dynamicpruningexpression(ss_sold_date_sk#8 IN dynamicpruning#9)]
PushedFilters: [IsNotNull(ss_cdemo_sk), IsNotNull(ss_item_sk), IsNotNull(ss_promo_sk)]
ReadSchema: struct<ss_item_sk:int,ss_cdemo_sk:int,ss_promo_sk:int,ss_quantity:int,ss_list_price:decimal(7,2),ss_sales_price:decimal(7,2),ss_coupon_amt:decimal(7,2)>

(2) ColumnarToRow [codegen id : 5]
Input [8]: [ss_item_sk#1, ss_cdemo_sk#2, ss_promo_sk#3, ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7, ss_sold_date_sk#8]

(3) Filter [codegen id : 5]
Input [8]: [ss_item_sk#1, ss_cdemo_sk#2, ss_promo_sk#3, ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7, ss_sold_date_sk#8]
Condition : ((isnotnull(ss_cdemo_sk#2) AND isnotnull(ss_item_sk#1)) AND isnotnull(ss_promo_sk#3))

(4) ReusedExchange [Reuses operator id: 35]
Output [1]: [d_date_sk#10]

(5) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [ss_sold_date_sk#8]
Right keys [1]: [d_date_sk#10]
Join type: Inner
Join condition: None

(6) Project [codegen id : 5]
Output [7]: [ss_item_sk#1, ss_cdemo_sk#2, ss_promo_sk#3, ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7]
Input [9]: [ss_item_sk#1, ss_cdemo_sk#2, ss_promo_sk#3, ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7, ss_sold_date_sk#8, d_date_sk#10]

(7) Scan parquet spark_catalog.default.promotion
Output [3]: [p_promo_sk#11, p_channel_email#12, p_channel_event#13]
Batched: true
Location [not included in comparison]/{warehouse_dir}/promotion]
PushedFilters: [Or(EqualTo(p_channel_email,N),EqualTo(p_channel_event,N)), IsNotNull(p_promo_sk)]
ReadSchema: struct<p_promo_sk:int,p_channel_email:string,p_channel_event:string>

(8) ColumnarToRow [codegen id : 2]
Input [3]: [p_promo_sk#11, p_channel_email#12, p_channel_event#13]

(9) Filter [codegen id : 2]
Input [3]: [p_promo_sk#11, p_channel_email#12, p_channel_event#13]
Condition : (((p_channel_email#12 = N) OR (p_channel_event#13 = N)) AND isnotnull(p_promo_sk#11))

(10) Project [codegen id : 2]
Output [1]: [p_promo_sk#11]
Input [3]: [p_promo_sk#11, p_channel_email#12, p_channel_event#13]

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

(12) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [ss_promo_sk#3]
Right keys [1]: [p_promo_sk#11]
Join type: Inner
Join condition: None

(13) Project [codegen id : 5]
Output [6]: [ss_item_sk#1, ss_cdemo_sk#2, ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7]
Input [8]: [ss_item_sk#1, ss_cdemo_sk#2, ss_promo_sk#3, ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7, p_promo_sk#11]

(14) Scan parquet spark_catalog.default.customer_demographics
Output [4]: [cd_demo_sk#14, cd_gender#15, cd_marital_status#16, cd_education_status#17]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_demographics]
PushedFilters: [IsNotNull(cd_gender), IsNotNull(cd_marital_status), IsNotNull(cd_education_status), EqualTo(cd_gender,F), EqualTo(cd_marital_status,W), EqualTo(cd_education_status,Primary             ), IsNotNull(cd_demo_sk)]
ReadSchema: struct<cd_demo_sk:int,cd_gender:string,cd_marital_status:string,cd_education_status:string>

(15) ColumnarToRow [codegen id : 3]
Input [4]: [cd_demo_sk#14, cd_gender#15, cd_marital_status#16, cd_education_status#17]

(16) Filter [codegen id : 3]
Input [4]: [cd_demo_sk#14, cd_gender#15, cd_marital_status#16, cd_education_status#17]
Condition : ((((((isnotnull(cd_gender#15) AND isnotnull(cd_marital_status#16)) AND isnotnull(cd_education_status#17)) AND (cd_gender#15 = F)) AND (cd_marital_status#16 = W)) AND (cd_education_status#17 = Primary             )) AND isnotnull(cd_demo_sk#14))

(17) Project [codegen id : 3]
Output [1]: [cd_demo_sk#14]
Input [4]: [cd_demo_sk#14, cd_gender#15, cd_marital_status#16, cd_education_status#17]

(18) BroadcastExchange
Input [1]: [cd_demo_sk#14]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=2]

(19) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [ss_cdemo_sk#2]
Right keys [1]: [cd_demo_sk#14]
Join type: Inner
Join condition: None

(20) Project [codegen id : 5]
Output [5]: [ss_item_sk#1, ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7]
Input [7]: [ss_item_sk#1, ss_cdemo_sk#2, ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7, cd_demo_sk#14]

(21) Scan parquet spark_catalog.default.item
Output [2]: [i_item_sk#18, i_item_id#19]
Batched: true
Location [not included in comparison]/{warehouse_dir}/item]
PushedFilters: [IsNotNull(i_item_sk)]
ReadSchema: struct<i_item_sk:int,i_item_id:string>

(22) ColumnarToRow [codegen id : 4]
Input [2]: [i_item_sk#18, i_item_id#19]

(23) Filter [codegen id : 4]
Input [2]: [i_item_sk#18, i_item_id#19]
Condition : isnotnull(i_item_sk#18)

(24) BroadcastExchange
Input [2]: [i_item_sk#18, i_item_id#19]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=3]

(25) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [ss_item_sk#1]
Right keys [1]: [i_item_sk#18]
Join type: Inner
Join condition: None

(26) Project [codegen id : 5]
Output [5]: [ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7, i_item_id#19]
Input [7]: [ss_item_sk#1, ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7, i_item_sk#18, i_item_id#19]

(27) HashAggregate [codegen id : 5]
Input [5]: [ss_quantity#4, ss_list_price#5, ss_sales_price#6, ss_coupon_amt#7, i_item_id#19]
Keys [1]: [i_item_id#19]
Functions [4]: [partial_avg(ss_quantity#4), partial_avg(UnscaledValue(ss_list_price#5)), partial_avg(UnscaledValue(ss_coupon_amt#7)), partial_avg(UnscaledValue(ss_sales_price#6))]
Aggregate Attributes [8]: [sum#20, count#21, sum#22, count#23, sum#24, count#25, sum#26, count#27]
Results [9]: [i_item_id#19, sum#28, count#29, sum#30, count#31, sum#32, count#33, sum#34, count#35]

(28) Exchange
Input [9]: [i_item_id#19, sum#28, count#29, sum#30, count#31, sum#32, count#33, sum#34, count#35]
Arguments: hashpartitioning(i_item_id#19, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(29) HashAggregate [codegen id : 6]
Input [9]: [i_item_id#19, sum#28, count#29, sum#30, count#31, sum#32, count#33, sum#34, count#35]
Keys [1]: [i_item_id#19]
Functions [4]: [avg(ss_quantity#4), avg(UnscaledValue(ss_list_price#5)), avg(UnscaledValue(ss_coupon_amt#7)), avg(UnscaledValue(ss_sales_price#6))]
Aggregate Attributes [4]: [avg(ss_quantity#4)#36, avg(UnscaledValue(ss_list_price#5))#37, avg(UnscaledValue(ss_coupon_amt#7))#38, avg(UnscaledValue(ss_sales_price#6))#39]
Results [5]: [i_item_id#19, avg(ss_quantity#4)#36 AS agg1#40, cast((avg(UnscaledValue(ss_list_price#5))#37 / 100.0) as decimal(11,6)) AS agg2#41, cast((avg(UnscaledValue(ss_coupon_amt#7))#38 / 100.0) as decimal(11,6)) AS agg3#42, cast((avg(UnscaledValue(ss_sales_price#6))#39 / 100.0) as decimal(11,6)) AS agg4#43]

(30) TakeOrderedAndProject
Input [5]: [i_item_id#19, agg1#40, agg2#41, agg3#42, agg4#43]
Arguments: 100, [i_item_id#19 ASC NULLS FIRST], [i_item_id#19, agg1#40, agg2#41, agg3#42, agg4#43]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ss_sold_date_sk#8 IN dynamicpruning#9
BroadcastExchange (35)
+- * Project (34)
   +- * Filter (33)
      +- * ColumnarToRow (32)
         +- Scan parquet spark_catalog.default.date_dim (31)


(31) Scan parquet spark_catalog.default.date_dim
Output [2]: [d_date_sk#10, d_year#44]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_year), EqualTo(d_year,1998), GreaterThanOrEqual(d_date_sk,2450815), LessThanOrEqual(d_date_sk,2451179), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int>

(32) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#10, d_year#44]

(33) Filter [codegen id : 1]
Input [2]: [d_date_sk#10, d_year#44]
Condition : ((((isnotnull(d_year#44) AND (d_year#44 = 1998)) AND (d_date_sk#10 >= 2450815)) AND (d_date_sk#10 <= 2451179)) AND isnotnull(d_date_sk#10))

(34) Project [codegen id : 1]
Output [1]: [d_date_sk#10]
Input [2]: [d_date_sk#10, d_year#44]

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


