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


(1) Scan parquet spark_catalog.default.item
Output [3]: [i_item_sk#1, i_current_price#2, i_category#3]
Batched: true
Location [not included in comparison]/{warehouse_dir}/item]
PushedFilters: [IsNotNull(i_current_price), IsNotNull(i_category), IsNotNull(i_item_sk)]
ReadSchema: struct<i_item_sk:int,i_current_price:decimal(7,2),i_category:string>

(2) ColumnarToRow [codegen id : 3]
Input [3]: [i_item_sk#1, i_current_price#2, i_category#3]

(3) Filter [codegen id : 3]
Input [3]: [i_item_sk#1, i_current_price#2, i_category#3]
Condition : ((isnotnull(i_current_price#2) AND isnotnull(i_category#3)) AND isnotnull(i_item_sk#1))

(4) Scan parquet spark_catalog.default.item
Output [2]: [i_current_price#4, i_category#5]
Batched: true
Location [not included in comparison]/{warehouse_dir}/item]
PushedFilters: [IsNotNull(i_category)]
ReadSchema: struct<i_current_price:decimal(7,2),i_category:string>

(5) ColumnarToRow [codegen id : 1]
Input [2]: [i_current_price#4, i_category#5]

(6) Filter [codegen id : 1]
Input [2]: [i_current_price#4, i_category#5]
Condition : isnotnull(i_category#5)

(7) HashAggregate [codegen id : 1]
Input [2]: [i_current_price#4, i_category#5]
Keys [1]: [i_category#5]
Functions [1]: [partial_avg(UnscaledValue(i_current_price#4))]
Aggregate Attributes [2]: [sum#6, count#7]
Results [3]: [i_category#5, sum#8, count#9]

(8) Exchange
Input [3]: [i_category#5, sum#8, count#9]
Arguments: hashpartitioning(i_category#5, 5), ENSURE_REQUIREMENTS, [plan_id=1]

(9) HashAggregate [codegen id : 2]
Input [3]: [i_category#5, sum#8, count#9]
Keys [1]: [i_category#5]
Functions [1]: [avg(UnscaledValue(i_current_price#4))]
Aggregate Attributes [1]: [avg(UnscaledValue(i_current_price#4))#10]
Results [2]: [cast((avg(UnscaledValue(i_current_price#4))#10 / 100.0) as decimal(11,6)) AS avg(i_current_price)#11, i_category#5]

(10) Filter [codegen id : 2]
Input [2]: [avg(i_current_price)#11, i_category#5]
Condition : isnotnull(avg(i_current_price)#11)

(11) BroadcastExchange
Input [2]: [avg(i_current_price)#11, i_category#5]
Arguments: HashedRelationBroadcastMode(List(input[1, string, true]),false), [plan_id=2]

(12) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [i_category#3]
Right keys [1]: [i_category#5]
Join type: Inner
Join condition: (cast(i_current_price#2 as decimal(14,7)) > (1.2 * avg(i_current_price)#11))

(13) Project [codegen id : 3]
Output [1]: [i_item_sk#1]
Input [5]: [i_item_sk#1, i_current_price#2, i_category#3, avg(i_current_price)#11, i_category#5]

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

(15) Scan parquet spark_catalog.default.store_sales
Output [3]: [ss_item_sk#12, ss_customer_sk#13, ss_sold_date_sk#14]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#14), dynamicpruningexpression(ss_sold_date_sk#14 IN dynamicpruning#15)]
PushedFilters: [IsNotNull(ss_customer_sk), IsNotNull(ss_item_sk)]
ReadSchema: struct<ss_item_sk:int,ss_customer_sk:int>

(16) ColumnarToRow
Input [3]: [ss_item_sk#12, ss_customer_sk#13, ss_sold_date_sk#14]

(17) Filter
Input [3]: [ss_item_sk#12, ss_customer_sk#13, ss_sold_date_sk#14]
Condition : (isnotnull(ss_customer_sk#13) AND isnotnull(ss_item_sk#12))

(18) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [i_item_sk#1]
Right keys [1]: [ss_item_sk#12]
Join type: Inner
Join condition: None

(19) Project [codegen id : 5]
Output [2]: [ss_customer_sk#13, ss_sold_date_sk#14]
Input [4]: [i_item_sk#1, ss_item_sk#12, ss_customer_sk#13, ss_sold_date_sk#14]

(20) ReusedExchange [Reuses operator id: 50]
Output [1]: [d_date_sk#16]

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

(22) Project [codegen id : 5]
Output [1]: [ss_customer_sk#13]
Input [3]: [ss_customer_sk#13, ss_sold_date_sk#14, d_date_sk#16]

(23) Exchange
Input [1]: [ss_customer_sk#13]
Arguments: hashpartitioning(ss_customer_sk#13, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(24) Sort [codegen id : 6]
Input [1]: [ss_customer_sk#13]
Arguments: [ss_customer_sk#13 ASC NULLS FIRST], false, 0

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

(26) ColumnarToRow [codegen id : 7]
Input [2]: [ca_address_sk#17, ca_state#18]

(27) Filter [codegen id : 7]
Input [2]: [ca_address_sk#17, ca_state#18]
Condition : isnotnull(ca_address_sk#17)

(28) Exchange
Input [2]: [ca_address_sk#17, ca_state#18]
Arguments: hashpartitioning(ca_address_sk#17, 5), ENSURE_REQUIREMENTS, [plan_id=5]

(29) Sort [codegen id : 8]
Input [2]: [ca_address_sk#17, ca_state#18]
Arguments: [ca_address_sk#17 ASC NULLS FIRST], false, 0

(30) Scan parquet spark_catalog.default.customer
Output [2]: [c_customer_sk#19, c_current_addr_sk#20]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer]
PushedFilters: [IsNotNull(c_current_addr_sk), IsNotNull(c_customer_sk)]
ReadSchema: struct<c_customer_sk:int,c_current_addr_sk:int>

(31) ColumnarToRow [codegen id : 9]
Input [2]: [c_customer_sk#19, c_current_addr_sk#20]

(32) Filter [codegen id : 9]
Input [2]: [c_customer_sk#19, c_current_addr_sk#20]
Condition : (isnotnull(c_current_addr_sk#20) AND isnotnull(c_customer_sk#19))

(33) Exchange
Input [2]: [c_customer_sk#19, c_current_addr_sk#20]
Arguments: hashpartitioning(c_current_addr_sk#20, 5), ENSURE_REQUIREMENTS, [plan_id=6]

(34) Sort [codegen id : 10]
Input [2]: [c_customer_sk#19, c_current_addr_sk#20]
Arguments: [c_current_addr_sk#20 ASC NULLS FIRST], false, 0

(35) SortMergeJoin [codegen id : 11]
Left keys [1]: [ca_address_sk#17]
Right keys [1]: [c_current_addr_sk#20]
Join type: Inner
Join condition: None

(36) Project [codegen id : 11]
Output [2]: [ca_state#18, c_customer_sk#19]
Input [4]: [ca_address_sk#17, ca_state#18, c_customer_sk#19, c_current_addr_sk#20]

(37) Exchange
Input [2]: [ca_state#18, c_customer_sk#19]
Arguments: hashpartitioning(c_customer_sk#19, 5), ENSURE_REQUIREMENTS, [plan_id=7]

(38) Sort [codegen id : 12]
Input [2]: [ca_state#18, c_customer_sk#19]
Arguments: [c_customer_sk#19 ASC NULLS FIRST], false, 0

(39) SortMergeJoin [codegen id : 13]
Left keys [1]: [ss_customer_sk#13]
Right keys [1]: [c_customer_sk#19]
Join type: Inner
Join condition: None

(40) Project [codegen id : 13]
Output [1]: [ca_state#18]
Input [3]: [ss_customer_sk#13, ca_state#18, c_customer_sk#19]

(41) HashAggregate [codegen id : 13]
Input [1]: [ca_state#18]
Keys [1]: [ca_state#18]
Functions [1]: [partial_count(1)]
Aggregate Attributes [1]: [count#21]
Results [2]: [ca_state#18, count#22]

(42) Exchange
Input [2]: [ca_state#18, count#22]
Arguments: hashpartitioning(ca_state#18, 5), ENSURE_REQUIREMENTS, [plan_id=8]

(43) HashAggregate [codegen id : 14]
Input [2]: [ca_state#18, count#22]
Keys [1]: [ca_state#18]
Functions [1]: [count(1)]
Aggregate Attributes [1]: [count(1)#23]
Results [2]: [ca_state#18 AS state#24, count(1)#23 AS cnt#25]

(44) Filter [codegen id : 14]
Input [2]: [state#24, cnt#25]
Condition : (cnt#25 >= 10)

(45) TakeOrderedAndProject
Input [2]: [state#24, cnt#25]
Arguments: 100, [cnt#25 ASC NULLS FIRST], [state#24, cnt#25]

===== Subqueries =====

Subquery:1 Hosting operator id = 15 Hosting Expression = ss_sold_date_sk#14 IN dynamicpruning#15
BroadcastExchange (50)
+- * Project (49)
   +- * Filter (48)
      +- * ColumnarToRow (47)
         +- Scan parquet spark_catalog.default.date_dim (46)


(46) Scan parquet spark_catalog.default.date_dim
Output [2]: [d_date_sk#16, d_month_seq#26]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_month_seq), EqualTo(d_month_seq,ScalarSubquery#27), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_month_seq:int>

(47) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#16, d_month_seq#26]

(48) Filter [codegen id : 1]
Input [2]: [d_date_sk#16, d_month_seq#26]
Condition : ((isnotnull(d_month_seq#26) AND (d_month_seq#26 = ReusedSubquery Subquery scalar-subquery#27, [id=#9])) AND isnotnull(d_date_sk#16))

(49) Project [codegen id : 1]
Output [1]: [d_date_sk#16]
Input [2]: [d_date_sk#16, d_month_seq#26]

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

Subquery:2 Hosting operator id = 48 Hosting Expression = ReusedSubquery Subquery scalar-subquery#27, [id=#9]

Subquery:3 Hosting operator id = 46 Hosting Expression = Subquery scalar-subquery#27, [id=#9]
* HashAggregate (57)
+- Exchange (56)
   +- * HashAggregate (55)
      +- * Project (54)
         +- * Filter (53)
            +- * ColumnarToRow (52)
               +- Scan parquet spark_catalog.default.date_dim (51)


(51) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_month_seq#28, 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,2000), EqualTo(d_moy,1)]
ReadSchema: struct<d_month_seq:int,d_year:int,d_moy:int>

(52) ColumnarToRow [codegen id : 1]
Input [3]: [d_month_seq#28, d_year#29, d_moy#30]

(53) Filter [codegen id : 1]
Input [3]: [d_month_seq#28, d_year#29, d_moy#30]
Condition : (((isnotnull(d_year#29) AND isnotnull(d_moy#30)) AND (d_year#29 = 2000)) AND (d_moy#30 = 1))

(54) Project [codegen id : 1]
Output [1]: [d_month_seq#28]
Input [3]: [d_month_seq#28, d_year#29, d_moy#30]

(55) HashAggregate [codegen id : 1]
Input [1]: [d_month_seq#28]
Keys [1]: [d_month_seq#28]
Functions: []
Aggregate Attributes: []
Results [1]: [d_month_seq#28]

(56) Exchange
Input [1]: [d_month_seq#28]
Arguments: hashpartitioning(d_month_seq#28, 5), ENSURE_REQUIREMENTS, [plan_id=11]

(57) HashAggregate [codegen id : 2]
Input [1]: [d_month_seq#28]
Keys [1]: [d_month_seq#28]
Functions: []
Aggregate Attributes: []
Results [1]: [d_month_seq#28]


