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


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

(2) ColumnarToRow [codegen id : 7]
Input [2]: [ca_address_sk#1, ca_state#2]

(3) Filter [codegen id : 7]
Input [2]: [ca_address_sk#1, ca_state#2]
Condition : isnotnull(ca_address_sk#1)

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

(5) ColumnarToRow [codegen id : 1]
Input [2]: [c_customer_sk#3, c_current_addr_sk#4]

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

(7) BroadcastExchange
Input [2]: [c_customer_sk#3, c_current_addr_sk#4]
Arguments: HashedRelationBroadcastMode(List(cast(input[1, int, false] as bigint)),false), [id=#5]

(8) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [ca_address_sk#1]
Right keys [1]: [c_current_addr_sk#4]
Join condition: None

(9) Project [codegen id : 7]
Output [2]: [ca_state#2, c_customer_sk#3]
Input [4]: [ca_address_sk#1, ca_state#2, c_customer_sk#3, c_current_addr_sk#4]

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

(11) ColumnarToRow [codegen id : 2]
Input [3]: [ss_item_sk#6, ss_customer_sk#7, ss_sold_date_sk#8]

(12) Filter [codegen id : 2]
Input [3]: [ss_item_sk#6, ss_customer_sk#7, ss_sold_date_sk#8]
Condition : (isnotnull(ss_customer_sk#7) AND isnotnull(ss_item_sk#6))

(13) BroadcastExchange
Input [3]: [ss_item_sk#6, ss_customer_sk#7, ss_sold_date_sk#8]
Arguments: HashedRelationBroadcastMode(List(cast(input[1, int, false] as bigint)),false), [id=#10]

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

(15) Project [codegen id : 7]
Output [3]: [ca_state#2, ss_item_sk#6, ss_sold_date_sk#8]
Input [5]: [ca_state#2, c_customer_sk#3, ss_item_sk#6, ss_customer_sk#7, ss_sold_date_sk#8]

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

(17) ColumnarToRow [codegen id : 3]
Input [2]: [d_date_sk#11, d_month_seq#12]

(18) Filter [codegen id : 3]
Input [2]: [d_date_sk#11, d_month_seq#12]
Condition : ((isnotnull(d_month_seq#12) AND (d_month_seq#12 = Subquery scalar-subquery#13, [id=#14])) AND isnotnull(d_date_sk#11))

(19) Project [codegen id : 3]
Output [1]: [d_date_sk#11]
Input [2]: [d_date_sk#11, d_month_seq#12]

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

(21) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [ss_sold_date_sk#8]
Right keys [1]: [d_date_sk#11]
Join condition: None

(22) Project [codegen id : 7]
Output [2]: [ca_state#2, ss_item_sk#6]
Input [4]: [ca_state#2, ss_item_sk#6, ss_sold_date_sk#8, d_date_sk#11]

(23) Scan parquet default.item
Output [3]: [i_item_sk#16, i_current_price#17, i_category#18]
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>

(24) ColumnarToRow [codegen id : 6]
Input [3]: [i_item_sk#16, i_current_price#17, i_category#18]

(25) Filter [codegen id : 6]
Input [3]: [i_item_sk#16, i_current_price#17, i_category#18]
Condition : (isnotnull(i_current_price#17) AND isnotnull(i_item_sk#16))

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

(27) ColumnarToRow [codegen id : 4]
Input [2]: [i_current_price#19, i_category#20]

(28) Filter [codegen id : 4]
Input [2]: [i_current_price#19, i_category#20]
Condition : isnotnull(i_category#20)

(29) HashAggregate [codegen id : 4]
Input [2]: [i_current_price#19, i_category#20]
Keys [1]: [i_category#20]
Functions [1]: [partial_avg(UnscaledValue(i_current_price#19))]
Aggregate Attributes [2]: [sum#21, count#22]
Results [3]: [i_category#20, sum#23, count#24]

(30) Exchange
Input [3]: [i_category#20, sum#23, count#24]
Arguments: hashpartitioning(i_category#20, 5), ENSURE_REQUIREMENTS, [id=#25]

(31) HashAggregate [codegen id : 5]
Input [3]: [i_category#20, sum#23, count#24]
Keys [1]: [i_category#20]
Functions [1]: [avg(UnscaledValue(i_current_price#19))]
Aggregate Attributes [1]: [avg(UnscaledValue(i_current_price#19))#26]
Results [2]: [cast((avg(UnscaledValue(i_current_price#19))#26 / 100.0) as decimal(11,6)) AS avg(i_current_price)#27, i_category#20]

(32) BroadcastExchange
Input [2]: [avg(i_current_price)#27, i_category#20]
Arguments: HashedRelationBroadcastMode(List(input[1, string, true]),false), [id=#28]

(33) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [i_category#18]
Right keys [1]: [i_category#20]
Join condition: None

(34) Filter [codegen id : 6]
Input [5]: [i_item_sk#16, i_current_price#17, i_category#18, avg(i_current_price)#27, i_category#20]
Condition : (cast(i_current_price#17 as decimal(14,7)) > CheckOverflow((1.200000 * promote_precision(avg(i_current_price)#27)), DecimalType(14,7), true))

(35) Project [codegen id : 6]
Output [1]: [i_item_sk#16]
Input [5]: [i_item_sk#16, i_current_price#17, i_category#18, avg(i_current_price)#27, i_category#20]

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

(37) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [ss_item_sk#6]
Right keys [1]: [i_item_sk#16]
Join condition: None

(38) Project [codegen id : 7]
Output [1]: [ca_state#2]
Input [3]: [ca_state#2, ss_item_sk#6, i_item_sk#16]

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

(40) Exchange
Input [2]: [ca_state#2, count#31]
Arguments: hashpartitioning(ca_state#2, 5), ENSURE_REQUIREMENTS, [id=#32]

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

(42) Filter [codegen id : 8]
Input [3]: [state#34, cnt#35, count(1)#36]
Condition : (count(1)#36 >= 10)

(43) Project [codegen id : 8]
Output [2]: [state#34, cnt#35]
Input [3]: [state#34, cnt#35, count(1)#36]

(44) TakeOrderedAndProject
Input [2]: [state#34, cnt#35]
Arguments: 100, [cnt#35 ASC NULLS FIRST], [state#34, cnt#35]

===== Subqueries =====

Subquery:1 Hosting operator id = 10 Hosting Expression = ss_sold_date_sk#8 IN dynamicpruning#9
ReusedExchange (45)


(45) ReusedExchange [Reuses operator id: 20]
Output [1]: [d_date_sk#11]

Subquery:2 Hosting operator id = 18 Hosting Expression = Subquery scalar-subquery#13, [id=#14]
* HashAggregate (52)
+- Exchange (51)
   +- * HashAggregate (50)
      +- * Project (49)
         +- * Filter (48)
            +- * ColumnarToRow (47)
               +- Scan parquet default.date_dim (46)


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

(47) ColumnarToRow [codegen id : 1]
Input [3]: [d_month_seq#37, d_year#38, d_moy#39]

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

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

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

(51) Exchange
Input [1]: [d_month_seq#37]
Arguments: hashpartitioning(d_month_seq#37, 5), ENSURE_REQUIREMENTS, [id=#40]

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


