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


(1) Scan parquet spark_catalog.default.store_sales
Output [10]: [ss_cdemo_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_quantity#5, ss_sales_price#6, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9, ss_sold_date_sk#10]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#10), dynamicpruningexpression(ss_sold_date_sk#10 IN dynamicpruning#11)]
PushedFilters: [IsNotNull(ss_store_sk), IsNotNull(ss_addr_sk), IsNotNull(ss_cdemo_sk), IsNotNull(ss_hdemo_sk), Or(Or(And(GreaterThanOrEqual(ss_net_profit,100.00),LessThanOrEqual(ss_net_profit,200.00)),And(GreaterThanOrEqual(ss_net_profit,150.00),LessThanOrEqual(ss_net_profit,300.00))),And(GreaterThanOrEqual(ss_net_profit,50.00),LessThanOrEqual(ss_net_profit,250.00))), Or(Or(And(GreaterThanOrEqual(ss_sales_price,100.00),LessThanOrEqual(ss_sales_price,150.00)),And(GreaterThanOrEqual(ss_sales_price,50.00),LessThanOrEqual(ss_sales_price,100.00))),And(GreaterThanOrEqual(ss_sales_price,150.00),LessThanOrEqual(ss_sales_price,200.00)))]
ReadSchema: struct<ss_cdemo_sk:int,ss_hdemo_sk:int,ss_addr_sk:int,ss_store_sk:int,ss_quantity:int,ss_sales_price:decimal(7,2),ss_ext_sales_price:decimal(7,2),ss_ext_wholesale_cost:decimal(7,2),ss_net_profit:decimal(7,2)>

(2) ColumnarToRow [codegen id : 6]
Input [10]: [ss_cdemo_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_quantity#5, ss_sales_price#6, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9, ss_sold_date_sk#10]

(3) Filter [codegen id : 6]
Input [10]: [ss_cdemo_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_quantity#5, ss_sales_price#6, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9, ss_sold_date_sk#10]
Condition : (((((isnotnull(ss_store_sk#4) AND isnotnull(ss_addr_sk#3)) AND isnotnull(ss_cdemo_sk#1)) AND isnotnull(ss_hdemo_sk#2)) AND ((((ss_net_profit#9 >= 100.00) AND (ss_net_profit#9 <= 200.00)) OR ((ss_net_profit#9 >= 150.00) AND (ss_net_profit#9 <= 300.00))) OR ((ss_net_profit#9 >= 50.00) AND (ss_net_profit#9 <= 250.00)))) AND ((((ss_sales_price#6 >= 100.00) AND (ss_sales_price#6 <= 150.00)) OR ((ss_sales_price#6 >= 50.00) AND (ss_sales_price#6 <= 100.00))) OR ((ss_sales_price#6 >= 150.00) AND (ss_sales_price#6 <= 200.00))))

(4) Scan parquet spark_catalog.default.customer_demographics
Output [3]: [cd_demo_sk#12, cd_marital_status#13, cd_education_status#14]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_demographics]
PushedFilters: [IsNotNull(cd_demo_sk), Or(Or(And(EqualTo(cd_marital_status,M),EqualTo(cd_education_status,Advanced Degree     )),And(EqualTo(cd_marital_status,S),EqualTo(cd_education_status,College             ))),And(EqualTo(cd_marital_status,W),EqualTo(cd_education_status,2 yr Degree         )))]
ReadSchema: struct<cd_demo_sk:int,cd_marital_status:string,cd_education_status:string>

(5) ColumnarToRow [codegen id : 1]
Input [3]: [cd_demo_sk#12, cd_marital_status#13, cd_education_status#14]

(6) Filter [codegen id : 1]
Input [3]: [cd_demo_sk#12, cd_marital_status#13, cd_education_status#14]
Condition : (isnotnull(cd_demo_sk#12) AND ((((cd_marital_status#13 = M) AND (cd_education_status#14 = Advanced Degree     )) OR ((cd_marital_status#13 = S) AND (cd_education_status#14 = College             ))) OR ((cd_marital_status#13 = W) AND (cd_education_status#14 = 2 yr Degree         ))))

(7) BroadcastExchange
Input [3]: [cd_demo_sk#12, cd_marital_status#13, cd_education_status#14]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=1]

(8) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [ss_cdemo_sk#1]
Right keys [1]: [cd_demo_sk#12]
Join type: Inner
Join condition: ((((((cd_marital_status#13 = M) AND (cd_education_status#14 = Advanced Degree     )) AND (ss_sales_price#6 >= 100.00)) AND (ss_sales_price#6 <= 150.00)) OR ((((cd_marital_status#13 = S) AND (cd_education_status#14 = College             )) AND (ss_sales_price#6 >= 50.00)) AND (ss_sales_price#6 <= 100.00))) OR ((((cd_marital_status#13 = W) AND (cd_education_status#14 = 2 yr Degree         )) AND (ss_sales_price#6 >= 150.00)) AND (ss_sales_price#6 <= 200.00)))

(9) Project [codegen id : 6]
Output [11]: [ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_quantity#5, ss_sales_price#6, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9, ss_sold_date_sk#10, cd_marital_status#13, cd_education_status#14]
Input [13]: [ss_cdemo_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_quantity#5, ss_sales_price#6, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9, ss_sold_date_sk#10, cd_demo_sk#12, cd_marital_status#13, cd_education_status#14]

(10) Scan parquet spark_catalog.default.household_demographics
Output [2]: [hd_demo_sk#15, hd_dep_count#16]
Batched: true
Location [not included in comparison]/{warehouse_dir}/household_demographics]
PushedFilters: [IsNotNull(hd_demo_sk), Or(EqualTo(hd_dep_count,3),EqualTo(hd_dep_count,1))]
ReadSchema: struct<hd_demo_sk:int,hd_dep_count:int>

(11) ColumnarToRow [codegen id : 2]
Input [2]: [hd_demo_sk#15, hd_dep_count#16]

(12) Filter [codegen id : 2]
Input [2]: [hd_demo_sk#15, hd_dep_count#16]
Condition : (isnotnull(hd_demo_sk#15) AND ((hd_dep_count#16 = 3) OR (hd_dep_count#16 = 1)))

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

(14) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [ss_hdemo_sk#2]
Right keys [1]: [hd_demo_sk#15]
Join type: Inner
Join condition: (((((((cd_marital_status#13 = M) AND (cd_education_status#14 = Advanced Degree     )) AND (ss_sales_price#6 >= 100.00)) AND (ss_sales_price#6 <= 150.00)) AND (hd_dep_count#16 = 3)) OR (((((cd_marital_status#13 = S) AND (cd_education_status#14 = College             )) AND (ss_sales_price#6 >= 50.00)) AND (ss_sales_price#6 <= 100.00)) AND (hd_dep_count#16 = 1))) OR (((((cd_marital_status#13 = W) AND (cd_education_status#14 = 2 yr Degree         )) AND (ss_sales_price#6 >= 150.00)) AND (ss_sales_price#6 <= 200.00)) AND (hd_dep_count#16 = 1)))

(15) Project [codegen id : 6]
Output [7]: [ss_addr_sk#3, ss_store_sk#4, ss_quantity#5, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9, ss_sold_date_sk#10]
Input [13]: [ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_quantity#5, ss_sales_price#6, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9, ss_sold_date_sk#10, cd_marital_status#13, cd_education_status#14, hd_demo_sk#15, hd_dep_count#16]

(16) ReusedExchange [Reuses operator id: 39]
Output [1]: [d_date_sk#17]

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

(18) Project [codegen id : 6]
Output [6]: [ss_addr_sk#3, ss_store_sk#4, ss_quantity#5, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9]
Input [8]: [ss_addr_sk#3, ss_store_sk#4, ss_quantity#5, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9, ss_sold_date_sk#10, d_date_sk#17]

(19) Scan parquet spark_catalog.default.store
Output [1]: [s_store_sk#18]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store]
PushedFilters: [IsNotNull(s_store_sk)]
ReadSchema: struct<s_store_sk:int>

(20) ColumnarToRow [codegen id : 4]
Input [1]: [s_store_sk#18]

(21) Filter [codegen id : 4]
Input [1]: [s_store_sk#18]
Condition : isnotnull(s_store_sk#18)

(22) BroadcastExchange
Input [1]: [s_store_sk#18]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=3]

(23) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [ss_store_sk#4]
Right keys [1]: [s_store_sk#18]
Join type: Inner
Join condition: None

(24) Project [codegen id : 6]
Output [5]: [ss_addr_sk#3, ss_quantity#5, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9]
Input [7]: [ss_addr_sk#3, ss_store_sk#4, ss_quantity#5, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9, s_store_sk#18]

(25) Scan parquet spark_catalog.default.customer_address
Output [3]: [ca_address_sk#19, ca_state#20, ca_country#21]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_address]
PushedFilters: [IsNotNull(ca_country), EqualTo(ca_country,United States), IsNotNull(ca_address_sk), Or(Or(In(ca_state, [OH,TX]),In(ca_state, [KY,NM,OR])),In(ca_state, [MS,TX,VA]))]
ReadSchema: struct<ca_address_sk:int,ca_state:string,ca_country:string>

(26) ColumnarToRow [codegen id : 5]
Input [3]: [ca_address_sk#19, ca_state#20, ca_country#21]

(27) Filter [codegen id : 5]
Input [3]: [ca_address_sk#19, ca_state#20, ca_country#21]
Condition : (((isnotnull(ca_country#21) AND (ca_country#21 = United States)) AND isnotnull(ca_address_sk#19)) AND ((ca_state#20 IN (TX,OH) OR ca_state#20 IN (OR,NM,KY)) OR ca_state#20 IN (VA,TX,MS)))

(28) Project [codegen id : 5]
Output [2]: [ca_address_sk#19, ca_state#20]
Input [3]: [ca_address_sk#19, ca_state#20, ca_country#21]

(29) BroadcastExchange
Input [2]: [ca_address_sk#19, ca_state#20]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=4]

(30) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [ss_addr_sk#3]
Right keys [1]: [ca_address_sk#19]
Join type: Inner
Join condition: ((((ca_state#20 IN (TX,OH) AND (ss_net_profit#9 >= 100.00)) AND (ss_net_profit#9 <= 200.00)) OR ((ca_state#20 IN (OR,NM,KY) AND (ss_net_profit#9 >= 150.00)) AND (ss_net_profit#9 <= 300.00))) OR ((ca_state#20 IN (VA,TX,MS) AND (ss_net_profit#9 >= 50.00)) AND (ss_net_profit#9 <= 250.00)))

(31) Project [codegen id : 6]
Output [3]: [ss_quantity#5, ss_ext_sales_price#7, ss_ext_wholesale_cost#8]
Input [7]: [ss_addr_sk#3, ss_quantity#5, ss_ext_sales_price#7, ss_ext_wholesale_cost#8, ss_net_profit#9, ca_address_sk#19, ca_state#20]

(32) HashAggregate [codegen id : 6]
Input [3]: [ss_quantity#5, ss_ext_sales_price#7, ss_ext_wholesale_cost#8]
Keys: []
Functions [4]: [partial_avg(ss_quantity#5), partial_avg(UnscaledValue(ss_ext_sales_price#7)), partial_avg(UnscaledValue(ss_ext_wholesale_cost#8)), partial_sum(UnscaledValue(ss_ext_wholesale_cost#8))]
Aggregate Attributes [7]: [sum#22, count#23, sum#24, count#25, sum#26, count#27, sum#28]
Results [7]: [sum#29, count#30, sum#31, count#32, sum#33, count#34, sum#35]

(33) Exchange
Input [7]: [sum#29, count#30, sum#31, count#32, sum#33, count#34, sum#35]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, [plan_id=5]

(34) HashAggregate [codegen id : 7]
Input [7]: [sum#29, count#30, sum#31, count#32, sum#33, count#34, sum#35]
Keys: []
Functions [4]: [avg(ss_quantity#5), avg(UnscaledValue(ss_ext_sales_price#7)), avg(UnscaledValue(ss_ext_wholesale_cost#8)), sum(UnscaledValue(ss_ext_wholesale_cost#8))]
Aggregate Attributes [4]: [avg(ss_quantity#5)#36, avg(UnscaledValue(ss_ext_sales_price#7))#37, avg(UnscaledValue(ss_ext_wholesale_cost#8))#38, sum(UnscaledValue(ss_ext_wholesale_cost#8))#39]
Results [4]: [avg(ss_quantity#5)#36 AS avg(ss_quantity)#40, cast((avg(UnscaledValue(ss_ext_sales_price#7))#37 / 100.0) as decimal(11,6)) AS avg(ss_ext_sales_price)#41, cast((avg(UnscaledValue(ss_ext_wholesale_cost#8))#38 / 100.0) as decimal(11,6)) AS avg(ss_ext_wholesale_cost)#42, MakeDecimal(sum(UnscaledValue(ss_ext_wholesale_cost#8))#39,17,2) AS sum(ss_ext_wholesale_cost)#43]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ss_sold_date_sk#10 IN dynamicpruning#11
BroadcastExchange (39)
+- * Project (38)
   +- * Filter (37)
      +- * ColumnarToRow (36)
         +- Scan parquet spark_catalog.default.date_dim (35)


(35) Scan parquet spark_catalog.default.date_dim
Output [2]: [d_date_sk#17, d_year#44]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_year), EqualTo(d_year,2001), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int>

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

(37) Filter [codegen id : 1]
Input [2]: [d_date_sk#17, d_year#44]
Condition : ((isnotnull(d_year#44) AND (d_year#44 = 2001)) AND isnotnull(d_date_sk#17))

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

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


