== 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 [9]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_ext_sales_price#6, ss_ext_list_price#7, ss_ext_tax#8, ss_sold_date_sk#9]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#9), dynamicpruningexpression(ss_sold_date_sk#9 IN dynamicpruning#10)]
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_ext_sales_price:decimal(7,2),ss_ext_list_price:decimal(7,2),ss_ext_tax:decimal(7,2)>

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

(3) Filter [codegen id : 5]
Input [9]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_ext_sales_price#6, ss_ext_list_price#7, ss_ext_tax#8, ss_sold_date_sk#9]
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#11]

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

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

(7) Scan parquet spark_catalog.default.store
Output [2]: [s_store_sk#12, s_city#13]
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#12, s_city#13]

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

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

(11) BroadcastExchange
Input [1]: [s_store_sk#12]
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#12]
Join type: Inner
Join condition: None

(13) Project [codegen id : 5]
Output [7]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_ticket_number#5, ss_ext_sales_price#6, ss_ext_list_price#7, ss_ext_tax#8]
Input [9]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_ext_sales_price#6, ss_ext_list_price#7, ss_ext_tax#8, s_store_sk#12]

(14) Scan parquet spark_catalog.default.household_demographics
Output [3]: [hd_demo_sk#14, hd_dep_count#15, hd_vehicle_count#16]
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#14, hd_dep_count#15, hd_vehicle_count#16]

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

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

(18) BroadcastExchange
Input [1]: [hd_demo_sk#14]
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#14]
Join type: Inner
Join condition: None

(20) Project [codegen id : 5]
Output [6]: [ss_customer_sk#1, ss_addr_sk#3, ss_ticket_number#5, ss_ext_sales_price#6, ss_ext_list_price#7, ss_ext_tax#8]
Input [8]: [ss_customer_sk#1, ss_hdemo_sk#2, ss_addr_sk#3, ss_ticket_number#5, ss_ext_sales_price#6, ss_ext_list_price#7, ss_ext_tax#8, hd_demo_sk#14]

(21) Scan parquet spark_catalog.default.customer_address
Output [2]: [ca_address_sk#17, ca_city#18]
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#17, ca_city#18]

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

(24) BroadcastExchange
Input [2]: [ca_address_sk#17, ca_city#18]
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#17]
Join type: Inner
Join condition: None

(26) Project [codegen id : 5]
Output [7]: [ss_customer_sk#1, ss_addr_sk#3, ss_ticket_number#5, ss_ext_sales_price#6, ss_ext_list_price#7, ss_ext_tax#8, ca_city#18]
Input [8]: [ss_customer_sk#1, ss_addr_sk#3, ss_ticket_number#5, ss_ext_sales_price#6, ss_ext_list_price#7, ss_ext_tax#8, ca_address_sk#17, ca_city#18]

(27) HashAggregate [codegen id : 5]
Input [7]: [ss_customer_sk#1, ss_addr_sk#3, ss_ticket_number#5, ss_ext_sales_price#6, ss_ext_list_price#7, ss_ext_tax#8, ca_city#18]
Keys [4]: [ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#18]
Functions [3]: [partial_sum(UnscaledValue(ss_ext_sales_price#6)), partial_sum(UnscaledValue(ss_ext_list_price#7)), partial_sum(UnscaledValue(ss_ext_tax#8))]
Aggregate Attributes [3]: [sum#19, sum#20, sum#21]
Results [7]: [ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#18, sum#22, sum#23, sum#24]

(28) Exchange
Input [7]: [ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#18, sum#22, sum#23, sum#24]
Arguments: hashpartitioning(ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#18, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(29) HashAggregate [codegen id : 8]
Input [7]: [ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#18, sum#22, sum#23, sum#24]
Keys [4]: [ss_ticket_number#5, ss_customer_sk#1, ss_addr_sk#3, ca_city#18]
Functions [3]: [sum(UnscaledValue(ss_ext_sales_price#6)), sum(UnscaledValue(ss_ext_list_price#7)), sum(UnscaledValue(ss_ext_tax#8))]
Aggregate Attributes [3]: [sum(UnscaledValue(ss_ext_sales_price#6))#25, sum(UnscaledValue(ss_ext_list_price#7))#26, sum(UnscaledValue(ss_ext_tax#8))#27]
Results [6]: [ss_ticket_number#5, ss_customer_sk#1, ca_city#18 AS bought_city#28, MakeDecimal(sum(UnscaledValue(ss_ext_sales_price#6))#25,17,2) AS extended_price#29, MakeDecimal(sum(UnscaledValue(ss_ext_list_price#7))#26,17,2) AS list_price#30, MakeDecimal(sum(UnscaledValue(ss_ext_tax#8))#27,17,2) AS extended_tax#31]

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

(32) Filter [codegen id : 6]
Input [4]: [c_customer_sk#32, c_current_addr_sk#33, c_first_name#34, c_last_name#35]
Condition : (isnotnull(c_customer_sk#32) AND isnotnull(c_current_addr_sk#33))

(33) BroadcastExchange
Input [4]: [c_customer_sk#32, c_current_addr_sk#33, c_first_name#34, c_last_name#35]
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#32]
Join type: Inner
Join condition: None

(35) Project [codegen id : 8]
Output [8]: [ss_ticket_number#5, bought_city#28, extended_price#29, list_price#30, extended_tax#31, c_current_addr_sk#33, c_first_name#34, c_last_name#35]
Input [10]: [ss_ticket_number#5, ss_customer_sk#1, bought_city#28, extended_price#29, list_price#30, extended_tax#31, c_customer_sk#32, c_current_addr_sk#33, c_first_name#34, c_last_name#35]

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

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

(38) Project [codegen id : 8]
Output [8]: [c_last_name#35, c_first_name#34, ca_city#37, bought_city#28, ss_ticket_number#5, extended_price#29, extended_tax#31, list_price#30]
Input [10]: [ss_ticket_number#5, bought_city#28, extended_price#29, list_price#30, extended_tax#31, c_current_addr_sk#33, c_first_name#34, c_last_name#35, ca_address_sk#36, ca_city#37]

(39) TakeOrderedAndProject
Input [8]: [c_last_name#35, c_first_name#34, ca_city#37, bought_city#28, ss_ticket_number#5, extended_price#29, extended_tax#31, list_price#30]
Arguments: 100, [c_last_name#35 ASC NULLS FIRST, ss_ticket_number#5 ASC NULLS FIRST], [c_last_name#35, c_first_name#34, ca_city#37, bought_city#28, ss_ticket_number#5, extended_price#29, extended_tax#31, list_price#30]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ss_sold_date_sk#9 IN dynamicpruning#10
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#11, d_year#38, d_dom#39]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_dom), GreaterThanOrEqual(d_dom,1), LessThanOrEqual(d_dom,2), In(d_year, [1999,2000,2001]), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int,d_dom:int>

(41) ColumnarToRow [codegen id : 1]
Input [3]: [d_date_sk#11, d_year#38, d_dom#39]

(42) Filter [codegen id : 1]
Input [3]: [d_date_sk#11, d_year#38, d_dom#39]
Condition : ((((isnotnull(d_dom#39) AND (d_dom#39 >= 1)) AND (d_dom#39 <= 2)) AND d_year#38 IN (1999,2000,2001)) AND isnotnull(d_date_sk#11))

(43) Project [codegen id : 1]
Output [1]: [d_date_sk#11]
Input [3]: [d_date_sk#11, d_year#38, d_dom#39]

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


