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


(1) Scan parquet spark_catalog.default.catalog_sales
Output [8]: [cs_bill_cdemo_sk#1, cs_item_sk#2, cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_sold_date_sk#8]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(cs_sold_date_sk#8), dynamicpruningexpression(cs_sold_date_sk#8 IN dynamicpruning#9)]
PushedFilters: [IsNotNull(cs_bill_cdemo_sk), IsNotNull(cs_item_sk), IsNotNull(cs_promo_sk)]
ReadSchema: struct<cs_bill_cdemo_sk:int,cs_item_sk:int,cs_promo_sk:int,cs_quantity:int,cs_list_price:decimal(7,2),cs_sales_price:decimal(7,2),cs_coupon_amt:decimal(7,2)>

(2) ColumnarToRow [codegen id : 5]
Input [8]: [cs_bill_cdemo_sk#1, cs_item_sk#2, cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_sold_date_sk#8]

(3) Filter [codegen id : 5]
Input [8]: [cs_bill_cdemo_sk#1, cs_item_sk#2, cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_sold_date_sk#8]
Condition : ((isnotnull(cs_bill_cdemo_sk#1) AND isnotnull(cs_item_sk#2)) AND isnotnull(cs_promo_sk#3))

(4) Scan parquet spark_catalog.default.customer_demographics
Output [4]: [cd_demo_sk#10, cd_gender#11, cd_marital_status#12, cd_education_status#13]
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,M), EqualTo(cd_marital_status,S), EqualTo(cd_education_status,College             ), IsNotNull(cd_demo_sk)]
ReadSchema: struct<cd_demo_sk:int,cd_gender:string,cd_marital_status:string,cd_education_status:string>

(5) ColumnarToRow [codegen id : 1]
Input [4]: [cd_demo_sk#10, cd_gender#11, cd_marital_status#12, cd_education_status#13]

(6) Filter [codegen id : 1]
Input [4]: [cd_demo_sk#10, cd_gender#11, cd_marital_status#12, cd_education_status#13]
Condition : ((((((isnotnull(cd_gender#11) AND isnotnull(cd_marital_status#12)) AND isnotnull(cd_education_status#13)) AND (cd_gender#11 = M)) AND (cd_marital_status#12 = S)) AND (cd_education_status#13 = College             )) AND isnotnull(cd_demo_sk#10))

(7) Project [codegen id : 1]
Output [1]: [cd_demo_sk#10]
Input [4]: [cd_demo_sk#10, cd_gender#11, cd_marital_status#12, cd_education_status#13]

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

(9) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [cs_bill_cdemo_sk#1]
Right keys [1]: [cd_demo_sk#10]
Join type: Inner
Join condition: None

(10) Project [codegen id : 5]
Output [7]: [cs_item_sk#2, cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_sold_date_sk#8]
Input [9]: [cs_bill_cdemo_sk#1, cs_item_sk#2, cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_sold_date_sk#8, cd_demo_sk#10]

(11) ReusedExchange [Reuses operator id: 35]
Output [1]: [d_date_sk#14]

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

(13) Project [codegen id : 5]
Output [6]: [cs_item_sk#2, cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7]
Input [8]: [cs_item_sk#2, cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_sold_date_sk#8, d_date_sk#14]

(14) Scan parquet spark_catalog.default.item
Output [2]: [i_item_sk#15, i_item_id#16]
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>

(15) ColumnarToRow [codegen id : 3]
Input [2]: [i_item_sk#15, i_item_id#16]

(16) Filter [codegen id : 3]
Input [2]: [i_item_sk#15, i_item_id#16]
Condition : isnotnull(i_item_sk#15)

(17) BroadcastExchange
Input [2]: [i_item_sk#15, i_item_id#16]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=2]

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

(19) Project [codegen id : 5]
Output [6]: [cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, i_item_id#16]
Input [8]: [cs_item_sk#2, cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, i_item_sk#15, i_item_id#16]

(20) Scan parquet spark_catalog.default.promotion
Output [3]: [p_promo_sk#17, p_channel_email#18, p_channel_event#19]
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>

(21) ColumnarToRow [codegen id : 4]
Input [3]: [p_promo_sk#17, p_channel_email#18, p_channel_event#19]

(22) Filter [codegen id : 4]
Input [3]: [p_promo_sk#17, p_channel_email#18, p_channel_event#19]
Condition : (((p_channel_email#18 = N) OR (p_channel_event#19 = N)) AND isnotnull(p_promo_sk#17))

(23) Project [codegen id : 4]
Output [1]: [p_promo_sk#17]
Input [3]: [p_promo_sk#17, p_channel_email#18, p_channel_event#19]

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

(25) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [cs_promo_sk#3]
Right keys [1]: [p_promo_sk#17]
Join type: Inner
Join condition: None

(26) Project [codegen id : 5]
Output [5]: [cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, i_item_id#16]
Input [7]: [cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, i_item_id#16, p_promo_sk#17]

(27) HashAggregate [codegen id : 5]
Input [5]: [cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, i_item_id#16]
Keys [1]: [i_item_id#16]
Functions [4]: [partial_avg(cs_quantity#4), partial_avg(UnscaledValue(cs_list_price#5)), partial_avg(UnscaledValue(cs_coupon_amt#7)), partial_avg(UnscaledValue(cs_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#16, sum#28, count#29, sum#30, count#31, sum#32, count#33, sum#34, count#35]

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

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

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

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = cs_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#14, d_year#44]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_year), EqualTo(d_year,2000), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int>

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

(33) Filter [codegen id : 1]
Input [2]: [d_date_sk#14, d_year#44]
Condition : ((isnotnull(d_year#44) AND (d_year#44 = 2000)) AND isnotnull(d_date_sk#14))

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

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


