== 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 default.catalog_sales (1)
               :     :     :     +- BroadcastExchange (8)
               :     :     :        +- * Project (7)
               :     :     :           +- * Filter (6)
               :     :     :              +- * ColumnarToRow (5)
               :     :     :                 +- Scan parquet default.customer_demographics (4)
               :     :     +- ReusedExchange (11)
               :     +- BroadcastExchange (17)
               :        +- * Filter (16)
               :           +- * ColumnarToRow (15)
               :              +- Scan parquet default.item (14)
               +- BroadcastExchange (24)
                  +- * Project (23)
                     +- * Filter (22)
                        +- * ColumnarToRow (21)
                           +- Scan parquet default.promotion (20)


(1) Scan parquet 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 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), [id=#14]

(9) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [cs_bill_cdemo_sk#1]
Right keys [1]: [cd_demo_sk#10]
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#15]

(12) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [cs_sold_date_sk#8]
Right keys [1]: [d_date_sk#15]
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#15]

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

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

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

(18) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [cs_item_sk#2]
Right keys [1]: [i_item_sk#16]
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#17]
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#16, i_item_id#17]

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

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

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

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

(25) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [cs_promo_sk#3]
Right keys [1]: [p_promo_sk#19]
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#17]
Input [7]: [cs_promo_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, i_item_id#17, p_promo_sk#19]

(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#17]
Keys [1]: [i_item_id#17]
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#23, count#24, sum#25, count#26, sum#27, count#28, sum#29, count#30]
Results [9]: [i_item_id#17, sum#31, count#32, sum#33, count#34, sum#35, count#36, sum#37, count#38]

(28) Exchange
Input [9]: [i_item_id#17, sum#31, count#32, sum#33, count#34, sum#35, count#36, sum#37, count#38]
Arguments: hashpartitioning(i_item_id#17, 5), ENSURE_REQUIREMENTS, [id=#39]

(29) HashAggregate [codegen id : 6]
Input [9]: [i_item_id#17, sum#31, count#32, sum#33, count#34, sum#35, count#36, sum#37, count#38]
Keys [1]: [i_item_id#17]
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)#40, avg(UnscaledValue(cs_list_price#5))#41, avg(UnscaledValue(cs_coupon_amt#7))#42, avg(UnscaledValue(cs_sales_price#6))#43]
Results [5]: [i_item_id#17, avg(cs_quantity#4)#40 AS agg1#44, cast((avg(UnscaledValue(cs_list_price#5))#41 / 100.0) as decimal(11,6)) AS agg2#45, cast((avg(UnscaledValue(cs_coupon_amt#7))#42 / 100.0) as decimal(11,6)) AS agg3#46, cast((avg(UnscaledValue(cs_sales_price#6))#43 / 100.0) as decimal(11,6)) AS agg4#47]

(30) TakeOrderedAndProject
Input [5]: [i_item_id#17, agg1#44, agg2#45, agg3#46, agg4#47]
Arguments: 100, [i_item_id#17 ASC NULLS FIRST], [i_item_id#17, agg1#44, agg2#45, agg3#46, agg4#47]

===== 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 default.date_dim (31)


(31) Scan parquet default.date_dim
Output [2]: [d_date_sk#15, d_year#48]
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#15, d_year#48]

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

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

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


