== Physical Plan ==
TakeOrderedAndProject (81)
+- * Project (80)
   +- * SortMergeJoin Inner (79)
      :- * Project (61)
      :  +- * SortMergeJoin Inner (60)
      :     :- * Project (40)
      :     :  +- * SortMergeJoin Inner (39)
      :     :     :- * Sort (21)
      :     :     :  +- Exchange (20)
      :     :     :     +- * Filter (19)
      :     :     :        +- * HashAggregate (18)
      :     :     :           +- Exchange (17)
      :     :     :              +- * HashAggregate (16)
      :     :     :                 +- * Project (15)
      :     :     :                    +- * SortMergeJoin Inner (14)
      :     :     :                       :- * Sort (8)
      :     :     :                       :  +- Exchange (7)
      :     :     :                       :     +- * Project (6)
      :     :     :                       :        +- * BroadcastHashJoin Inner BuildRight (5)
      :     :     :                       :           :- * Filter (3)
      :     :     :                       :           :  +- * ColumnarToRow (2)
      :     :     :                       :           :     +- Scan parquet default.store_sales (1)
      :     :     :                       :           +- ReusedExchange (4)
      :     :     :                       +- * Sort (13)
      :     :     :                          +- Exchange (12)
      :     :     :                             +- * Filter (11)
      :     :     :                                +- * ColumnarToRow (10)
      :     :     :                                   +- Scan parquet default.customer (9)
      :     :     +- * Sort (38)
      :     :        +- Exchange (37)
      :     :           +- * HashAggregate (36)
      :     :              +- Exchange (35)
      :     :                 +- * HashAggregate (34)
      :     :                    +- * Project (33)
      :     :                       +- * SortMergeJoin Inner (32)
      :     :                          :- * Sort (29)
      :     :                          :  +- Exchange (28)
      :     :                          :     +- * Project (27)
      :     :                          :        +- * BroadcastHashJoin Inner BuildRight (26)
      :     :                          :           :- * Filter (24)
      :     :                          :           :  +- * ColumnarToRow (23)
      :     :                          :           :     +- Scan parquet default.store_sales (22)
      :     :                          :           +- ReusedExchange (25)
      :     :                          +- * Sort (31)
      :     :                             +- ReusedExchange (30)
      :     +- * Sort (59)
      :        +- Exchange (58)
      :           +- * Project (57)
      :              +- * Filter (56)
      :                 +- * HashAggregate (55)
      :                    +- Exchange (54)
      :                       +- * HashAggregate (53)
      :                          +- * Project (52)
      :                             +- * SortMergeJoin Inner (51)
      :                                :- * Sort (48)
      :                                :  +- Exchange (47)
      :                                :     +- * Project (46)
      :                                :        +- * BroadcastHashJoin Inner BuildRight (45)
      :                                :           :- * Filter (43)
      :                                :           :  +- * ColumnarToRow (42)
      :                                :           :     +- Scan parquet default.web_sales (41)
      :                                :           +- ReusedExchange (44)
      :                                +- * Sort (50)
      :                                   +- ReusedExchange (49)
      +- * Sort (78)
         +- Exchange (77)
            +- * HashAggregate (76)
               +- Exchange (75)
                  +- * HashAggregate (74)
                     +- * Project (73)
                        +- * SortMergeJoin Inner (72)
                           :- * Sort (69)
                           :  +- Exchange (68)
                           :     +- * Project (67)
                           :        +- * BroadcastHashJoin Inner BuildRight (66)
                           :           :- * Filter (64)
                           :           :  +- * ColumnarToRow (63)
                           :           :     +- Scan parquet default.web_sales (62)
                           :           +- ReusedExchange (65)
                           +- * Sort (71)
                              +- ReusedExchange (70)


(1) Scan parquet default.store_sales
Output [4]: [ss_customer_sk#1, ss_ext_discount_amt#2, ss_ext_list_price#3, ss_sold_date_sk#4]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#4), dynamicpruningexpression(ss_sold_date_sk#4 IN dynamicpruning#5)]
PushedFilters: [IsNotNull(ss_customer_sk)]
ReadSchema: struct<ss_customer_sk:int,ss_ext_discount_amt:decimal(7,2),ss_ext_list_price:decimal(7,2)>

(2) ColumnarToRow [codegen id : 2]
Input [4]: [ss_customer_sk#1, ss_ext_discount_amt#2, ss_ext_list_price#3, ss_sold_date_sk#4]

(3) Filter [codegen id : 2]
Input [4]: [ss_customer_sk#1, ss_ext_discount_amt#2, ss_ext_list_price#3, ss_sold_date_sk#4]
Condition : isnotnull(ss_customer_sk#1)

(4) ReusedExchange [Reuses operator id: 85]
Output [2]: [d_date_sk#6, d_year#7]

(5) BroadcastHashJoin [codegen id : 2]
Left keys [1]: [ss_sold_date_sk#4]
Right keys [1]: [d_date_sk#6]
Join condition: None

(6) Project [codegen id : 2]
Output [4]: [ss_customer_sk#1, ss_ext_discount_amt#2, ss_ext_list_price#3, d_year#7]
Input [6]: [ss_customer_sk#1, ss_ext_discount_amt#2, ss_ext_list_price#3, ss_sold_date_sk#4, d_date_sk#6, d_year#7]

(7) Exchange
Input [4]: [ss_customer_sk#1, ss_ext_discount_amt#2, ss_ext_list_price#3, d_year#7]
Arguments: hashpartitioning(ss_customer_sk#1, 5), ENSURE_REQUIREMENTS, [id=#8]

(8) Sort [codegen id : 3]
Input [4]: [ss_customer_sk#1, ss_ext_discount_amt#2, ss_ext_list_price#3, d_year#7]
Arguments: [ss_customer_sk#1 ASC NULLS FIRST], false, 0

(9) Scan parquet default.customer
Output [8]: [c_customer_sk#9, c_customer_id#10, c_first_name#11, c_last_name#12, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer]
PushedFilters: [IsNotNull(c_customer_sk), IsNotNull(c_customer_id)]
ReadSchema: struct<c_customer_sk:int,c_customer_id:string,c_first_name:string,c_last_name:string,c_preferred_cust_flag:string,c_birth_country:string,c_login:string,c_email_address:string>

(10) ColumnarToRow [codegen id : 4]
Input [8]: [c_customer_sk#9, c_customer_id#10, c_first_name#11, c_last_name#12, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16]

(11) Filter [codegen id : 4]
Input [8]: [c_customer_sk#9, c_customer_id#10, c_first_name#11, c_last_name#12, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16]
Condition : (isnotnull(c_customer_sk#9) AND isnotnull(c_customer_id#10))

(12) Exchange
Input [8]: [c_customer_sk#9, c_customer_id#10, c_first_name#11, c_last_name#12, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16]
Arguments: hashpartitioning(c_customer_sk#9, 5), ENSURE_REQUIREMENTS, [id=#17]

(13) Sort [codegen id : 5]
Input [8]: [c_customer_sk#9, c_customer_id#10, c_first_name#11, c_last_name#12, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16]
Arguments: [c_customer_sk#9 ASC NULLS FIRST], false, 0

(14) SortMergeJoin [codegen id : 6]
Left keys [1]: [ss_customer_sk#1]
Right keys [1]: [c_customer_sk#9]
Join condition: None

(15) Project [codegen id : 6]
Output [10]: [c_customer_id#10, c_first_name#11, c_last_name#12, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16, ss_ext_discount_amt#2, ss_ext_list_price#3, d_year#7]
Input [12]: [ss_customer_sk#1, ss_ext_discount_amt#2, ss_ext_list_price#3, d_year#7, c_customer_sk#9, c_customer_id#10, c_first_name#11, c_last_name#12, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16]

(16) HashAggregate [codegen id : 6]
Input [10]: [c_customer_id#10, c_first_name#11, c_last_name#12, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16, ss_ext_discount_amt#2, ss_ext_list_price#3, d_year#7]
Keys [8]: [c_customer_id#10, c_first_name#11, c_last_name#12, d_year#7, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16]
Functions [1]: [partial_sum(UnscaledValue(CheckOverflow((promote_precision(cast(ss_ext_list_price#3 as decimal(8,2))) - promote_precision(cast(ss_ext_discount_amt#2 as decimal(8,2)))), DecimalType(8,2), true)))]
Aggregate Attributes [1]: [sum#18]
Results [9]: [c_customer_id#10, c_first_name#11, c_last_name#12, d_year#7, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16, sum#19]

(17) Exchange
Input [9]: [c_customer_id#10, c_first_name#11, c_last_name#12, d_year#7, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16, sum#19]
Arguments: hashpartitioning(c_customer_id#10, c_first_name#11, c_last_name#12, d_year#7, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16, 5), ENSURE_REQUIREMENTS, [id=#20]

(18) HashAggregate [codegen id : 7]
Input [9]: [c_customer_id#10, c_first_name#11, c_last_name#12, d_year#7, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16, sum#19]
Keys [8]: [c_customer_id#10, c_first_name#11, c_last_name#12, d_year#7, c_preferred_cust_flag#13, c_birth_country#14, c_login#15, c_email_address#16]
Functions [1]: [sum(UnscaledValue(CheckOverflow((promote_precision(cast(ss_ext_list_price#3 as decimal(8,2))) - promote_precision(cast(ss_ext_discount_amt#2 as decimal(8,2)))), DecimalType(8,2), true)))]
Aggregate Attributes [1]: [sum(UnscaledValue(CheckOverflow((promote_precision(cast(ss_ext_list_price#3 as decimal(8,2))) - promote_precision(cast(ss_ext_discount_amt#2 as decimal(8,2)))), DecimalType(8,2), true)))#21]
Results [2]: [c_customer_id#10 AS customer_id#22, MakeDecimal(sum(UnscaledValue(CheckOverflow((promote_precision(cast(ss_ext_list_price#3 as decimal(8,2))) - promote_precision(cast(ss_ext_discount_amt#2 as decimal(8,2)))), DecimalType(8,2), true)))#21,18,2) AS year_total#23]

(19) Filter [codegen id : 7]
Input [2]: [customer_id#22, year_total#23]
Condition : (isnotnull(year_total#23) AND (year_total#23 > 0.00))

(20) Exchange
Input [2]: [customer_id#22, year_total#23]
Arguments: hashpartitioning(customer_id#22, 5), ENSURE_REQUIREMENTS, [id=#24]

(21) Sort [codegen id : 8]
Input [2]: [customer_id#22, year_total#23]
Arguments: [customer_id#22 ASC NULLS FIRST], false, 0

(22) Scan parquet default.store_sales
Output [4]: [ss_customer_sk#25, ss_ext_discount_amt#26, ss_ext_list_price#27, ss_sold_date_sk#28]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#28), dynamicpruningexpression(ss_sold_date_sk#28 IN dynamicpruning#29)]
PushedFilters: [IsNotNull(ss_customer_sk)]
ReadSchema: struct<ss_customer_sk:int,ss_ext_discount_amt:decimal(7,2),ss_ext_list_price:decimal(7,2)>

(23) ColumnarToRow [codegen id : 10]
Input [4]: [ss_customer_sk#25, ss_ext_discount_amt#26, ss_ext_list_price#27, ss_sold_date_sk#28]

(24) Filter [codegen id : 10]
Input [4]: [ss_customer_sk#25, ss_ext_discount_amt#26, ss_ext_list_price#27, ss_sold_date_sk#28]
Condition : isnotnull(ss_customer_sk#25)

(25) ReusedExchange [Reuses operator id: 89]
Output [2]: [d_date_sk#30, d_year#31]

(26) BroadcastHashJoin [codegen id : 10]
Left keys [1]: [ss_sold_date_sk#28]
Right keys [1]: [d_date_sk#30]
Join condition: None

(27) Project [codegen id : 10]
Output [4]: [ss_customer_sk#25, ss_ext_discount_amt#26, ss_ext_list_price#27, d_year#31]
Input [6]: [ss_customer_sk#25, ss_ext_discount_amt#26, ss_ext_list_price#27, ss_sold_date_sk#28, d_date_sk#30, d_year#31]

(28) Exchange
Input [4]: [ss_customer_sk#25, ss_ext_discount_amt#26, ss_ext_list_price#27, d_year#31]
Arguments: hashpartitioning(ss_customer_sk#25, 5), ENSURE_REQUIREMENTS, [id=#32]

(29) Sort [codegen id : 11]
Input [4]: [ss_customer_sk#25, ss_ext_discount_amt#26, ss_ext_list_price#27, d_year#31]
Arguments: [ss_customer_sk#25 ASC NULLS FIRST], false, 0

(30) ReusedExchange [Reuses operator id: 12]
Output [8]: [c_customer_sk#33, c_customer_id#34, c_first_name#35, c_last_name#36, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40]

(31) Sort [codegen id : 13]
Input [8]: [c_customer_sk#33, c_customer_id#34, c_first_name#35, c_last_name#36, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40]
Arguments: [c_customer_sk#33 ASC NULLS FIRST], false, 0

(32) SortMergeJoin [codegen id : 14]
Left keys [1]: [ss_customer_sk#25]
Right keys [1]: [c_customer_sk#33]
Join condition: None

(33) Project [codegen id : 14]
Output [10]: [c_customer_id#34, c_first_name#35, c_last_name#36, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40, ss_ext_discount_amt#26, ss_ext_list_price#27, d_year#31]
Input [12]: [ss_customer_sk#25, ss_ext_discount_amt#26, ss_ext_list_price#27, d_year#31, c_customer_sk#33, c_customer_id#34, c_first_name#35, c_last_name#36, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40]

(34) HashAggregate [codegen id : 14]
Input [10]: [c_customer_id#34, c_first_name#35, c_last_name#36, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40, ss_ext_discount_amt#26, ss_ext_list_price#27, d_year#31]
Keys [8]: [c_customer_id#34, c_first_name#35, c_last_name#36, d_year#31, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40]
Functions [1]: [partial_sum(UnscaledValue(CheckOverflow((promote_precision(cast(ss_ext_list_price#27 as decimal(8,2))) - promote_precision(cast(ss_ext_discount_amt#26 as decimal(8,2)))), DecimalType(8,2), true)))]
Aggregate Attributes [1]: [sum#41]
Results [9]: [c_customer_id#34, c_first_name#35, c_last_name#36, d_year#31, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40, sum#42]

(35) Exchange
Input [9]: [c_customer_id#34, c_first_name#35, c_last_name#36, d_year#31, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40, sum#42]
Arguments: hashpartitioning(c_customer_id#34, c_first_name#35, c_last_name#36, d_year#31, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40, 5), ENSURE_REQUIREMENTS, [id=#43]

(36) HashAggregate [codegen id : 15]
Input [9]: [c_customer_id#34, c_first_name#35, c_last_name#36, d_year#31, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40, sum#42]
Keys [8]: [c_customer_id#34, c_first_name#35, c_last_name#36, d_year#31, c_preferred_cust_flag#37, c_birth_country#38, c_login#39, c_email_address#40]
Functions [1]: [sum(UnscaledValue(CheckOverflow((promote_precision(cast(ss_ext_list_price#27 as decimal(8,2))) - promote_precision(cast(ss_ext_discount_amt#26 as decimal(8,2)))), DecimalType(8,2), true)))]
Aggregate Attributes [1]: [sum(UnscaledValue(CheckOverflow((promote_precision(cast(ss_ext_list_price#27 as decimal(8,2))) - promote_precision(cast(ss_ext_discount_amt#26 as decimal(8,2)))), DecimalType(8,2), true)))#21]
Results [3]: [c_customer_id#34 AS customer_id#44, c_preferred_cust_flag#37 AS customer_preferred_cust_flag#45, MakeDecimal(sum(UnscaledValue(CheckOverflow((promote_precision(cast(ss_ext_list_price#27 as decimal(8,2))) - promote_precision(cast(ss_ext_discount_amt#26 as decimal(8,2)))), DecimalType(8,2), true)))#21,18,2) AS year_total#46]

(37) Exchange
Input [3]: [customer_id#44, customer_preferred_cust_flag#45, year_total#46]
Arguments: hashpartitioning(customer_id#44, 5), ENSURE_REQUIREMENTS, [id=#47]

(38) Sort [codegen id : 16]
Input [3]: [customer_id#44, customer_preferred_cust_flag#45, year_total#46]
Arguments: [customer_id#44 ASC NULLS FIRST], false, 0

(39) SortMergeJoin [codegen id : 17]
Left keys [1]: [customer_id#22]
Right keys [1]: [customer_id#44]
Join condition: None

(40) Project [codegen id : 17]
Output [4]: [customer_id#22, year_total#23, customer_preferred_cust_flag#45, year_total#46]
Input [5]: [customer_id#22, year_total#23, customer_id#44, customer_preferred_cust_flag#45, year_total#46]

(41) Scan parquet default.web_sales
Output [4]: [ws_bill_customer_sk#48, ws_ext_discount_amt#49, ws_ext_list_price#50, ws_sold_date_sk#51]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ws_sold_date_sk#51), dynamicpruningexpression(ws_sold_date_sk#51 IN dynamicpruning#5)]
PushedFilters: [IsNotNull(ws_bill_customer_sk)]
ReadSchema: struct<ws_bill_customer_sk:int,ws_ext_discount_amt:decimal(7,2),ws_ext_list_price:decimal(7,2)>

(42) ColumnarToRow [codegen id : 19]
Input [4]: [ws_bill_customer_sk#48, ws_ext_discount_amt#49, ws_ext_list_price#50, ws_sold_date_sk#51]

(43) Filter [codegen id : 19]
Input [4]: [ws_bill_customer_sk#48, ws_ext_discount_amt#49, ws_ext_list_price#50, ws_sold_date_sk#51]
Condition : isnotnull(ws_bill_customer_sk#48)

(44) ReusedExchange [Reuses operator id: 85]
Output [2]: [d_date_sk#52, d_year#53]

(45) BroadcastHashJoin [codegen id : 19]
Left keys [1]: [ws_sold_date_sk#51]
Right keys [1]: [d_date_sk#52]
Join condition: None

(46) Project [codegen id : 19]
Output [4]: [ws_bill_customer_sk#48, ws_ext_discount_amt#49, ws_ext_list_price#50, d_year#53]
Input [6]: [ws_bill_customer_sk#48, ws_ext_discount_amt#49, ws_ext_list_price#50, ws_sold_date_sk#51, d_date_sk#52, d_year#53]

(47) Exchange
Input [4]: [ws_bill_customer_sk#48, ws_ext_discount_amt#49, ws_ext_list_price#50, d_year#53]
Arguments: hashpartitioning(ws_bill_customer_sk#48, 5), ENSURE_REQUIREMENTS, [id=#54]

(48) Sort [codegen id : 20]
Input [4]: [ws_bill_customer_sk#48, ws_ext_discount_amt#49, ws_ext_list_price#50, d_year#53]
Arguments: [ws_bill_customer_sk#48 ASC NULLS FIRST], false, 0

(49) ReusedExchange [Reuses operator id: 12]
Output [8]: [c_customer_sk#55, c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62]

(50) Sort [codegen id : 22]
Input [8]: [c_customer_sk#55, c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62]
Arguments: [c_customer_sk#55 ASC NULLS FIRST], false, 0

(51) SortMergeJoin [codegen id : 23]
Left keys [1]: [ws_bill_customer_sk#48]
Right keys [1]: [c_customer_sk#55]
Join condition: None

(52) Project [codegen id : 23]
Output [10]: [c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62, ws_ext_discount_amt#49, ws_ext_list_price#50, d_year#53]
Input [12]: [ws_bill_customer_sk#48, ws_ext_discount_amt#49, ws_ext_list_price#50, d_year#53, c_customer_sk#55, c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62]

(53) HashAggregate [codegen id : 23]
Input [10]: [c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62, ws_ext_discount_amt#49, ws_ext_list_price#50, d_year#53]
Keys [8]: [c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62, d_year#53]
Functions [1]: [partial_sum(UnscaledValue(CheckOverflow((promote_precision(cast(ws_ext_list_price#50 as decimal(8,2))) - promote_precision(cast(ws_ext_discount_amt#49 as decimal(8,2)))), DecimalType(8,2), true)))]
Aggregate Attributes [1]: [sum#63]
Results [9]: [c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62, d_year#53, sum#64]

(54) Exchange
Input [9]: [c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62, d_year#53, sum#64]
Arguments: hashpartitioning(c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62, d_year#53, 5), ENSURE_REQUIREMENTS, [id=#65]

(55) HashAggregate [codegen id : 24]
Input [9]: [c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62, d_year#53, sum#64]
Keys [8]: [c_customer_id#56, c_first_name#57, c_last_name#58, c_preferred_cust_flag#59, c_birth_country#60, c_login#61, c_email_address#62, d_year#53]
Functions [1]: [sum(UnscaledValue(CheckOverflow((promote_precision(cast(ws_ext_list_price#50 as decimal(8,2))) - promote_precision(cast(ws_ext_discount_amt#49 as decimal(8,2)))), DecimalType(8,2), true)))]
Aggregate Attributes [1]: [sum(UnscaledValue(CheckOverflow((promote_precision(cast(ws_ext_list_price#50 as decimal(8,2))) - promote_precision(cast(ws_ext_discount_amt#49 as decimal(8,2)))), DecimalType(8,2), true)))#66]
Results [2]: [c_customer_id#56 AS customer_id#67, MakeDecimal(sum(UnscaledValue(CheckOverflow((promote_precision(cast(ws_ext_list_price#50 as decimal(8,2))) - promote_precision(cast(ws_ext_discount_amt#49 as decimal(8,2)))), DecimalType(8,2), true)))#66,18,2) AS year_total#68]

(56) Filter [codegen id : 24]
Input [2]: [customer_id#67, year_total#68]
Condition : (isnotnull(year_total#68) AND (year_total#68 > 0.00))

(57) Project [codegen id : 24]
Output [2]: [customer_id#67 AS customer_id#69, year_total#68 AS year_total#70]
Input [2]: [customer_id#67, year_total#68]

(58) Exchange
Input [2]: [customer_id#69, year_total#70]
Arguments: hashpartitioning(customer_id#69, 5), ENSURE_REQUIREMENTS, [id=#71]

(59) Sort [codegen id : 25]
Input [2]: [customer_id#69, year_total#70]
Arguments: [customer_id#69 ASC NULLS FIRST], false, 0

(60) SortMergeJoin [codegen id : 26]
Left keys [1]: [customer_id#22]
Right keys [1]: [customer_id#69]
Join condition: None

(61) Project [codegen id : 26]
Output [5]: [customer_id#22, year_total#23, customer_preferred_cust_flag#45, year_total#46, year_total#70]
Input [6]: [customer_id#22, year_total#23, customer_preferred_cust_flag#45, year_total#46, customer_id#69, year_total#70]

(62) Scan parquet default.web_sales
Output [4]: [ws_bill_customer_sk#72, ws_ext_discount_amt#73, ws_ext_list_price#74, ws_sold_date_sk#75]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ws_sold_date_sk#75), dynamicpruningexpression(ws_sold_date_sk#75 IN dynamicpruning#29)]
PushedFilters: [IsNotNull(ws_bill_customer_sk)]
ReadSchema: struct<ws_bill_customer_sk:int,ws_ext_discount_amt:decimal(7,2),ws_ext_list_price:decimal(7,2)>

(63) ColumnarToRow [codegen id : 28]
Input [4]: [ws_bill_customer_sk#72, ws_ext_discount_amt#73, ws_ext_list_price#74, ws_sold_date_sk#75]

(64) Filter [codegen id : 28]
Input [4]: [ws_bill_customer_sk#72, ws_ext_discount_amt#73, ws_ext_list_price#74, ws_sold_date_sk#75]
Condition : isnotnull(ws_bill_customer_sk#72)

(65) ReusedExchange [Reuses operator id: 89]
Output [2]: [d_date_sk#76, d_year#77]

(66) BroadcastHashJoin [codegen id : 28]
Left keys [1]: [ws_sold_date_sk#75]
Right keys [1]: [d_date_sk#76]
Join condition: None

(67) Project [codegen id : 28]
Output [4]: [ws_bill_customer_sk#72, ws_ext_discount_amt#73, ws_ext_list_price#74, d_year#77]
Input [6]: [ws_bill_customer_sk#72, ws_ext_discount_amt#73, ws_ext_list_price#74, ws_sold_date_sk#75, d_date_sk#76, d_year#77]

(68) Exchange
Input [4]: [ws_bill_customer_sk#72, ws_ext_discount_amt#73, ws_ext_list_price#74, d_year#77]
Arguments: hashpartitioning(ws_bill_customer_sk#72, 5), ENSURE_REQUIREMENTS, [id=#78]

(69) Sort [codegen id : 29]
Input [4]: [ws_bill_customer_sk#72, ws_ext_discount_amt#73, ws_ext_list_price#74, d_year#77]
Arguments: [ws_bill_customer_sk#72 ASC NULLS FIRST], false, 0

(70) ReusedExchange [Reuses operator id: 12]
Output [8]: [c_customer_sk#79, c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86]

(71) Sort [codegen id : 31]
Input [8]: [c_customer_sk#79, c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86]
Arguments: [c_customer_sk#79 ASC NULLS FIRST], false, 0

(72) SortMergeJoin [codegen id : 32]
Left keys [1]: [ws_bill_customer_sk#72]
Right keys [1]: [c_customer_sk#79]
Join condition: None

(73) Project [codegen id : 32]
Output [10]: [c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86, ws_ext_discount_amt#73, ws_ext_list_price#74, d_year#77]
Input [12]: [ws_bill_customer_sk#72, ws_ext_discount_amt#73, ws_ext_list_price#74, d_year#77, c_customer_sk#79, c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86]

(74) HashAggregate [codegen id : 32]
Input [10]: [c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86, ws_ext_discount_amt#73, ws_ext_list_price#74, d_year#77]
Keys [8]: [c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86, d_year#77]
Functions [1]: [partial_sum(UnscaledValue(CheckOverflow((promote_precision(cast(ws_ext_list_price#74 as decimal(8,2))) - promote_precision(cast(ws_ext_discount_amt#73 as decimal(8,2)))), DecimalType(8,2), true)))]
Aggregate Attributes [1]: [sum#87]
Results [9]: [c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86, d_year#77, sum#88]

(75) Exchange
Input [9]: [c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86, d_year#77, sum#88]
Arguments: hashpartitioning(c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86, d_year#77, 5), ENSURE_REQUIREMENTS, [id=#89]

(76) HashAggregate [codegen id : 33]
Input [9]: [c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86, d_year#77, sum#88]
Keys [8]: [c_customer_id#80, c_first_name#81, c_last_name#82, c_preferred_cust_flag#83, c_birth_country#84, c_login#85, c_email_address#86, d_year#77]
Functions [1]: [sum(UnscaledValue(CheckOverflow((promote_precision(cast(ws_ext_list_price#74 as decimal(8,2))) - promote_precision(cast(ws_ext_discount_amt#73 as decimal(8,2)))), DecimalType(8,2), true)))]
Aggregate Attributes [1]: [sum(UnscaledValue(CheckOverflow((promote_precision(cast(ws_ext_list_price#74 as decimal(8,2))) - promote_precision(cast(ws_ext_discount_amt#73 as decimal(8,2)))), DecimalType(8,2), true)))#66]
Results [2]: [c_customer_id#80 AS customer_id#90, MakeDecimal(sum(UnscaledValue(CheckOverflow((promote_precision(cast(ws_ext_list_price#74 as decimal(8,2))) - promote_precision(cast(ws_ext_discount_amt#73 as decimal(8,2)))), DecimalType(8,2), true)))#66,18,2) AS year_total#91]

(77) Exchange
Input [2]: [customer_id#90, year_total#91]
Arguments: hashpartitioning(customer_id#90, 5), ENSURE_REQUIREMENTS, [id=#92]

(78) Sort [codegen id : 34]
Input [2]: [customer_id#90, year_total#91]
Arguments: [customer_id#90 ASC NULLS FIRST], false, 0

(79) SortMergeJoin [codegen id : 35]
Left keys [1]: [customer_id#22]
Right keys [1]: [customer_id#90]
Join condition: (CASE WHEN (year_total#70 > 0.00) THEN CheckOverflow((promote_precision(year_total#91) / promote_precision(year_total#70)), DecimalType(38,20), true) END > CASE WHEN (year_total#23 > 0.00) THEN CheckOverflow((promote_precision(year_total#46) / promote_precision(year_total#23)), DecimalType(38,20), true) END)

(80) Project [codegen id : 35]
Output [1]: [customer_preferred_cust_flag#45]
Input [7]: [customer_id#22, year_total#23, customer_preferred_cust_flag#45, year_total#46, year_total#70, customer_id#90, year_total#91]

(81) TakeOrderedAndProject
Input [1]: [customer_preferred_cust_flag#45]
Arguments: 100, [customer_preferred_cust_flag#45 ASC NULLS FIRST], [customer_preferred_cust_flag#45]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ss_sold_date_sk#4 IN dynamicpruning#5
BroadcastExchange (85)
+- * Filter (84)
   +- * ColumnarToRow (83)
      +- Scan parquet default.date_dim (82)


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

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

(84) Filter [codegen id : 1]
Input [2]: [d_date_sk#6, d_year#7]
Condition : ((isnotnull(d_year#7) AND (d_year#7 = 2001)) AND isnotnull(d_date_sk#6))

(85) BroadcastExchange
Input [2]: [d_date_sk#6, d_year#7]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#93]

Subquery:2 Hosting operator id = 22 Hosting Expression = ss_sold_date_sk#28 IN dynamicpruning#29
BroadcastExchange (89)
+- * Filter (88)
   +- * ColumnarToRow (87)
      +- Scan parquet default.date_dim (86)


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

(87) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#30, d_year#31]

(88) Filter [codegen id : 1]
Input [2]: [d_date_sk#30, d_year#31]
Condition : ((isnotnull(d_year#31) AND (d_year#31 = 2002)) AND isnotnull(d_date_sk#30))

(89) BroadcastExchange
Input [2]: [d_date_sk#30, d_year#31]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#94]

Subquery:3 Hosting operator id = 41 Hosting Expression = ws_sold_date_sk#51 IN dynamicpruning#5

Subquery:4 Hosting operator id = 62 Hosting Expression = ws_sold_date_sk#75 IN dynamicpruning#29


