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


(1) Scan parquet default.store
Output [2]: [s_store_sk#1, s_store_name#2]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store]
PushedFilters: [IsNotNull(s_store_sk)]
ReadSchema: struct<s_store_sk:int,s_store_name:string>

(2) ColumnarToRow [codegen id : 9]
Input [2]: [s_store_sk#1, s_store_name#2]

(3) Filter [codegen id : 9]
Input [2]: [s_store_sk#1, s_store_name#2]
Condition : isnotnull(s_store_sk#1)

(4) Scan parquet default.store_sales
Output [4]: [ss_item_sk#3, ss_store_sk#4, ss_sales_price#5, ss_sold_date_sk#6]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#6), (ss_sold_date_sk#6 >= 2451911), (ss_sold_date_sk#6 <= 2452275), dynamicpruningexpression(ss_sold_date_sk#6 IN dynamicpruning#7)]
PushedFilters: [IsNotNull(ss_store_sk), IsNotNull(ss_item_sk)]
ReadSchema: struct<ss_item_sk:int,ss_store_sk:int,ss_sales_price:decimal(7,2)>

(5) ColumnarToRow [codegen id : 2]
Input [4]: [ss_item_sk#3, ss_store_sk#4, ss_sales_price#5, ss_sold_date_sk#6]

(6) Filter [codegen id : 2]
Input [4]: [ss_item_sk#3, ss_store_sk#4, ss_sales_price#5, ss_sold_date_sk#6]
Condition : (isnotnull(ss_store_sk#4) AND isnotnull(ss_item_sk#3))

(7) ReusedExchange [Reuses operator id: 43]
Output [1]: [d_date_sk#8]

(8) BroadcastHashJoin [codegen id : 2]
Left keys [1]: [ss_sold_date_sk#6]
Right keys [1]: [d_date_sk#8]
Join condition: None

(9) Project [codegen id : 2]
Output [3]: [ss_item_sk#3, ss_store_sk#4, ss_sales_price#5]
Input [5]: [ss_item_sk#3, ss_store_sk#4, ss_sales_price#5, ss_sold_date_sk#6, d_date_sk#8]

(10) HashAggregate [codegen id : 2]
Input [3]: [ss_item_sk#3, ss_store_sk#4, ss_sales_price#5]
Keys [2]: [ss_store_sk#4, ss_item_sk#3]
Functions [1]: [partial_sum(UnscaledValue(ss_sales_price#5))]
Aggregate Attributes [1]: [sum#9]
Results [3]: [ss_store_sk#4, ss_item_sk#3, sum#10]

(11) Exchange
Input [3]: [ss_store_sk#4, ss_item_sk#3, sum#10]
Arguments: hashpartitioning(ss_store_sk#4, ss_item_sk#3, 5), ENSURE_REQUIREMENTS, [id=#11]

(12) HashAggregate [codegen id : 3]
Input [3]: [ss_store_sk#4, ss_item_sk#3, sum#10]
Keys [2]: [ss_store_sk#4, ss_item_sk#3]
Functions [1]: [sum(UnscaledValue(ss_sales_price#5))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_sales_price#5))#12]
Results [3]: [ss_store_sk#4, ss_item_sk#3, MakeDecimal(sum(UnscaledValue(ss_sales_price#5))#12,17,2) AS revenue#13]

(13) Filter [codegen id : 3]
Input [3]: [ss_store_sk#4, ss_item_sk#3, revenue#13]
Condition : isnotnull(revenue#13)

(14) BroadcastExchange
Input [3]: [ss_store_sk#4, ss_item_sk#3, revenue#13]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#14]

(15) BroadcastHashJoin [codegen id : 9]
Left keys [1]: [s_store_sk#1]
Right keys [1]: [ss_store_sk#4]
Join condition: None

(16) Project [codegen id : 9]
Output [4]: [s_store_name#2, ss_store_sk#4, ss_item_sk#3, revenue#13]
Input [5]: [s_store_sk#1, s_store_name#2, ss_store_sk#4, ss_item_sk#3, revenue#13]

(17) Scan parquet default.item
Output [5]: [i_item_sk#15, i_item_desc#16, i_current_price#17, i_wholesale_cost#18, i_brand#19]
Batched: true
Location [not included in comparison]/{warehouse_dir}/item]
PushedFilters: [IsNotNull(i_item_sk)]
ReadSchema: struct<i_item_sk:int,i_item_desc:string,i_current_price:decimal(7,2),i_wholesale_cost:decimal(7,2),i_brand:string>

(18) ColumnarToRow [codegen id : 4]
Input [5]: [i_item_sk#15, i_item_desc#16, i_current_price#17, i_wholesale_cost#18, i_brand#19]

(19) Filter [codegen id : 4]
Input [5]: [i_item_sk#15, i_item_desc#16, i_current_price#17, i_wholesale_cost#18, i_brand#19]
Condition : isnotnull(i_item_sk#15)

(20) BroadcastExchange
Input [5]: [i_item_sk#15, i_item_desc#16, i_current_price#17, i_wholesale_cost#18, i_brand#19]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#20]

(21) BroadcastHashJoin [codegen id : 9]
Left keys [1]: [ss_item_sk#3]
Right keys [1]: [i_item_sk#15]
Join condition: None

(22) Project [codegen id : 9]
Output [7]: [s_store_name#2, ss_store_sk#4, revenue#13, i_item_desc#16, i_current_price#17, i_wholesale_cost#18, i_brand#19]
Input [9]: [s_store_name#2, ss_store_sk#4, ss_item_sk#3, revenue#13, i_item_sk#15, i_item_desc#16, i_current_price#17, i_wholesale_cost#18, i_brand#19]

(23) Scan parquet default.store_sales
Output [4]: [ss_item_sk#21, ss_store_sk#22, ss_sales_price#23, ss_sold_date_sk#24]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#24), (ss_sold_date_sk#24 >= 2451911), (ss_sold_date_sk#24 <= 2452275), dynamicpruningexpression(ss_sold_date_sk#24 IN dynamicpruning#7)]
PushedFilters: [IsNotNull(ss_store_sk)]
ReadSchema: struct<ss_item_sk:int,ss_store_sk:int,ss_sales_price:decimal(7,2)>

(24) ColumnarToRow [codegen id : 6]
Input [4]: [ss_item_sk#21, ss_store_sk#22, ss_sales_price#23, ss_sold_date_sk#24]

(25) Filter [codegen id : 6]
Input [4]: [ss_item_sk#21, ss_store_sk#22, ss_sales_price#23, ss_sold_date_sk#24]
Condition : isnotnull(ss_store_sk#22)

(26) ReusedExchange [Reuses operator id: 43]
Output [1]: [d_date_sk#25]

(27) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [ss_sold_date_sk#24]
Right keys [1]: [d_date_sk#25]
Join condition: None

(28) Project [codegen id : 6]
Output [3]: [ss_item_sk#21, ss_store_sk#22, ss_sales_price#23]
Input [5]: [ss_item_sk#21, ss_store_sk#22, ss_sales_price#23, ss_sold_date_sk#24, d_date_sk#25]

(29) HashAggregate [codegen id : 6]
Input [3]: [ss_item_sk#21, ss_store_sk#22, ss_sales_price#23]
Keys [2]: [ss_store_sk#22, ss_item_sk#21]
Functions [1]: [partial_sum(UnscaledValue(ss_sales_price#23))]
Aggregate Attributes [1]: [sum#26]
Results [3]: [ss_store_sk#22, ss_item_sk#21, sum#27]

(30) Exchange
Input [3]: [ss_store_sk#22, ss_item_sk#21, sum#27]
Arguments: hashpartitioning(ss_store_sk#22, ss_item_sk#21, 5), ENSURE_REQUIREMENTS, [id=#28]

(31) HashAggregate [codegen id : 7]
Input [3]: [ss_store_sk#22, ss_item_sk#21, sum#27]
Keys [2]: [ss_store_sk#22, ss_item_sk#21]
Functions [1]: [sum(UnscaledValue(ss_sales_price#23))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_sales_price#23))#29]
Results [2]: [ss_store_sk#22, MakeDecimal(sum(UnscaledValue(ss_sales_price#23))#29,17,2) AS revenue#30]

(32) HashAggregate [codegen id : 7]
Input [2]: [ss_store_sk#22, revenue#30]
Keys [1]: [ss_store_sk#22]
Functions [1]: [partial_avg(revenue#30)]
Aggregate Attributes [2]: [sum#31, count#32]
Results [3]: [ss_store_sk#22, sum#33, count#34]

(33) Exchange
Input [3]: [ss_store_sk#22, sum#33, count#34]
Arguments: hashpartitioning(ss_store_sk#22, 5), ENSURE_REQUIREMENTS, [id=#35]

(34) HashAggregate [codegen id : 8]
Input [3]: [ss_store_sk#22, sum#33, count#34]
Keys [1]: [ss_store_sk#22]
Functions [1]: [avg(revenue#30)]
Aggregate Attributes [1]: [avg(revenue#30)#36]
Results [2]: [ss_store_sk#22, avg(revenue#30)#36 AS ave#37]

(35) BroadcastExchange
Input [2]: [ss_store_sk#22, ave#37]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#38]

(36) BroadcastHashJoin [codegen id : 9]
Left keys [1]: [ss_store_sk#4]
Right keys [1]: [ss_store_sk#22]
Join condition: (cast(revenue#13 as decimal(23,7)) <= CheckOverflow((0.100000 * promote_precision(ave#37)), DecimalType(23,7), true))

(37) Project [codegen id : 9]
Output [6]: [s_store_name#2, i_item_desc#16, revenue#13, i_current_price#17, i_wholesale_cost#18, i_brand#19]
Input [9]: [s_store_name#2, ss_store_sk#4, revenue#13, i_item_desc#16, i_current_price#17, i_wholesale_cost#18, i_brand#19, ss_store_sk#22, ave#37]

(38) TakeOrderedAndProject
Input [6]: [s_store_name#2, i_item_desc#16, revenue#13, i_current_price#17, i_wholesale_cost#18, i_brand#19]
Arguments: 100, [s_store_name#2 ASC NULLS FIRST, i_item_desc#16 ASC NULLS FIRST], [s_store_name#2, i_item_desc#16, revenue#13, i_current_price#17, i_wholesale_cost#18, i_brand#19]

===== Subqueries =====

Subquery:1 Hosting operator id = 4 Hosting Expression = ss_sold_date_sk#6 IN dynamicpruning#7
BroadcastExchange (43)
+- * Project (42)
   +- * Filter (41)
      +- * ColumnarToRow (40)
         +- Scan parquet default.date_dim (39)


(39) Scan parquet default.date_dim
Output [2]: [d_date_sk#8, d_month_seq#39]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_month_seq), GreaterThanOrEqual(d_month_seq,1212), LessThanOrEqual(d_month_seq,1223), GreaterThanOrEqual(d_date_sk,2451911), LessThanOrEqual(d_date_sk,2452275), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_month_seq:int>

(40) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#8, d_month_seq#39]

(41) Filter [codegen id : 1]
Input [2]: [d_date_sk#8, d_month_seq#39]
Condition : (((((isnotnull(d_month_seq#39) AND (d_month_seq#39 >= 1212)) AND (d_month_seq#39 <= 1223)) AND (d_date_sk#8 >= 2451911)) AND (d_date_sk#8 <= 2452275)) AND isnotnull(d_date_sk#8))

(42) Project [codegen id : 1]
Output [1]: [d_date_sk#8]
Input [2]: [d_date_sk#8, d_month_seq#39]

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

Subquery:2 Hosting operator id = 23 Hosting Expression = ss_sold_date_sk#24 IN dynamicpruning#7


