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


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

(2) ColumnarToRow [codegen id : 5]
Input [3]: [ss_item_sk#1, ss_customer_sk#2, ss_sold_date_sk#3]

(3) Filter [codegen id : 5]
Input [3]: [ss_item_sk#1, ss_customer_sk#2, ss_sold_date_sk#3]
Condition : (isnotnull(ss_customer_sk#2) AND isnotnull(ss_item_sk#1))

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

(5) ColumnarToRow [codegen id : 3]
Input [3]: [i_item_sk#5, i_current_price#6, i_category#7]

(6) Filter [codegen id : 3]
Input [3]: [i_item_sk#5, i_current_price#6, i_category#7]
Condition : (isnotnull(i_current_price#6) AND isnotnull(i_item_sk#5))

(7) Scan parquet default.item
Output [2]: [i_current_price#8, i_category#9]
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>

(8) ColumnarToRow [codegen id : 1]
Input [2]: [i_current_price#8, i_category#9]

(9) Filter [codegen id : 1]
Input [2]: [i_current_price#8, i_category#9]
Condition : isnotnull(i_category#9)

(10) HashAggregate [codegen id : 1]
Input [2]: [i_current_price#8, i_category#9]
Keys [1]: [i_category#9]
Functions [1]: [partial_avg(UnscaledValue(i_current_price#8))]
Aggregate Attributes [2]: [sum#10, count#11]
Results [3]: [i_category#9, sum#12, count#13]

(11) Exchange
Input [3]: [i_category#9, sum#12, count#13]
Arguments: hashpartitioning(i_category#9, 5), ENSURE_REQUIREMENTS, [id=#14]

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

(13) BroadcastExchange
Input [2]: [avg(i_current_price)#16, i_category#9]
Arguments: HashedRelationBroadcastMode(List(input[1, string, true]),false), [id=#17]

(14) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [i_category#7]
Right keys [1]: [i_category#9]
Join condition: None

(15) Filter [codegen id : 3]
Input [5]: [i_item_sk#5, i_current_price#6, i_category#7, avg(i_current_price)#16, i_category#9]
Condition : (cast(i_current_price#6 as decimal(14,7)) > CheckOverflow((1.200000 * promote_precision(avg(i_current_price)#16)), DecimalType(14,7), true))

(16) Project [codegen id : 3]
Output [1]: [i_item_sk#5]
Input [5]: [i_item_sk#5, i_current_price#6, i_category#7, avg(i_current_price)#16, i_category#9]

(17) BroadcastExchange
Input [1]: [i_item_sk#5]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#18]

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

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

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

(21) ColumnarToRow [codegen id : 4]
Input [2]: [d_date_sk#19, d_month_seq#20]

(22) Filter [codegen id : 4]
Input [2]: [d_date_sk#19, d_month_seq#20]
Condition : ((isnotnull(d_month_seq#20) AND (d_month_seq#20 = Subquery scalar-subquery#21, [id=#22])) AND isnotnull(d_date_sk#19))

(23) Project [codegen id : 4]
Output [1]: [d_date_sk#19]
Input [2]: [d_date_sk#19, d_month_seq#20]

(24) BroadcastExchange
Input [1]: [d_date_sk#19]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#23]

(25) BroadcastHashJoin [codegen id : 5]
Left keys [1]: [ss_sold_date_sk#3]
Right keys [1]: [d_date_sk#19]
Join condition: None

(26) Project [codegen id : 5]
Output [1]: [ss_customer_sk#2]
Input [3]: [ss_customer_sk#2, ss_sold_date_sk#3, d_date_sk#19]

(27) Exchange
Input [1]: [ss_customer_sk#2]
Arguments: hashpartitioning(ss_customer_sk#2, 5), ENSURE_REQUIREMENTS, [id=#24]

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

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

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

(31) Filter [codegen id : 7]
Input [2]: [ca_address_sk#25, ca_state#26]
Condition : isnotnull(ca_address_sk#25)

(32) Exchange
Input [2]: [ca_address_sk#25, ca_state#26]
Arguments: hashpartitioning(ca_address_sk#25, 5), ENSURE_REQUIREMENTS, [id=#27]

(33) Sort [codegen id : 8]
Input [2]: [ca_address_sk#25, ca_state#26]
Arguments: [ca_address_sk#25 ASC NULLS FIRST], false, 0

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

(35) ColumnarToRow [codegen id : 9]
Input [2]: [c_customer_sk#28, c_current_addr_sk#29]

(36) Filter [codegen id : 9]
Input [2]: [c_customer_sk#28, c_current_addr_sk#29]
Condition : (isnotnull(c_current_addr_sk#29) AND isnotnull(c_customer_sk#28))

(37) Exchange
Input [2]: [c_customer_sk#28, c_current_addr_sk#29]
Arguments: hashpartitioning(c_current_addr_sk#29, 5), ENSURE_REQUIREMENTS, [id=#30]

(38) Sort [codegen id : 10]
Input [2]: [c_customer_sk#28, c_current_addr_sk#29]
Arguments: [c_current_addr_sk#29 ASC NULLS FIRST], false, 0

(39) SortMergeJoin [codegen id : 11]
Left keys [1]: [ca_address_sk#25]
Right keys [1]: [c_current_addr_sk#29]
Join condition: None

(40) Project [codegen id : 11]
Output [2]: [ca_state#26, c_customer_sk#28]
Input [4]: [ca_address_sk#25, ca_state#26, c_customer_sk#28, c_current_addr_sk#29]

(41) Exchange
Input [2]: [ca_state#26, c_customer_sk#28]
Arguments: hashpartitioning(c_customer_sk#28, 5), ENSURE_REQUIREMENTS, [id=#31]

(42) Sort [codegen id : 12]
Input [2]: [ca_state#26, c_customer_sk#28]
Arguments: [c_customer_sk#28 ASC NULLS FIRST], false, 0

(43) SortMergeJoin [codegen id : 13]
Left keys [1]: [ss_customer_sk#2]
Right keys [1]: [c_customer_sk#28]
Join condition: None

(44) Project [codegen id : 13]
Output [1]: [ca_state#26]
Input [3]: [ss_customer_sk#2, ca_state#26, c_customer_sk#28]

(45) HashAggregate [codegen id : 13]
Input [1]: [ca_state#26]
Keys [1]: [ca_state#26]
Functions [1]: [partial_count(1)]
Aggregate Attributes [1]: [count#32]
Results [2]: [ca_state#26, count#33]

(46) Exchange
Input [2]: [ca_state#26, count#33]
Arguments: hashpartitioning(ca_state#26, 5), ENSURE_REQUIREMENTS, [id=#34]

(47) HashAggregate [codegen id : 14]
Input [2]: [ca_state#26, count#33]
Keys [1]: [ca_state#26]
Functions [1]: [count(1)]
Aggregate Attributes [1]: [count(1)#35]
Results [3]: [ca_state#26 AS state#36, count(1)#35 AS cnt#37, count(1)#35 AS count(1)#38]

(48) Filter [codegen id : 14]
Input [3]: [state#36, cnt#37, count(1)#38]
Condition : (count(1)#38 >= 10)

(49) Project [codegen id : 14]
Output [2]: [state#36, cnt#37]
Input [3]: [state#36, cnt#37, count(1)#38]

(50) TakeOrderedAndProject
Input [2]: [state#36, cnt#37]
Arguments: 100, [cnt#37 ASC NULLS FIRST], [state#36, cnt#37]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ss_sold_date_sk#3 IN dynamicpruning#4
ReusedExchange (51)


(51) ReusedExchange [Reuses operator id: 24]
Output [1]: [d_date_sk#19]

Subquery:2 Hosting operator id = 22 Hosting Expression = Subquery scalar-subquery#21, [id=#22]
* HashAggregate (58)
+- Exchange (57)
   +- * HashAggregate (56)
      +- * Project (55)
         +- * Filter (54)
            +- * ColumnarToRow (53)
               +- Scan parquet default.date_dim (52)


(52) Scan parquet default.date_dim
Output [3]: [d_month_seq#39, d_year#40, d_moy#41]
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>

(53) ColumnarToRow [codegen id : 1]
Input [3]: [d_month_seq#39, d_year#40, d_moy#41]

(54) Filter [codegen id : 1]
Input [3]: [d_month_seq#39, d_year#40, d_moy#41]
Condition : (((isnotnull(d_year#40) AND isnotnull(d_moy#41)) AND (d_year#40 = 2000)) AND (d_moy#41 = 1))

(55) Project [codegen id : 1]
Output [1]: [d_month_seq#39]
Input [3]: [d_month_seq#39, d_year#40, d_moy#41]

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

(57) Exchange
Input [1]: [d_month_seq#39]
Arguments: hashpartitioning(d_month_seq#39, 5), ENSURE_REQUIREMENTS, [id=#42]

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


