== Physical Plan ==
TakeOrderedAndProject (28)
+- * HashAggregate (27)
   +- Exchange (26)
      +- * HashAggregate (25)
         +- * Project (24)
            +- * SortMergeJoin Inner (23)
               :- * Sort (8)
               :  +- Exchange (7)
               :     +- * Project (6)
               :        +- * BroadcastHashJoin Inner BuildRight (5)
               :           :- * Filter (3)
               :           :  +- * ColumnarToRow (2)
               :           :     +- Scan parquet spark_catalog.default.catalog_sales (1)
               :           +- ReusedExchange (4)
               +- * Sort (22)
                  +- Exchange (21)
                     +- * Project (20)
                        +- * SortMergeJoin Inner (19)
                           :- * Sort (13)
                           :  +- Exchange (12)
                           :     +- * Filter (11)
                           :        +- * ColumnarToRow (10)
                           :           +- Scan parquet spark_catalog.default.customer (9)
                           +- * Sort (18)
                              +- Exchange (17)
                                 +- * Filter (16)
                                    +- * ColumnarToRow (15)
                                       +- Scan parquet spark_catalog.default.customer_address (14)


(1) Scan parquet spark_catalog.default.catalog_sales
Output [3]: [cs_bill_customer_sk#1, cs_sales_price#2, cs_sold_date_sk#3]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(cs_sold_date_sk#3), dynamicpruningexpression(cs_sold_date_sk#3 IN dynamicpruning#4)]
PushedFilters: [IsNotNull(cs_bill_customer_sk)]
ReadSchema: struct<cs_bill_customer_sk:int,cs_sales_price:decimal(7,2)>

(2) ColumnarToRow [codegen id : 2]
Input [3]: [cs_bill_customer_sk#1, cs_sales_price#2, cs_sold_date_sk#3]

(3) Filter [codegen id : 2]
Input [3]: [cs_bill_customer_sk#1, cs_sales_price#2, cs_sold_date_sk#3]
Condition : isnotnull(cs_bill_customer_sk#1)

(4) ReusedExchange [Reuses operator id: 33]
Output [1]: [d_date_sk#5]

(5) BroadcastHashJoin [codegen id : 2]
Left keys [1]: [cs_sold_date_sk#3]
Right keys [1]: [d_date_sk#5]
Join type: Inner
Join condition: None

(6) Project [codegen id : 2]
Output [2]: [cs_bill_customer_sk#1, cs_sales_price#2]
Input [4]: [cs_bill_customer_sk#1, cs_sales_price#2, cs_sold_date_sk#3, d_date_sk#5]

(7) Exchange
Input [2]: [cs_bill_customer_sk#1, cs_sales_price#2]
Arguments: hashpartitioning(cs_bill_customer_sk#1, 5), ENSURE_REQUIREMENTS, [plan_id=1]

(8) Sort [codegen id : 3]
Input [2]: [cs_bill_customer_sk#1, cs_sales_price#2]
Arguments: [cs_bill_customer_sk#1 ASC NULLS FIRST], false, 0

(9) Scan parquet spark_catalog.default.customer
Output [2]: [c_customer_sk#6, c_current_addr_sk#7]
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>

(10) ColumnarToRow [codegen id : 4]
Input [2]: [c_customer_sk#6, c_current_addr_sk#7]

(11) Filter [codegen id : 4]
Input [2]: [c_customer_sk#6, c_current_addr_sk#7]
Condition : (isnotnull(c_customer_sk#6) AND isnotnull(c_current_addr_sk#7))

(12) Exchange
Input [2]: [c_customer_sk#6, c_current_addr_sk#7]
Arguments: hashpartitioning(c_current_addr_sk#7, 5), ENSURE_REQUIREMENTS, [plan_id=2]

(13) Sort [codegen id : 5]
Input [2]: [c_customer_sk#6, c_current_addr_sk#7]
Arguments: [c_current_addr_sk#7 ASC NULLS FIRST], false, 0

(14) Scan parquet spark_catalog.default.customer_address
Output [3]: [ca_address_sk#8, ca_state#9, ca_zip#10]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_address]
PushedFilters: [IsNotNull(ca_address_sk)]
ReadSchema: struct<ca_address_sk:int,ca_state:string,ca_zip:string>

(15) ColumnarToRow [codegen id : 6]
Input [3]: [ca_address_sk#8, ca_state#9, ca_zip#10]

(16) Filter [codegen id : 6]
Input [3]: [ca_address_sk#8, ca_state#9, ca_zip#10]
Condition : isnotnull(ca_address_sk#8)

(17) Exchange
Input [3]: [ca_address_sk#8, ca_state#9, ca_zip#10]
Arguments: hashpartitioning(ca_address_sk#8, 5), ENSURE_REQUIREMENTS, [plan_id=3]

(18) Sort [codegen id : 7]
Input [3]: [ca_address_sk#8, ca_state#9, ca_zip#10]
Arguments: [ca_address_sk#8 ASC NULLS FIRST], false, 0

(19) SortMergeJoin [codegen id : 8]
Left keys [1]: [c_current_addr_sk#7]
Right keys [1]: [ca_address_sk#8]
Join type: Inner
Join condition: None

(20) Project [codegen id : 8]
Output [3]: [c_customer_sk#6, ca_state#9, ca_zip#10]
Input [5]: [c_customer_sk#6, c_current_addr_sk#7, ca_address_sk#8, ca_state#9, ca_zip#10]

(21) Exchange
Input [3]: [c_customer_sk#6, ca_state#9, ca_zip#10]
Arguments: hashpartitioning(c_customer_sk#6, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(22) Sort [codegen id : 9]
Input [3]: [c_customer_sk#6, ca_state#9, ca_zip#10]
Arguments: [c_customer_sk#6 ASC NULLS FIRST], false, 0

(23) SortMergeJoin [codegen id : 10]
Left keys [1]: [cs_bill_customer_sk#1]
Right keys [1]: [c_customer_sk#6]
Join type: Inner
Join condition: ((substr(ca_zip#10, 1, 5) IN (85669,86197,88274,83405,86475,85392,85460,80348,81792) OR ca_state#9 IN (CA,WA,GA)) OR (cs_sales_price#2 > 500.00))

(24) Project [codegen id : 10]
Output [2]: [cs_sales_price#2, ca_zip#10]
Input [5]: [cs_bill_customer_sk#1, cs_sales_price#2, c_customer_sk#6, ca_state#9, ca_zip#10]

(25) HashAggregate [codegen id : 10]
Input [2]: [cs_sales_price#2, ca_zip#10]
Keys [1]: [ca_zip#10]
Functions [1]: [partial_sum(UnscaledValue(cs_sales_price#2))]
Aggregate Attributes [1]: [sum#11]
Results [2]: [ca_zip#10, sum#12]

(26) Exchange
Input [2]: [ca_zip#10, sum#12]
Arguments: hashpartitioning(ca_zip#10, 5), ENSURE_REQUIREMENTS, [plan_id=5]

(27) HashAggregate [codegen id : 11]
Input [2]: [ca_zip#10, sum#12]
Keys [1]: [ca_zip#10]
Functions [1]: [sum(UnscaledValue(cs_sales_price#2))]
Aggregate Attributes [1]: [sum(UnscaledValue(cs_sales_price#2))#13]
Results [2]: [ca_zip#10, MakeDecimal(sum(UnscaledValue(cs_sales_price#2))#13,17,2) AS sum(cs_sales_price)#14]

(28) TakeOrderedAndProject
Input [2]: [ca_zip#10, sum(cs_sales_price)#14]
Arguments: 100, [ca_zip#10 ASC NULLS FIRST], [ca_zip#10, sum(cs_sales_price)#14]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = cs_sold_date_sk#3 IN dynamicpruning#4
BroadcastExchange (33)
+- * Project (32)
   +- * Filter (31)
      +- * ColumnarToRow (30)
         +- Scan parquet spark_catalog.default.date_dim (29)


(29) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_date_sk#5, d_year#15, d_qoy#16]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_qoy), IsNotNull(d_year), EqualTo(d_qoy,2), EqualTo(d_year,2001), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int,d_qoy:int>

(30) ColumnarToRow [codegen id : 1]
Input [3]: [d_date_sk#5, d_year#15, d_qoy#16]

(31) Filter [codegen id : 1]
Input [3]: [d_date_sk#5, d_year#15, d_qoy#16]
Condition : ((((isnotnull(d_qoy#16) AND isnotnull(d_year#15)) AND (d_qoy#16 = 2)) AND (d_year#15 = 2001)) AND isnotnull(d_date_sk#5))

(32) Project [codegen id : 1]
Output [1]: [d_date_sk#5]
Input [3]: [d_date_sk#5, d_year#15, d_qoy#16]

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


