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


(1) Scan parquet spark_catalog.default.customer
Output [4]: [c_customer_sk#1, c_customer_id#2, c_first_name#3, c_last_name#4]
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>

(2) ColumnarToRow [codegen id : 3]
Input [4]: [c_customer_sk#1, c_customer_id#2, c_first_name#3, c_last_name#4]

(3) Filter [codegen id : 3]
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))

(4) Scan parquet spark_catalog.default.store_sales
Output [3]: [ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#7)]
PushedFilters: [IsNotNull(ss_customer_sk)]
ReadSchema: struct<ss_customer_sk:int,ss_net_paid:decimal(7,2)>

(5) ColumnarToRow [codegen id : 1]
Input [3]: [ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]

(6) Filter [codegen id : 1]
Input [3]: [ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]
Condition : isnotnull(ss_customer_sk#5)

(7) BroadcastExchange
Input [3]: [ss_customer_sk#5, ss_net_paid#6, ss_sold_date_sk#7]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=1]

(8) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [c_customer_sk#1]
Right keys [1]: [ss_customer_sk#5]
Join type: Inner
Join condition: None

(9) Project [codegen id : 3]
Output [5]: [c_customer_id#2, c_first_name#3, c_last_name#4, ss_net_paid#6, ss_sold_date_sk#7]
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]

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

(11) ColumnarToRow [codegen id : 2]
Input [2]: [d_date_sk#8, d_year#9]

(12) Filter [codegen id : 2]
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))

(13) BroadcastExchange
Input [2]: [d_date_sk#8, d_year#9]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=2]

(14) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [ss_sold_date_sk#7]
Right keys [1]: [d_date_sk#8]
Join type: Inner
Join condition: None

(15) Project [codegen id : 3]
Output [5]: [c_customer_id#2, c_first_name#3, c_last_name#4, ss_net_paid#6, d_year#9]
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]

(16) HashAggregate [codegen id : 3]
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]

(17) 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=3]

(18) HashAggregate [codegen id : 16]
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]

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

(20) Scan parquet spark_catalog.default.customer
Output [4]: [c_customer_sk#15, c_customer_id#16, c_first_name#17, c_last_name#18]
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>

(21) ColumnarToRow [codegen id : 6]
Input [4]: [c_customer_sk#15, c_customer_id#16, c_first_name#17, c_last_name#18]

(22) Filter [codegen id : 6]
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))

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

(24) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [c_customer_sk#15]
Right keys [1]: [ss_customer_sk#19]
Join type: Inner
Join condition: None

(25) Project [codegen id : 6]
Output [5]: [c_customer_id#16, c_first_name#17, c_last_name#18, ss_net_paid#20, ss_sold_date_sk#21]
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]

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

(27) ColumnarToRow [codegen id : 5]
Input [2]: [d_date_sk#22, d_year#23]

(28) Filter [codegen id : 5]
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))

(29) BroadcastExchange
Input [2]: [d_date_sk#22, d_year#23]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=4]

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

(31) Project [codegen id : 6]
Output [5]: [c_customer_id#16, c_first_name#17, c_last_name#18, ss_net_paid#20, d_year#23]
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]

(32) HashAggregate [codegen id : 6]
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]

(33) 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=5]

(34) HashAggregate [codegen id : 7]
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]

(35) 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=6]

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

(37) Scan parquet spark_catalog.default.customer
Output [4]: [c_customer_sk#30, c_customer_id#31, c_first_name#32, c_last_name#33]
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>

(38) ColumnarToRow [codegen id : 10]
Input [4]: [c_customer_sk#30, c_customer_id#31, c_first_name#32, c_last_name#33]

(39) Filter [codegen id : 10]
Input [4]: [c_customer_sk#30, c_customer_id#31, c_first_name#32, c_last_name#33]
Condition : (isnotnull(c_customer_sk#30) AND isnotnull(c_customer_id#31))

(40) Scan parquet spark_catalog.default.web_sales
Output [3]: [ws_bill_customer_sk#34, ws_net_paid#35, ws_sold_date_sk#36]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ws_sold_date_sk#36)]
PushedFilters: [IsNotNull(ws_bill_customer_sk)]
ReadSchema: struct<ws_bill_customer_sk:int,ws_net_paid:decimal(7,2)>

(41) ColumnarToRow [codegen id : 8]
Input [3]: [ws_bill_customer_sk#34, ws_net_paid#35, ws_sold_date_sk#36]

(42) Filter [codegen id : 8]
Input [3]: [ws_bill_customer_sk#34, ws_net_paid#35, ws_sold_date_sk#36]
Condition : isnotnull(ws_bill_customer_sk#34)

(43) BroadcastExchange
Input [3]: [ws_bill_customer_sk#34, ws_net_paid#35, ws_sold_date_sk#36]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=7]

(44) BroadcastHashJoin [codegen id : 10]
Left keys [1]: [c_customer_sk#30]
Right keys [1]: [ws_bill_customer_sk#34]
Join type: Inner
Join condition: None

(45) Project [codegen id : 10]
Output [5]: [c_customer_id#31, c_first_name#32, c_last_name#33, ws_net_paid#35, ws_sold_date_sk#36]
Input [7]: [c_customer_sk#30, c_customer_id#31, c_first_name#32, c_last_name#33, ws_bill_customer_sk#34, ws_net_paid#35, ws_sold_date_sk#36]

(46) ReusedExchange [Reuses operator id: 13]
Output [2]: [d_date_sk#37, d_year#38]

(47) BroadcastHashJoin [codegen id : 10]
Left keys [1]: [ws_sold_date_sk#36]
Right keys [1]: [d_date_sk#37]
Join type: Inner
Join condition: None

(48) Project [codegen id : 10]
Output [5]: [c_customer_id#31, c_first_name#32, c_last_name#33, ws_net_paid#35, d_year#38]
Input [7]: [c_customer_id#31, c_first_name#32, c_last_name#33, ws_net_paid#35, ws_sold_date_sk#36, d_date_sk#37, d_year#38]

(49) HashAggregate [codegen id : 10]
Input [5]: [c_customer_id#31, c_first_name#32, c_last_name#33, ws_net_paid#35, d_year#38]
Keys [4]: [c_customer_id#31, c_first_name#32, c_last_name#33, d_year#38]
Functions [1]: [partial_sum(UnscaledValue(ws_net_paid#35))]
Aggregate Attributes [1]: [sum#39]
Results [5]: [c_customer_id#31, c_first_name#32, c_last_name#33, d_year#38, sum#40]

(50) Exchange
Input [5]: [c_customer_id#31, c_first_name#32, c_last_name#33, d_year#38, sum#40]
Arguments: hashpartitioning(c_customer_id#31, c_first_name#32, c_last_name#33, d_year#38, 5), ENSURE_REQUIREMENTS, [plan_id=8]

(51) HashAggregate [codegen id : 11]
Input [5]: [c_customer_id#31, c_first_name#32, c_last_name#33, d_year#38, sum#40]
Keys [4]: [c_customer_id#31, c_first_name#32, c_last_name#33, d_year#38]
Functions [1]: [sum(UnscaledValue(ws_net_paid#35))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_net_paid#35))#41]
Results [2]: [c_customer_id#31 AS customer_id#42, MakeDecimal(sum(UnscaledValue(ws_net_paid#35))#41,17,2) AS year_total#43]

(52) Filter [codegen id : 11]
Input [2]: [customer_id#42, year_total#43]
Condition : (isnotnull(year_total#43) AND (year_total#43 > 0.00))

(53) BroadcastExchange
Input [2]: [customer_id#42, year_total#43]
Arguments: HashedRelationBroadcastMode(List(input[0, string, true]),false), [plan_id=9]

(54) BroadcastHashJoin [codegen id : 16]
Left keys [1]: [customer_id#13]
Right keys [1]: [customer_id#42]
Join type: Inner
Join condition: None

(55) Project [codegen id : 16]
Output [7]: [customer_id#13, year_total#14, customer_id#26, customer_first_name#27, customer_last_name#28, year_total#29, year_total#43]
Input [8]: [customer_id#13, year_total#14, customer_id#26, customer_first_name#27, customer_last_name#28, year_total#29, customer_id#42, year_total#43]

(56) Scan parquet spark_catalog.default.customer
Output [4]: [c_customer_sk#44, c_customer_id#45, c_first_name#46, c_last_name#47]
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>

(57) ColumnarToRow [codegen id : 14]
Input [4]: [c_customer_sk#44, c_customer_id#45, c_first_name#46, c_last_name#47]

(58) Filter [codegen id : 14]
Input [4]: [c_customer_sk#44, c_customer_id#45, c_first_name#46, c_last_name#47]
Condition : (isnotnull(c_customer_sk#44) AND isnotnull(c_customer_id#45))

(59) ReusedExchange [Reuses operator id: 43]
Output [3]: [ws_bill_customer_sk#48, ws_net_paid#49, ws_sold_date_sk#50]

(60) BroadcastHashJoin [codegen id : 14]
Left keys [1]: [c_customer_sk#44]
Right keys [1]: [ws_bill_customer_sk#48]
Join type: Inner
Join condition: None

(61) Project [codegen id : 14]
Output [5]: [c_customer_id#45, c_first_name#46, c_last_name#47, ws_net_paid#49, ws_sold_date_sk#50]
Input [7]: [c_customer_sk#44, c_customer_id#45, c_first_name#46, c_last_name#47, ws_bill_customer_sk#48, ws_net_paid#49, ws_sold_date_sk#50]

(62) ReusedExchange [Reuses operator id: 29]
Output [2]: [d_date_sk#51, d_year#52]

(63) BroadcastHashJoin [codegen id : 14]
Left keys [1]: [ws_sold_date_sk#50]
Right keys [1]: [d_date_sk#51]
Join type: Inner
Join condition: None

(64) Project [codegen id : 14]
Output [5]: [c_customer_id#45, c_first_name#46, c_last_name#47, ws_net_paid#49, d_year#52]
Input [7]: [c_customer_id#45, c_first_name#46, c_last_name#47, ws_net_paid#49, ws_sold_date_sk#50, d_date_sk#51, d_year#52]

(65) HashAggregate [codegen id : 14]
Input [5]: [c_customer_id#45, c_first_name#46, c_last_name#47, ws_net_paid#49, d_year#52]
Keys [4]: [c_customer_id#45, c_first_name#46, c_last_name#47, d_year#52]
Functions [1]: [partial_sum(UnscaledValue(ws_net_paid#49))]
Aggregate Attributes [1]: [sum#53]
Results [5]: [c_customer_id#45, c_first_name#46, c_last_name#47, d_year#52, sum#54]

(66) Exchange
Input [5]: [c_customer_id#45, c_first_name#46, c_last_name#47, d_year#52, sum#54]
Arguments: hashpartitioning(c_customer_id#45, c_first_name#46, c_last_name#47, d_year#52, 5), ENSURE_REQUIREMENTS, [plan_id=10]

(67) HashAggregate [codegen id : 15]
Input [5]: [c_customer_id#45, c_first_name#46, c_last_name#47, d_year#52, sum#54]
Keys [4]: [c_customer_id#45, c_first_name#46, c_last_name#47, d_year#52]
Functions [1]: [sum(UnscaledValue(ws_net_paid#49))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_net_paid#49))#41]
Results [2]: [c_customer_id#45 AS customer_id#55, MakeDecimal(sum(UnscaledValue(ws_net_paid#49))#41,17,2) AS year_total#56]

(68) BroadcastExchange
Input [2]: [customer_id#55, year_total#56]
Arguments: HashedRelationBroadcastMode(List(input[0, string, true]),false), [plan_id=11]

(69) BroadcastHashJoin [codegen id : 16]
Left keys [1]: [customer_id#13]
Right keys [1]: [customer_id#55]
Join type: Inner
Join condition: (CASE WHEN (year_total#43 > 0.00) THEN (year_total#56 / year_total#43) END > CASE WHEN (year_total#14 > 0.00) THEN (year_total#29 / year_total#14) END)

(70) Project [codegen id : 16]
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#43, customer_id#55, year_total#56]

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

