== 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_sold_date_sk#1, ss_item_sk#2, ss_customer_sk#3]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store_sales]
PushedFilters: [IsNotNull(ss_customer_sk), IsNotNull(ss_sold_date_sk), IsNotNull(ss_item_sk)]
ReadSchema: struct<ss_sold_date_sk:int,ss_item_sk:int,ss_customer_sk:int>

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

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

(4) Scan parquet default.item
Output [3]: [i_item_sk#4, i_current_price#5, i_category#6]
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#4, i_current_price#5, i_category#6]

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

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

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

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

(11) Exchange
Input [3]: [i_category#6, sum#9, count#10]
Arguments: hashpartitioning(i_category#6, 5), true, [id=#11]

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

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

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

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

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

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

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

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

(20) Scan parquet default.date_dim
Output [2]: [d_date_sk#17, d_month_seq#18]
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#17, d_month_seq#18]

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

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

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

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

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

(27) Exchange
Input [1]: [ss_customer_sk#3]
Arguments: hashpartitioning(ss_customer_sk#3, 5), true, [id=#22]

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

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

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

(32) Exchange
Input [2]: [ca_address_sk#23, ca_state#24]
Arguments: hashpartitioning(ca_address_sk#23, 5), true, [id=#25]

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

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

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

(37) Exchange
Input [2]: [c_customer_sk#26, c_current_addr_sk#27]
Arguments: hashpartitioning(c_current_addr_sk#27, 5), true, [id=#28]

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

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

(40) Project [codegen id : 11]
Output [2]: [ca_state#24, c_customer_sk#26]
Input [4]: [ca_address_sk#23, ca_state#24, c_customer_sk#26, c_current_addr_sk#27]

(41) Exchange
Input [2]: [ca_state#24, c_customer_sk#26]
Arguments: hashpartitioning(c_customer_sk#26, 5), true, [id=#29]

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

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

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

(45) HashAggregate [codegen id : 13]
Input [1]: [ca_state#24]
Keys [1]: [ca_state#24]
Functions [1]: [partial_count(1)]
Aggregate Attributes [1]: [count#30]
Results [2]: [ca_state#24, count#31]

(46) Exchange
Input [2]: [ca_state#24, count#31]
Arguments: hashpartitioning(ca_state#24, 5), true, [id=#32]

(47) HashAggregate [codegen id : 14]
Input [2]: [ca_state#24, count#31]
Keys [1]: [ca_state#24]
Functions [1]: [count(1)]
Aggregate Attributes [1]: [count(1)#33]
Results [4]: [ca_state#24 AS state#34, count(1)#33 AS cnt#35, count(1)#33 AS count(1)#36, ca_state#24]

(48) Filter [codegen id : 14]
Input [4]: [state#34, cnt#35, count(1)#36, ca_state#24]
Condition : (count(1)#36 >= 10)

(49) Project [codegen id : 14]
Output [3]: [state#34, cnt#35, ca_state#24]
Input [4]: [state#34, cnt#35, count(1)#36, ca_state#24]

(50) TakeOrderedAndProject
Input [3]: [state#34, cnt#35, ca_state#24]
Arguments: 100, [cnt#35 ASC NULLS FIRST, ca_state#24 ASC NULLS FIRST], [state#34, cnt#35]

===== Subqueries =====

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


(51) Scan parquet default.date_dim
Output [3]: [d_month_seq#18, d_year#37, d_moy#38]
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#18, d_year#37, d_moy#38]

(53) Filter [codegen id : 1]
Input [3]: [d_month_seq#18, d_year#37, d_moy#38]
Condition : (((isnotnull(d_year#37) AND isnotnull(d_moy#38)) AND (d_year#37 = 2000)) AND (d_moy#38 = 1))

(54) Project [codegen id : 1]
Output [1]: [d_month_seq#18]
Input [3]: [d_month_seq#18, d_year#37, d_moy#38]

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

(56) Exchange
Input [1]: [d_month_seq#18]
Arguments: hashpartitioning(d_month_seq#18, 5), true, [id=#39]

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


