== Physical Plan ==
TakeOrderedAndProject (49)
+- * Project (48)
   +- * BroadcastHashJoin Inner BuildRight (47)
      :- * Project (41)
      :  +- * BroadcastHashJoin Inner BuildRight (40)
      :     :- * Project (35)
      :     :  +- * BroadcastHashJoin Inner BuildRight (34)
      :     :     :- * Filter (16)
      :     :     :  +- * HashAggregate (15)
      :     :     :     +- Exchange (14)
      :     :     :        +- * HashAggregate (13)
      :     :     :           +- * Project (12)
      :     :     :              +- * BroadcastHashJoin Inner BuildRight (11)
      :     :     :                 :- * Project (6)
      :     :     :                 :  +- * BroadcastHashJoin Inner BuildRight (5)
      :     :     :                 :     :- * Filter (3)
      :     :     :                 :     :  +- * ColumnarToRow (2)
      :     :     :                 :     :     +- Scan parquet spark_catalog.default.web_returns (1)
      :     :     :                 :     +- ReusedExchange (4)
      :     :     :                 +- BroadcastExchange (10)
      :     :     :                    +- * Filter (9)
      :     :     :                       +- * ColumnarToRow (8)
      :     :     :                          +- Scan parquet spark_catalog.default.customer_address (7)
      :     :     +- BroadcastExchange (33)
      :     :        +- * Filter (32)
      :     :           +- * HashAggregate (31)
      :     :              +- Exchange (30)
      :     :                 +- * HashAggregate (29)
      :     :                    +- * HashAggregate (28)
      :     :                       +- Exchange (27)
      :     :                          +- * HashAggregate (26)
      :     :                             +- * Project (25)
      :     :                                +- * BroadcastHashJoin Inner BuildRight (24)
      :     :                                   :- * Project (22)
      :     :                                   :  +- * BroadcastHashJoin Inner BuildRight (21)
      :     :                                   :     :- * Filter (19)
      :     :                                   :     :  +- * ColumnarToRow (18)
      :     :                                   :     :     +- Scan parquet spark_catalog.default.web_returns (17)
      :     :                                   :     +- ReusedExchange (20)
      :     :                                   +- ReusedExchange (23)
      :     +- BroadcastExchange (39)
      :        +- * Filter (38)
      :           +- * ColumnarToRow (37)
      :              +- Scan parquet spark_catalog.default.customer (36)
      +- BroadcastExchange (46)
         +- * Project (45)
            +- * Filter (44)
               +- * ColumnarToRow (43)
                  +- Scan parquet spark_catalog.default.customer_address (42)


(1) Scan parquet spark_catalog.default.web_returns
Output [4]: [wr_returning_customer_sk#1, wr_returning_addr_sk#2, wr_return_amt#3, wr_returned_date_sk#4]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(wr_returned_date_sk#4), dynamicpruningexpression(wr_returned_date_sk#4 IN dynamicpruning#5)]
PushedFilters: [IsNotNull(wr_returning_addr_sk), IsNotNull(wr_returning_customer_sk)]
ReadSchema: struct<wr_returning_customer_sk:int,wr_returning_addr_sk:int,wr_return_amt:decimal(7,2)>

(2) ColumnarToRow [codegen id : 3]
Input [4]: [wr_returning_customer_sk#1, wr_returning_addr_sk#2, wr_return_amt#3, wr_returned_date_sk#4]

(3) Filter [codegen id : 3]
Input [4]: [wr_returning_customer_sk#1, wr_returning_addr_sk#2, wr_return_amt#3, wr_returned_date_sk#4]
Condition : (isnotnull(wr_returning_addr_sk#2) AND isnotnull(wr_returning_customer_sk#1))

(4) ReusedExchange [Reuses operator id: 54]
Output [1]: [d_date_sk#6]

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

(6) Project [codegen id : 3]
Output [3]: [wr_returning_customer_sk#1, wr_returning_addr_sk#2, wr_return_amt#3]
Input [5]: [wr_returning_customer_sk#1, wr_returning_addr_sk#2, wr_return_amt#3, wr_returned_date_sk#4, d_date_sk#6]

(7) Scan parquet spark_catalog.default.customer_address
Output [2]: [ca_address_sk#7, ca_state#8]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_address]
PushedFilters: [IsNotNull(ca_address_sk), IsNotNull(ca_state)]
ReadSchema: struct<ca_address_sk:int,ca_state:string>

(8) ColumnarToRow [codegen id : 2]
Input [2]: [ca_address_sk#7, ca_state#8]

(9) Filter [codegen id : 2]
Input [2]: [ca_address_sk#7, ca_state#8]
Condition : (isnotnull(ca_address_sk#7) AND isnotnull(ca_state#8))

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

(11) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [wr_returning_addr_sk#2]
Right keys [1]: [ca_address_sk#7]
Join type: Inner
Join condition: None

(12) Project [codegen id : 3]
Output [3]: [wr_returning_customer_sk#1, wr_return_amt#3, ca_state#8]
Input [5]: [wr_returning_customer_sk#1, wr_returning_addr_sk#2, wr_return_amt#3, ca_address_sk#7, ca_state#8]

(13) HashAggregate [codegen id : 3]
Input [3]: [wr_returning_customer_sk#1, wr_return_amt#3, ca_state#8]
Keys [2]: [wr_returning_customer_sk#1, ca_state#8]
Functions [1]: [partial_sum(UnscaledValue(wr_return_amt#3))]
Aggregate Attributes [1]: [sum#9]
Results [3]: [wr_returning_customer_sk#1, ca_state#8, sum#10]

(14) Exchange
Input [3]: [wr_returning_customer_sk#1, ca_state#8, sum#10]
Arguments: hashpartitioning(wr_returning_customer_sk#1, ca_state#8, 5), ENSURE_REQUIREMENTS, [plan_id=2]

(15) HashAggregate [codegen id : 11]
Input [3]: [wr_returning_customer_sk#1, ca_state#8, sum#10]
Keys [2]: [wr_returning_customer_sk#1, ca_state#8]
Functions [1]: [sum(UnscaledValue(wr_return_amt#3))]
Aggregate Attributes [1]: [sum(UnscaledValue(wr_return_amt#3))#11]
Results [3]: [wr_returning_customer_sk#1 AS ctr_customer_sk#12, ca_state#8 AS ctr_state#13, MakeDecimal(sum(UnscaledValue(wr_return_amt#3))#11,17,2) AS ctr_total_return#14]

(16) Filter [codegen id : 11]
Input [3]: [ctr_customer_sk#12, ctr_state#13, ctr_total_return#14]
Condition : isnotnull(ctr_total_return#14)

(17) Scan parquet spark_catalog.default.web_returns
Output [4]: [wr_returning_customer_sk#15, wr_returning_addr_sk#16, wr_return_amt#17, wr_returned_date_sk#18]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(wr_returned_date_sk#18), dynamicpruningexpression(wr_returned_date_sk#18 IN dynamicpruning#5)]
PushedFilters: [IsNotNull(wr_returning_addr_sk)]
ReadSchema: struct<wr_returning_customer_sk:int,wr_returning_addr_sk:int,wr_return_amt:decimal(7,2)>

(18) ColumnarToRow [codegen id : 6]
Input [4]: [wr_returning_customer_sk#15, wr_returning_addr_sk#16, wr_return_amt#17, wr_returned_date_sk#18]

(19) Filter [codegen id : 6]
Input [4]: [wr_returning_customer_sk#15, wr_returning_addr_sk#16, wr_return_amt#17, wr_returned_date_sk#18]
Condition : isnotnull(wr_returning_addr_sk#16)

(20) ReusedExchange [Reuses operator id: 54]
Output [1]: [d_date_sk#19]

(21) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [wr_returned_date_sk#18]
Right keys [1]: [d_date_sk#19]
Join type: Inner
Join condition: None

(22) Project [codegen id : 6]
Output [3]: [wr_returning_customer_sk#15, wr_returning_addr_sk#16, wr_return_amt#17]
Input [5]: [wr_returning_customer_sk#15, wr_returning_addr_sk#16, wr_return_amt#17, wr_returned_date_sk#18, d_date_sk#19]

(23) ReusedExchange [Reuses operator id: 10]
Output [2]: [ca_address_sk#20, ca_state#21]

(24) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [wr_returning_addr_sk#16]
Right keys [1]: [ca_address_sk#20]
Join type: Inner
Join condition: None

(25) Project [codegen id : 6]
Output [3]: [wr_returning_customer_sk#15, wr_return_amt#17, ca_state#21]
Input [5]: [wr_returning_customer_sk#15, wr_returning_addr_sk#16, wr_return_amt#17, ca_address_sk#20, ca_state#21]

(26) HashAggregate [codegen id : 6]
Input [3]: [wr_returning_customer_sk#15, wr_return_amt#17, ca_state#21]
Keys [2]: [wr_returning_customer_sk#15, ca_state#21]
Functions [1]: [partial_sum(UnscaledValue(wr_return_amt#17))]
Aggregate Attributes [1]: [sum#22]
Results [3]: [wr_returning_customer_sk#15, ca_state#21, sum#23]

(27) Exchange
Input [3]: [wr_returning_customer_sk#15, ca_state#21, sum#23]
Arguments: hashpartitioning(wr_returning_customer_sk#15, ca_state#21, 5), ENSURE_REQUIREMENTS, [plan_id=3]

(28) HashAggregate [codegen id : 7]
Input [3]: [wr_returning_customer_sk#15, ca_state#21, sum#23]
Keys [2]: [wr_returning_customer_sk#15, ca_state#21]
Functions [1]: [sum(UnscaledValue(wr_return_amt#17))]
Aggregate Attributes [1]: [sum(UnscaledValue(wr_return_amt#17))#11]
Results [2]: [ca_state#21 AS ctr_state#24, MakeDecimal(sum(UnscaledValue(wr_return_amt#17))#11,17,2) AS ctr_total_return#25]

(29) HashAggregate [codegen id : 7]
Input [2]: [ctr_state#24, ctr_total_return#25]
Keys [1]: [ctr_state#24]
Functions [1]: [partial_avg(ctr_total_return#25)]
Aggregate Attributes [2]: [sum#26, count#27]
Results [3]: [ctr_state#24, sum#28, count#29]

(30) Exchange
Input [3]: [ctr_state#24, sum#28, count#29]
Arguments: hashpartitioning(ctr_state#24, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(31) HashAggregate [codegen id : 8]
Input [3]: [ctr_state#24, sum#28, count#29]
Keys [1]: [ctr_state#24]
Functions [1]: [avg(ctr_total_return#25)]
Aggregate Attributes [1]: [avg(ctr_total_return#25)#30]
Results [2]: [(avg(ctr_total_return#25)#30 * 1.2) AS (avg(ctr_total_return) * 1.2)#31, ctr_state#24]

(32) Filter [codegen id : 8]
Input [2]: [(avg(ctr_total_return) * 1.2)#31, ctr_state#24]
Condition : isnotnull((avg(ctr_total_return) * 1.2)#31)

(33) BroadcastExchange
Input [2]: [(avg(ctr_total_return) * 1.2)#31, ctr_state#24]
Arguments: HashedRelationBroadcastMode(List(input[1, string, true]),false), [plan_id=5]

(34) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [ctr_state#13]
Right keys [1]: [ctr_state#24]
Join type: Inner
Join condition: (cast(ctr_total_return#14 as decimal(24,7)) > (avg(ctr_total_return) * 1.2)#31)

(35) Project [codegen id : 11]
Output [2]: [ctr_customer_sk#12, ctr_total_return#14]
Input [5]: [ctr_customer_sk#12, ctr_state#13, ctr_total_return#14, (avg(ctr_total_return) * 1.2)#31, ctr_state#24]

(36) Scan parquet spark_catalog.default.customer
Output [14]: [c_customer_sk#32, c_customer_id#33, c_current_addr_sk#34, c_salutation#35, c_first_name#36, c_last_name#37, c_preferred_cust_flag#38, c_birth_day#39, c_birth_month#40, c_birth_year#41, c_birth_country#42, c_login#43, c_email_address#44, c_last_review_date#45]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer]
PushedFilters: [IsNotNull(c_customer_sk), IsNotNull(c_current_addr_sk)]
ReadSchema: struct<c_customer_sk:int,c_customer_id:string,c_current_addr_sk:int,c_salutation:string,c_first_name:string,c_last_name:string,c_preferred_cust_flag:string,c_birth_day:int,c_birth_month:int,c_birth_year:int,c_birth_country:string,c_login:string,c_email_address:string,c_last_review_date:int>

(37) ColumnarToRow [codegen id : 9]
Input [14]: [c_customer_sk#32, c_customer_id#33, c_current_addr_sk#34, c_salutation#35, c_first_name#36, c_last_name#37, c_preferred_cust_flag#38, c_birth_day#39, c_birth_month#40, c_birth_year#41, c_birth_country#42, c_login#43, c_email_address#44, c_last_review_date#45]

(38) Filter [codegen id : 9]
Input [14]: [c_customer_sk#32, c_customer_id#33, c_current_addr_sk#34, c_salutation#35, c_first_name#36, c_last_name#37, c_preferred_cust_flag#38, c_birth_day#39, c_birth_month#40, c_birth_year#41, c_birth_country#42, c_login#43, c_email_address#44, c_last_review_date#45]
Condition : (isnotnull(c_customer_sk#32) AND isnotnull(c_current_addr_sk#34))

(39) BroadcastExchange
Input [14]: [c_customer_sk#32, c_customer_id#33, c_current_addr_sk#34, c_salutation#35, c_first_name#36, c_last_name#37, c_preferred_cust_flag#38, c_birth_day#39, c_birth_month#40, c_birth_year#41, c_birth_country#42, c_login#43, c_email_address#44, c_last_review_date#45]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=6]

(40) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [ctr_customer_sk#12]
Right keys [1]: [c_customer_sk#32]
Join type: Inner
Join condition: None

(41) Project [codegen id : 11]
Output [14]: [ctr_total_return#14, c_customer_id#33, c_current_addr_sk#34, c_salutation#35, c_first_name#36, c_last_name#37, c_preferred_cust_flag#38, c_birth_day#39, c_birth_month#40, c_birth_year#41, c_birth_country#42, c_login#43, c_email_address#44, c_last_review_date#45]
Input [16]: [ctr_customer_sk#12, ctr_total_return#14, c_customer_sk#32, c_customer_id#33, c_current_addr_sk#34, c_salutation#35, c_first_name#36, c_last_name#37, c_preferred_cust_flag#38, c_birth_day#39, c_birth_month#40, c_birth_year#41, c_birth_country#42, c_login#43, c_email_address#44, c_last_review_date#45]

(42) Scan parquet spark_catalog.default.customer_address
Output [2]: [ca_address_sk#46, ca_state#47]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_address]
PushedFilters: [IsNotNull(ca_state), EqualTo(ca_state,GA), IsNotNull(ca_address_sk)]
ReadSchema: struct<ca_address_sk:int,ca_state:string>

(43) ColumnarToRow [codegen id : 10]
Input [2]: [ca_address_sk#46, ca_state#47]

(44) Filter [codegen id : 10]
Input [2]: [ca_address_sk#46, ca_state#47]
Condition : ((isnotnull(ca_state#47) AND (ca_state#47 = GA)) AND isnotnull(ca_address_sk#46))

(45) Project [codegen id : 10]
Output [1]: [ca_address_sk#46]
Input [2]: [ca_address_sk#46, ca_state#47]

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

(47) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [c_current_addr_sk#34]
Right keys [1]: [ca_address_sk#46]
Join type: Inner
Join condition: None

(48) Project [codegen id : 11]
Output [13]: [c_customer_id#33, c_salutation#35, c_first_name#36, c_last_name#37, c_preferred_cust_flag#38, c_birth_day#39, c_birth_month#40, c_birth_year#41, c_birth_country#42, c_login#43, c_email_address#44, c_last_review_date#45, ctr_total_return#14]
Input [15]: [ctr_total_return#14, c_customer_id#33, c_current_addr_sk#34, c_salutation#35, c_first_name#36, c_last_name#37, c_preferred_cust_flag#38, c_birth_day#39, c_birth_month#40, c_birth_year#41, c_birth_country#42, c_login#43, c_email_address#44, c_last_review_date#45, ca_address_sk#46]

(49) TakeOrderedAndProject
Input [13]: [c_customer_id#33, c_salutation#35, c_first_name#36, c_last_name#37, c_preferred_cust_flag#38, c_birth_day#39, c_birth_month#40, c_birth_year#41, c_birth_country#42, c_login#43, c_email_address#44, c_last_review_date#45, ctr_total_return#14]
Arguments: 100, [c_customer_id#33 ASC NULLS FIRST, c_salutation#35 ASC NULLS FIRST, c_first_name#36 ASC NULLS FIRST, c_last_name#37 ASC NULLS FIRST, c_preferred_cust_flag#38 ASC NULLS FIRST, c_birth_day#39 ASC NULLS FIRST, c_birth_month#40 ASC NULLS FIRST, c_birth_year#41 ASC NULLS FIRST, c_birth_country#42 ASC NULLS FIRST, c_login#43 ASC NULLS FIRST, c_email_address#44 ASC NULLS FIRST, c_last_review_date#45 ASC NULLS FIRST, ctr_total_return#14 ASC NULLS FIRST], [c_customer_id#33, c_salutation#35, c_first_name#36, c_last_name#37, c_preferred_cust_flag#38, c_birth_day#39, c_birth_month#40, c_birth_year#41, c_birth_country#42, c_login#43, c_email_address#44, c_last_review_date#45, ctr_total_return#14]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = wr_returned_date_sk#4 IN dynamicpruning#5
BroadcastExchange (54)
+- * Project (53)
   +- * Filter (52)
      +- * ColumnarToRow (51)
         +- Scan parquet spark_catalog.default.date_dim (50)


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

(51) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#6, d_year#48]

(52) Filter [codegen id : 1]
Input [2]: [d_date_sk#6, d_year#48]
Condition : ((isnotnull(d_year#48) AND (d_year#48 = 2002)) AND isnotnull(d_date_sk#6))

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

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

Subquery:2 Hosting operator id = 17 Hosting Expression = wr_returned_date_sk#18 IN dynamicpruning#5


