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


(1) Scan parquet spark_catalog.default.call_center
Output [4]: [cc_call_center_sk#1, cc_call_center_id#2, cc_name#3, cc_manager#4]
Batched: true
Location [not included in comparison]/{warehouse_dir}/call_center]
PushedFilters: [IsNotNull(cc_call_center_sk)]
ReadSchema: struct<cc_call_center_sk:int,cc_call_center_id:string,cc_name:string,cc_manager:string>

(2) ColumnarToRow [codegen id : 7]
Input [4]: [cc_call_center_sk#1, cc_call_center_id#2, cc_name#3, cc_manager#4]

(3) Filter [codegen id : 7]
Input [4]: [cc_call_center_sk#1, cc_call_center_id#2, cc_name#3, cc_manager#4]
Condition : isnotnull(cc_call_center_sk#1)

(4) Scan parquet spark_catalog.default.catalog_returns
Output [4]: [cr_returning_customer_sk#5, cr_call_center_sk#6, cr_net_loss#7, cr_returned_date_sk#8]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(cr_returned_date_sk#8), dynamicpruningexpression(cr_returned_date_sk#8 IN dynamicpruning#9)]
PushedFilters: [IsNotNull(cr_call_center_sk), IsNotNull(cr_returning_customer_sk)]
ReadSchema: struct<cr_returning_customer_sk:int,cr_call_center_sk:int,cr_net_loss:decimal(7,2)>

(5) ColumnarToRow [codegen id : 1]
Input [4]: [cr_returning_customer_sk#5, cr_call_center_sk#6, cr_net_loss#7, cr_returned_date_sk#8]

(6) Filter [codegen id : 1]
Input [4]: [cr_returning_customer_sk#5, cr_call_center_sk#6, cr_net_loss#7, cr_returned_date_sk#8]
Condition : (isnotnull(cr_call_center_sk#6) AND isnotnull(cr_returning_customer_sk#5))

(7) BroadcastExchange
Input [4]: [cr_returning_customer_sk#5, cr_call_center_sk#6, cr_net_loss#7, cr_returned_date_sk#8]
Arguments: HashedRelationBroadcastMode(List(cast(input[1, int, false] as bigint)),false), [plan_id=1]

(8) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [cc_call_center_sk#1]
Right keys [1]: [cr_call_center_sk#6]
Join type: Inner
Join condition: None

(9) Project [codegen id : 7]
Output [6]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_returning_customer_sk#5, cr_net_loss#7, cr_returned_date_sk#8]
Input [8]: [cc_call_center_sk#1, cc_call_center_id#2, cc_name#3, cc_manager#4, cr_returning_customer_sk#5, cr_call_center_sk#6, cr_net_loss#7, cr_returned_date_sk#8]

(10) ReusedExchange [Reuses operator id: 48]
Output [1]: [d_date_sk#10]

(11) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [cr_returned_date_sk#8]
Right keys [1]: [d_date_sk#10]
Join type: Inner
Join condition: None

(12) Project [codegen id : 7]
Output [5]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_returning_customer_sk#5, cr_net_loss#7]
Input [7]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_returning_customer_sk#5, cr_net_loss#7, cr_returned_date_sk#8, d_date_sk#10]

(13) Scan parquet spark_catalog.default.customer
Output [4]: [c_customer_sk#11, c_current_cdemo_sk#12, c_current_hdemo_sk#13, c_current_addr_sk#14]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer]
PushedFilters: [IsNotNull(c_customer_sk), IsNotNull(c_current_addr_sk), IsNotNull(c_current_cdemo_sk), IsNotNull(c_current_hdemo_sk)]
ReadSchema: struct<c_customer_sk:int,c_current_cdemo_sk:int,c_current_hdemo_sk:int,c_current_addr_sk:int>

(14) ColumnarToRow [codegen id : 3]
Input [4]: [c_customer_sk#11, c_current_cdemo_sk#12, c_current_hdemo_sk#13, c_current_addr_sk#14]

(15) Filter [codegen id : 3]
Input [4]: [c_customer_sk#11, c_current_cdemo_sk#12, c_current_hdemo_sk#13, c_current_addr_sk#14]
Condition : (((isnotnull(c_customer_sk#11) AND isnotnull(c_current_addr_sk#14)) AND isnotnull(c_current_cdemo_sk#12)) AND isnotnull(c_current_hdemo_sk#13))

(16) BroadcastExchange
Input [4]: [c_customer_sk#11, c_current_cdemo_sk#12, c_current_hdemo_sk#13, c_current_addr_sk#14]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=2]

(17) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [cr_returning_customer_sk#5]
Right keys [1]: [c_customer_sk#11]
Join type: Inner
Join condition: None

(18) Project [codegen id : 7]
Output [7]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_net_loss#7, c_current_cdemo_sk#12, c_current_hdemo_sk#13, c_current_addr_sk#14]
Input [9]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_returning_customer_sk#5, cr_net_loss#7, c_customer_sk#11, c_current_cdemo_sk#12, c_current_hdemo_sk#13, c_current_addr_sk#14]

(19) Scan parquet spark_catalog.default.customer_address
Output [2]: [ca_address_sk#15, ca_gmt_offset#16]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_address]
PushedFilters: [IsNotNull(ca_gmt_offset), EqualTo(ca_gmt_offset,-7.00), IsNotNull(ca_address_sk)]
ReadSchema: struct<ca_address_sk:int,ca_gmt_offset:decimal(5,2)>

(20) ColumnarToRow [codegen id : 4]
Input [2]: [ca_address_sk#15, ca_gmt_offset#16]

(21) Filter [codegen id : 4]
Input [2]: [ca_address_sk#15, ca_gmt_offset#16]
Condition : ((isnotnull(ca_gmt_offset#16) AND (ca_gmt_offset#16 = -7.00)) AND isnotnull(ca_address_sk#15))

(22) Project [codegen id : 4]
Output [1]: [ca_address_sk#15]
Input [2]: [ca_address_sk#15, ca_gmt_offset#16]

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

(24) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [c_current_addr_sk#14]
Right keys [1]: [ca_address_sk#15]
Join type: Inner
Join condition: None

(25) Project [codegen id : 7]
Output [6]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_net_loss#7, c_current_cdemo_sk#12, c_current_hdemo_sk#13]
Input [8]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_net_loss#7, c_current_cdemo_sk#12, c_current_hdemo_sk#13, c_current_addr_sk#14, ca_address_sk#15]

(26) Scan parquet spark_catalog.default.customer_demographics
Output [3]: [cd_demo_sk#17, cd_marital_status#18, cd_education_status#19]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_demographics]
PushedFilters: [Or(And(EqualTo(cd_marital_status,M),EqualTo(cd_education_status,Unknown             )),And(EqualTo(cd_marital_status,W),EqualTo(cd_education_status,Advanced Degree     ))), IsNotNull(cd_demo_sk)]
ReadSchema: struct<cd_demo_sk:int,cd_marital_status:string,cd_education_status:string>

(27) ColumnarToRow [codegen id : 5]
Input [3]: [cd_demo_sk#17, cd_marital_status#18, cd_education_status#19]

(28) Filter [codegen id : 5]
Input [3]: [cd_demo_sk#17, cd_marital_status#18, cd_education_status#19]
Condition : ((((cd_marital_status#18 = M) AND (cd_education_status#19 = Unknown             )) OR ((cd_marital_status#18 = W) AND (cd_education_status#19 = Advanced Degree     ))) AND isnotnull(cd_demo_sk#17))

(29) BroadcastExchange
Input [3]: [cd_demo_sk#17, cd_marital_status#18, cd_education_status#19]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=4]

(30) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [c_current_cdemo_sk#12]
Right keys [1]: [cd_demo_sk#17]
Join type: Inner
Join condition: None

(31) Project [codegen id : 7]
Output [7]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_net_loss#7, c_current_hdemo_sk#13, cd_marital_status#18, cd_education_status#19]
Input [9]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_net_loss#7, c_current_cdemo_sk#12, c_current_hdemo_sk#13, cd_demo_sk#17, cd_marital_status#18, cd_education_status#19]

(32) Scan parquet spark_catalog.default.household_demographics
Output [2]: [hd_demo_sk#20, hd_buy_potential#21]
Batched: true
Location [not included in comparison]/{warehouse_dir}/household_demographics]
PushedFilters: [IsNotNull(hd_buy_potential), StringStartsWith(hd_buy_potential,Unknown), IsNotNull(hd_demo_sk)]
ReadSchema: struct<hd_demo_sk:int,hd_buy_potential:string>

(33) ColumnarToRow [codegen id : 6]
Input [2]: [hd_demo_sk#20, hd_buy_potential#21]

(34) Filter [codegen id : 6]
Input [2]: [hd_demo_sk#20, hd_buy_potential#21]
Condition : ((isnotnull(hd_buy_potential#21) AND StartsWith(hd_buy_potential#21, Unknown)) AND isnotnull(hd_demo_sk#20))

(35) Project [codegen id : 6]
Output [1]: [hd_demo_sk#20]
Input [2]: [hd_demo_sk#20, hd_buy_potential#21]

(36) BroadcastExchange
Input [1]: [hd_demo_sk#20]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=5]

(37) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [c_current_hdemo_sk#13]
Right keys [1]: [hd_demo_sk#20]
Join type: Inner
Join condition: None

(38) Project [codegen id : 7]
Output [6]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_net_loss#7, cd_marital_status#18, cd_education_status#19]
Input [8]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_net_loss#7, c_current_hdemo_sk#13, cd_marital_status#18, cd_education_status#19, hd_demo_sk#20]

(39) HashAggregate [codegen id : 7]
Input [6]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cr_net_loss#7, cd_marital_status#18, cd_education_status#19]
Keys [5]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cd_marital_status#18, cd_education_status#19]
Functions [1]: [partial_sum(UnscaledValue(cr_net_loss#7))]
Aggregate Attributes [1]: [sum#22]
Results [6]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cd_marital_status#18, cd_education_status#19, sum#23]

(40) Exchange
Input [6]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cd_marital_status#18, cd_education_status#19, sum#23]
Arguments: hashpartitioning(cc_call_center_id#2, cc_name#3, cc_manager#4, cd_marital_status#18, cd_education_status#19, 5), ENSURE_REQUIREMENTS, [plan_id=6]

(41) HashAggregate [codegen id : 8]
Input [6]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cd_marital_status#18, cd_education_status#19, sum#23]
Keys [5]: [cc_call_center_id#2, cc_name#3, cc_manager#4, cd_marital_status#18, cd_education_status#19]
Functions [1]: [sum(UnscaledValue(cr_net_loss#7))]
Aggregate Attributes [1]: [sum(UnscaledValue(cr_net_loss#7))#24]
Results [4]: [cc_call_center_id#2 AS Call_Center#25, cc_name#3 AS Call_Center_Name#26, cc_manager#4 AS Manager#27, MakeDecimal(sum(UnscaledValue(cr_net_loss#7))#24,17,2) AS Returns_Loss#28]

(42) Exchange
Input [4]: [Call_Center#25, Call_Center_Name#26, Manager#27, Returns_Loss#28]
Arguments: rangepartitioning(Returns_Loss#28 DESC NULLS LAST, 5), ENSURE_REQUIREMENTS, [plan_id=7]

(43) Sort [codegen id : 9]
Input [4]: [Call_Center#25, Call_Center_Name#26, Manager#27, Returns_Loss#28]
Arguments: [Returns_Loss#28 DESC NULLS LAST], true, 0

===== Subqueries =====

Subquery:1 Hosting operator id = 4 Hosting Expression = cr_returned_date_sk#8 IN dynamicpruning#9
BroadcastExchange (48)
+- * Project (47)
   +- * Filter (46)
      +- * ColumnarToRow (45)
         +- Scan parquet spark_catalog.default.date_dim (44)


(44) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_date_sk#10, d_year#29, d_moy#30]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_year), IsNotNull(d_moy), EqualTo(d_year,1998), EqualTo(d_moy,11), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int,d_moy:int>

(45) ColumnarToRow [codegen id : 1]
Input [3]: [d_date_sk#10, d_year#29, d_moy#30]

(46) Filter [codegen id : 1]
Input [3]: [d_date_sk#10, d_year#29, d_moy#30]
Condition : ((((isnotnull(d_year#29) AND isnotnull(d_moy#30)) AND (d_year#29 = 1998)) AND (d_moy#30 = 11)) AND isnotnull(d_date_sk#10))

(47) Project [codegen id : 1]
Output [1]: [d_date_sk#10]
Input [3]: [d_date_sk#10, d_year#29, d_moy#30]

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


