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


(1) CometNativeScan: `spark_catalog`.`default`.`customer`
Output [4]: [c_customer_sk#1, c_customer_id#2, c_first_name#3, c_last_name#4]
Arguments: [c_customer_sk#1, c_customer_id#2, c_first_name#3, c_last_name#4]

(2) CometFilter
Input [4]: [c_customer_sk#1, c_customer_id#2, c_first_name#3, c_last_name#4]
Condition : (isnotnull(c_customer_sk#1) AND isnotnull(c_customer_id#2))

(3) CometNativeScan: `spark_catalog`.`default`.`store_sales`
Output [3]: [ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]
Arguments: [ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]

(4) CometFilter
Input [3]: [ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]
Condition : isnotnull(ss_customer_sk#5)

(5) CometBroadcastExchange
Input [3]: [ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]
Arguments: [ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]

(6) CometBroadcastHashJoin
Left output [4]: [c_customer_sk#1, c_customer_id#2, c_first_name#3, c_last_name#4]
Right output [3]: [ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]
Arguments: [c_customer_sk#1], [ss_customer_sk#5], Inner, BuildRight

(7) CometProject
Input [7]: [c_customer_sk#1, c_customer_id#2, c_first_name#3, c_last_name#4, ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]
Arguments: [c_customer_id#2, c_first_name#3, c_last_name#4, ss_net_paid#6, ss_sold_date_sk#7], [c_customer_id#2, c_first_name#3, c_last_name#4, ss_net_paid#6, ss_sold_date_sk#7]

(8) CometNativeScan: `spark_catalog`.`default`.`date_dim`
Output [2]: [d_date_sk#8, d_year#9]
Arguments: [d_date_sk#8, d_year#9]

(9) CometFilter
Input [2]: [d_date_sk#8, d_year#9]
Condition : (((isnotnull(d_year#9) AND (d_year#9 = 2001)) AND d_year#9 IN (2001,2002)) AND isnotnull(d_date_sk#8))

(10) CometBroadcastExchange
Input [2]: [d_date_sk#8, d_year#9]
Arguments: [d_date_sk#8, d_year#9]

(11) CometBroadcastHashJoin
Left output [5]: [c_customer_id#2, c_first_name#3, c_last_name#4, ss_net_paid#6, ss_sold_date_sk#7]
Right output [2]: [d_date_sk#8, d_year#9]
Arguments: [ss_sold_date_sk#7], [d_date_sk#8], Inner, BuildRight

(12) CometProject
Input [7]: [c_customer_id#2, c_first_name#3, c_last_name#4, ss_net_paid#6, ss_sold_date_sk#7, d_date_sk#8, d_year#9]
Arguments: [c_customer_id#2, c_first_name#3, c_last_name#4, ss_net_paid#6, d_year#9], [c_customer_id#2, c_first_name#3, c_last_name#4, ss_net_paid#6, d_year#9]

(13) ColumnarToRow [codegen id : 1]
Input [5]: [c_customer_id#2, c_first_name#3, c_last_name#4, ss_net_paid#6, d_year#9]

(14) HashAggregate [codegen id : 1]
Input [5]: [c_customer_id#2, c_first_name#3, c_last_name#4, ss_net_paid#6, d_year#9]
Keys [4]: [c_customer_id#2, c_first_name#3, c_last_name#4, d_year#9]
Functions [1]: [partial_sum(UnscaledValue(ss_net_paid#6))]
Aggregate Attributes [1]: [sum#10]
Results [5]: [c_customer_id#2, c_first_name#3, c_last_name#4, d_year#9, sum#11]

(15) Exchange
Input [5]: [c_customer_id#2, c_first_name#3, c_last_name#4, d_year#9, sum#11]
Arguments: hashpartitioning(c_customer_id#2, c_first_name#3, c_last_name#4, d_year#9, 5), ENSURE_REQUIREMENTS, [plan_id=1]

(16) HashAggregate [codegen id : 8]
Input [5]: [c_customer_id#2, c_first_name#3, c_last_name#4, d_year#9, sum#11]
Keys [4]: [c_customer_id#2, c_first_name#3, c_last_name#4, d_year#9]
Functions [1]: [sum(UnscaledValue(ss_net_paid#6))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_net_paid#6))#12]
Results [2]: [c_customer_id#2 AS customer_id#13, MakeDecimal(sum(UnscaledValue(ss_net_paid#6))#12,17,2) AS year_total#14]

(17) Filter [codegen id : 8]
Input [2]: [customer_id#13, year_total#14]
Condition : (isnotnull(year_total#14) AND (year_total#14 > 0.00))

(18) CometNativeScan: `spark_catalog`.`default`.`customer`
Output [4]: [c_customer_sk#15, c_customer_id#16, c_first_name#17, c_last_name#18]
Arguments: [c_customer_sk#15, c_customer_id#16, c_first_name#17, c_last_name#18]

(19) CometFilter
Input [4]: [c_customer_sk#15, c_customer_id#16, c_first_name#17, c_last_name#18]
Condition : (isnotnull(c_customer_sk#15) AND isnotnull(c_customer_id#16))

(20) ReusedExchange [Reuses operator id: 5]
Output [3]: [ss_customer_sk#19, ss_net_paid#20, ss_sold_date_sk#21]

(21) CometBroadcastHashJoin
Left output [4]: [c_customer_sk#15, c_customer_id#16, c_first_name#17, c_last_name#18]
Right output [3]: [ss_customer_sk#19, ss_net_paid#20, ss_sold_date_sk#21]
Arguments: [c_customer_sk#15], [ss_customer_sk#19], Inner, BuildRight

(22) CometProject
Input [7]: [c_customer_sk#15, c_customer_id#16, c_first_name#17, c_last_name#18, ss_customer_sk#19, ss_net_paid#20, ss_sold_date_sk#21]
Arguments: [c_customer_id#16, c_first_name#17, c_last_name#18, ss_net_paid#20, ss_sold_date_sk#21], [c_customer_id#16, c_first_name#17, c_last_name#18, ss_net_paid#20, ss_sold_date_sk#21]

(23) CometNativeScan: `spark_catalog`.`default`.`date_dim`
Output [2]: [d_date_sk#22, d_year#23]
Arguments: [d_date_sk#22, d_year#23]

(24) CometFilter
Input [2]: [d_date_sk#22, d_year#23]
Condition : (((isnotnull(d_year#23) AND (d_year#23 = 2002)) AND d_year#23 IN (2001,2002)) AND isnotnull(d_date_sk#22))

(25) CometBroadcastExchange
Input [2]: [d_date_sk#22, d_year#23]
Arguments: [d_date_sk#22, d_year#23]

(26) CometBroadcastHashJoin
Left output [5]: [c_customer_id#16, c_first_name#17, c_last_name#18, ss_net_paid#20, ss_sold_date_sk#21]
Right output [2]: [d_date_sk#22, d_year#23]
Arguments: [ss_sold_date_sk#21], [d_date_sk#22], Inner, BuildRight

(27) CometProject
Input [7]: [c_customer_id#16, c_first_name#17, c_last_name#18, ss_net_paid#20, ss_sold_date_sk#21, d_date_sk#22, d_year#23]
Arguments: [c_customer_id#16, c_first_name#17, c_last_name#18, ss_net_paid#20, d_year#23], [c_customer_id#16, c_first_name#17, c_last_name#18, ss_net_paid#20, d_year#23]

(28) ColumnarToRow [codegen id : 2]
Input [5]: [c_customer_id#16, c_first_name#17, c_last_name#18, ss_net_paid#20, d_year#23]

(29) HashAggregate [codegen id : 2]
Input [5]: [c_customer_id#16, c_first_name#17, c_last_name#18, ss_net_paid#20, d_year#23]
Keys [4]: [c_customer_id#16, c_first_name#17, c_last_name#18, d_year#23]
Functions [1]: [partial_sum(UnscaledValue(ss_net_paid#20))]
Aggregate Attributes [1]: [sum#24]
Results [5]: [c_customer_id#16, c_first_name#17, c_last_name#18, d_year#23, sum#25]

(30) Exchange
Input [5]: [c_customer_id#16, c_first_name#17, c_last_name#18, d_year#23, sum#25]
Arguments: hashpartitioning(c_customer_id#16, c_first_name#17, c_last_name#18, d_year#23, 5), ENSURE_REQUIREMENTS, [plan_id=2]

(31) HashAggregate [codegen id : 3]
Input [5]: [c_customer_id#16, c_first_name#17, c_last_name#18, d_year#23, sum#25]
Keys [4]: [c_customer_id#16, c_first_name#17, c_last_name#18, d_year#23]
Functions [1]: [sum(UnscaledValue(ss_net_paid#20))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_net_paid#20))#12]
Results [4]: [c_customer_id#16 AS customer_id#26, c_first_name#17 AS customer_first_name#27, c_last_name#18 AS customer_last_name#28, MakeDecimal(sum(UnscaledValue(ss_net_paid#20))#12,17,2) AS year_total#29]

(32) BroadcastExchange
Input [4]: [customer_id#26, customer_first_name#27, customer_last_name#28, year_total#29]
Arguments: HashedRelationBroadcastMode(List(input[0, string, true]),false), [plan_id=3]

(33) BroadcastHashJoin [codegen id : 8]
Left keys [1]: [customer_id#13]
Right keys [1]: [customer_id#26]
Join type: Inner
Join condition: None

(34) ReusedExchange [Reuses operator id: 15]
Output [5]: [c_customer_id#30, c_first_name#31, c_last_name#32, d_year#33, sum#34]

(35) HashAggregate [codegen id : 5]
Input [5]: [c_customer_id#30, c_first_name#31, c_last_name#32, d_year#33, sum#34]
Keys [4]: [c_customer_id#30, c_first_name#31, c_last_name#32, d_year#33]
Functions [1]: [sum(UnscaledValue(ws_net_paid#35))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_net_paid#35))#36]
Results [2]: [c_customer_id#30 AS customer_id#37, MakeDecimal(sum(UnscaledValue(ws_net_paid#35))#36,17,2) AS year_total#38]

(36) Filter [codegen id : 5]
Input [2]: [customer_id#37, year_total#38]
Condition : (isnotnull(year_total#38) AND (year_total#38 > 0.00))

(37) BroadcastExchange
Input [2]: [customer_id#37, year_total#38]
Arguments: HashedRelationBroadcastMode(List(input[0, string, true]),false), [plan_id=4]

(38) BroadcastHashJoin [codegen id : 8]
Left keys [1]: [customer_id#13]
Right keys [1]: [customer_id#37]
Join type: Inner
Join condition: None

(39) Project [codegen id : 8]
Output [7]: [customer_id#13, year_total#14, customer_id#26, customer_first_name#27, customer_last_name#28, year_total#29, year_total#38]
Input [8]: [customer_id#13, year_total#14, customer_id#26, customer_first_name#27, customer_last_name#28, year_total#29, customer_id#37, year_total#38]

(40) ReusedExchange [Reuses operator id: 30]
Output [5]: [c_customer_id#39, c_first_name#40, c_last_name#41, d_year#42, sum#43]

(41) HashAggregate [codegen id : 7]
Input [5]: [c_customer_id#39, c_first_name#40, c_last_name#41, d_year#42, sum#43]
Keys [4]: [c_customer_id#39, c_first_name#40, c_last_name#41, d_year#42]
Functions [1]: [sum(UnscaledValue(ws_net_paid#44))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_net_paid#44))#36]
Results [2]: [c_customer_id#39 AS customer_id#45, MakeDecimal(sum(UnscaledValue(ws_net_paid#44))#36,17,2) AS year_total#46]

(42) BroadcastExchange
Input [2]: [customer_id#45, year_total#46]
Arguments: HashedRelationBroadcastMode(List(input[0, string, true]),false), [plan_id=5]

(43) BroadcastHashJoin [codegen id : 8]
Left keys [1]: [customer_id#13]
Right keys [1]: [customer_id#45]
Join type: Inner
Join condition: (CASE WHEN (year_total#38 > 0.00) THEN (year_total#46 / year_total#38) END > CASE WHEN (year_total#14 > 0.00) THEN (year_total#29 / year_total#14) END)

(44) Project [codegen id : 8]
Output [3]: [customer_id#26, customer_first_name#27, customer_last_name#28]
Input [9]: [customer_id#13, year_total#14, customer_id#26, customer_first_name#27, customer_last_name#28, year_total#29, year_total#38, customer_id#45, year_total#46]

(45) TakeOrderedAndProject
Input [3]: [customer_id#26, customer_first_name#27, customer_last_name#28]
Arguments: 100, [customer_id#26 ASC NULLS FIRST, customer_id#26 ASC NULLS FIRST, customer_id#26 ASC NULLS FIRST], [customer_id#26, customer_first_name#27, customer_last_name#28]

