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


(1) Scan parquet spark_catalog.default.store_sales
Output [8]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7, ss_sold_date_sk#8]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#8), dynamicpruningexpression(ss_sold_date_sk#8 IN dynamicpruning#9)]
PushedFilters: [IsNotNull(ss_store_sk), IsNotNull(ss_hdemo_sk), IsNotNull(ss_addr_sk), IsNotNull(ss_customer_sk)]
ReadSchema: struct<ss_customer_sk:int,ss_hdemo_sk:int,ss_addr_sk:int,ss_store_sk:int,ss_ticket_number:int,ss_coupon_amt:decimal(7,2),ss_net_profit:decimal(7,2)>

(2) ColumnarToRow [codegen id : 5]
Input [8]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7, ss_sold_date_sk#8]

(3) Filter [codegen id : 5]
Input [8]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7, ss_sold_date_sk#8]
Condition : (((isnotnull(ss_store_sk#4) AND isnotnull(ss_hdemo_sk#2)) AND isnotnull(ss_addr_sk#3)) AND isnotnull(ss_customer_sk#1))

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

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

(6) Project [codegen id : 5]
Output [7]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7]
Input [9]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7, ss_sold_date_sk#8, d_date_sk#10]

(7) Scan parquet spark_catalog.default.store
Output [2]: [s_store_sk#11, s_city#12]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store]
PushedFilters: [In(s_city, [Fairview,Midway]), IsNotNull(s_store_sk)]
ReadSchema: struct<s_store_sk:int,s_city:string>

(8) ColumnarToRow [codegen id : 2]
Input [2]: [s_store_sk#11, s_city#12]

(9) Filter [codegen id : 2]
Input [2]: [s_store_sk#11, s_city#12]
Condition : (s_city#12 IN (Fairview,Midway) AND isnotnull(s_store_sk#11))

(10) Project [codegen id : 2]
Output [1]: [s_store_sk#11]
Input [2]: [s_store_sk#11, s_city#12]

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

(12) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [ss_store_sk#4]
Right keys [1]: [s_store_sk#11]
Join type: Inner
Join condition: None

(13) Project [codegen id : 5]
Output [6]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7]
Input [8]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7, s_store_sk#11]

(14) Scan parquet spark_catalog.default.household_demographics
Output [3]: [hd_demo_sk#13, hd_dep_count#14, hd_vehicle_count#15]
Batched: true
Location [not included in comparison]/{warehouse_dir}/household_demographics]
PushedFilters: [Or(EqualTo(hd_dep_count,4),EqualTo(hd_vehicle_count,3)), IsNotNull(hd_demo_sk)]
ReadSchema: struct<hd_demo_sk:int,hd_dep_count:int,hd_vehicle_count:int>

(15) ColumnarToRow [codegen id : 3]
Input [3]: [hd_demo_sk#13, hd_dep_count#14, hd_vehicle_count#15]

(16) Filter [codegen id : 3]
Input [3]: [hd_demo_sk#13, hd_dep_count#14, hd_vehicle_count#15]
Condition : (((hd_dep_count#14 = 4) OR (hd_vehicle_count#15 = 3)) AND isnotnull(hd_demo_sk#13))

(17) Project [codegen id : 3]
Output [1]: [hd_demo_sk#13]
Input [3]: [hd_demo_sk#13, hd_dep_count#14, hd_vehicle_count#15]

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

(19) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [ss_hdemo_sk#2]
Right keys [1]: [hd_demo_sk#13]
Join type: Inner
Join condition: None

(20) Project [codegen id : 5]
Output [5]: [ss_customer_sk#1, ss_addr_sk#3, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7]
Input [7]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7, hd_demo_sk#13]

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

(22) ColumnarToRow [codegen id : 4]
Input [2]: [ca_address_sk#16, ca_city#17]

(23) Filter [codegen id : 4]
Input [2]: [ca_address_sk#16, ca_city#17]
Condition : (isnotnull(ca_address_sk#16) AND isnotnull(ca_city#17))

(24) BroadcastExchange
Input [2]: [ca_address_sk#16, ca_city#17]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=3]

(25) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [ss_addr_sk#3]
Right keys [1]: [ca_address_sk#16]
Join type: Inner
Join condition: None

(26) Project [codegen id : 5]
Output [6]: [ss_customer_sk#1, ss_addr_sk#3, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7, ca_city#17]
Input [7]: [ss_customer_sk#1, ss_addr_sk#3, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7, ca_address_sk#16, ca_city#17]

(27) HashAggregate [codegen id : 5]
Input [6]: [ss_customer_sk#1, ss_addr_sk#3, ss_ticket_number#5, ss_coupon_amt#6, ss_net_profit#7, ca_city#17]
Keys [4]: [ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#17]
Functions [2]: [partial_sum(UnscaledValue(ss_coupon_amt#6)), partial_sum(UnscaledValue(ss_net_profit#7))]
Aggregate Attributes [2]: [sum#18, sum#19]
Results [6]: [ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#17, sum#20, sum#21]

(28) Exchange
Input [6]: [ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#17, sum#20, sum#21]
Arguments: hashpartitioning(ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#17, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(29) HashAggregate [codegen id : 8]
Input [6]: [ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#17, sum#20, sum#21]
Keys [4]: [ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#17]
Functions [2]: [sum(UnscaledValue(ss_coupon_amt#6)), sum(UnscaledValue(ss_net_profit#7))]
Aggregate Attributes [2]: [sum(UnscaledValue(ss_coupon_amt#6))#22, sum(UnscaledValue(ss_net_profit#7))#23]
Results [5]: [ss_ticket_number#5, ss_customer_sk#1, ca_city#17 AS bought_city#24, MakeDecimal(sum(UnscaledValue(ss_coupon_amt#6))#22,17,2) AS amt#25, MakeDecimal(sum(UnscaledValue(ss_net_profit#7))#23,17,2) AS profit#26]

(30) Scan parquet spark_catalog.default.customer
Output [4]: [c_customer_sk#27, c_current_addr_sk#28, c_first_name#29, c_last_name#30]
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_current_addr_sk:int,c_first_name:string,c_last_name:string>

(31) ColumnarToRow [codegen id : 6]
Input [4]: [c_customer_sk#27, c_current_addr_sk#28, c_first_name#29, c_last_name#30]

(32) Filter [codegen id : 6]
Input [4]: [c_customer_sk#27, c_current_addr_sk#28, c_first_name#29, c_last_name#30]
Condition : (isnotnull(c_customer_sk#27) AND isnotnull(c_current_addr_sk#28))

(33) BroadcastExchange
Input [4]: [c_customer_sk#27, c_current_addr_sk#28, c_first_name#29, c_last_name#30]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=5]

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

(35) Project [codegen id : 8]
Output [7]: [ss_ticket_number#5, bought_city#24, amt#25, profit#26, c_current_addr_sk#28, c_first_name#29, c_last_name#30]
Input [9]: [ss_ticket_number#5, ss_customer_sk#1, bought_city#24, amt#25, profit#26, c_customer_sk#27, c_current_addr_sk#28, c_first_name#29, c_last_name#30]

(36) ReusedExchange [Reuses operator id: 24]
Output [2]: [ca_address_sk#31, ca_city#32]

(37) BroadcastHashJoin [codegen id : 8]
Left keys [1]: [c_current_addr_sk#28]
Right keys [1]: [ca_address_sk#31]
Join type: Inner
Join condition: NOT (ca_city#32 = bought_city#24)

(38) Project [codegen id : 8]
Output [7]: [c_last_name#30, c_first_name#29, ca_city#32, bought_city#24, ss_ticket_number#5, amt#25, profit#26]
Input [9]: [ss_ticket_number#5, bought_city#24, amt#25, profit#26, c_current_addr_sk#28, c_first_name#29, c_last_name#30, ca_address_sk#31, ca_city#32]

(39) TakeOrderedAndProject
Input [7]: [c_last_name#30, c_first_name#29, ca_city#32, bought_city#24, ss_ticket_number#5, amt#25, profit#26]
Arguments: 100, [c_last_name#30 ASC NULLS FIRST, c_first_name#29 ASC NULLS FIRST, ca_city#32 ASC NULLS FIRST, bought_city#24 ASC NULLS FIRST, ss_ticket_number#5 ASC NULLS FIRST], [c_last_name#30, c_first_name#29, ca_city#32, bought_city#24, ss_ticket_number#5, amt#25, profit#26]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ss_sold_date_sk#8 IN dynamicpruning#9
BroadcastExchange (44)
+- * Project (43)
   +- * Filter (42)
      +- * ColumnarToRow (41)
         +- Scan parquet spark_catalog.default.date_dim (40)


(40) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_date_sk#10, d_year#33, d_dow#34]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [In(d_dow, [0,6]), In(d_year, [1999,2000,2001]), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int,d_dow:int>

(41) ColumnarToRow [codegen id : 1]
Input [3]: [d_date_sk#10, d_year#33, d_dow#34]

(42) Filter [codegen id : 1]
Input [3]: [d_date_sk#10, d_year#33, d_dow#34]
Condition : ((d_dow#34 IN (6,0) AND d_year#33 IN (1999,2000,2001)) AND isnotnull(d_date_sk#10))

(43) Project [codegen id : 1]
Output [1]: [d_date_sk#10]
Input [3]: [d_date_sk#10, d_year#33, d_dow#34]

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


