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


(1) Scan parquet default.store_sales
Output [4]: [ss_item_sk#1, ss_store_sk#2, ss_sales_price#3, ss_sold_date_sk#4]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#4), dynamicpruningexpression(ss_sold_date_sk#4 IN dynamicpruning#5)]
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)>

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

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

(4) ReusedExchange [Reuses operator id: 46]
Output [1]: [d_date_sk#6]

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

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

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

(8) Exchange
Input [3]: [ss_store_sk#2, ss_item_sk#1, sum#8]
Arguments: hashpartitioning(ss_store_sk#2, ss_item_sk#1, 5), ENSURE_REQUIREMENTS, [id=#9]

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

(10) Filter [codegen id : 8]
Input [3]: [ss_store_sk#2, ss_item_sk#1, revenue#11]
Condition : isnotnull(revenue#11)

(11) Scan parquet default.store_sales
Output [4]: [ss_item_sk#12, ss_store_sk#13, ss_sales_price#14, ss_sold_date_sk#15]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#15), dynamicpruningexpression(ss_sold_date_sk#15 IN dynamicpruning#5)]
PushedFilters: [IsNotNull(ss_store_sk)]
ReadSchema: struct<ss_item_sk:int,ss_store_sk:int,ss_sales_price:decimal(7,2)>

(12) ColumnarToRow [codegen id : 4]
Input [4]: [ss_item_sk#12, ss_store_sk#13, ss_sales_price#14, ss_sold_date_sk#15]

(13) Filter [codegen id : 4]
Input [4]: [ss_item_sk#12, ss_store_sk#13, ss_sales_price#14, ss_sold_date_sk#15]
Condition : isnotnull(ss_store_sk#13)

(14) ReusedExchange [Reuses operator id: 46]
Output [1]: [d_date_sk#16]

(15) BroadcastHashJoin [codegen id : 4]
Left keys [1]: [ss_sold_date_sk#15]
Right keys [1]: [d_date_sk#16]
Join condition: None

(16) Project [codegen id : 4]
Output [3]: [ss_item_sk#12, ss_store_sk#13, ss_sales_price#14]
Input [5]: [ss_item_sk#12, ss_store_sk#13, ss_sales_price#14, ss_sold_date_sk#15, d_date_sk#16]

(17) HashAggregate [codegen id : 4]
Input [3]: [ss_item_sk#12, ss_store_sk#13, ss_sales_price#14]
Keys [2]: [ss_store_sk#13, ss_item_sk#12]
Functions [1]: [partial_sum(UnscaledValue(ss_sales_price#14))]
Aggregate Attributes [1]: [sum#17]
Results [3]: [ss_store_sk#13, ss_item_sk#12, sum#18]

(18) Exchange
Input [3]: [ss_store_sk#13, ss_item_sk#12, sum#18]
Arguments: hashpartitioning(ss_store_sk#13, ss_item_sk#12, 5), ENSURE_REQUIREMENTS, [id=#19]

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

(20) HashAggregate [codegen id : 5]
Input [2]: [ss_store_sk#13, revenue#21]
Keys [1]: [ss_store_sk#13]
Functions [1]: [partial_avg(revenue#21)]
Aggregate Attributes [2]: [sum#22, count#23]
Results [3]: [ss_store_sk#13, sum#24, count#25]

(21) Exchange
Input [3]: [ss_store_sk#13, sum#24, count#25]
Arguments: hashpartitioning(ss_store_sk#13, 5), ENSURE_REQUIREMENTS, [id=#26]

(22) HashAggregate [codegen id : 6]
Input [3]: [ss_store_sk#13, sum#24, count#25]
Keys [1]: [ss_store_sk#13]
Functions [1]: [avg(revenue#21)]
Aggregate Attributes [1]: [avg(revenue#21)#27]
Results [2]: [ss_store_sk#13, avg(revenue#21)#27 AS ave#28]

(23) BroadcastExchange
Input [2]: [ss_store_sk#13, ave#28]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#29]

(24) BroadcastHashJoin [codegen id : 8]
Left keys [1]: [ss_store_sk#2]
Right keys [1]: [ss_store_sk#13]
Join condition: (cast(revenue#11 as decimal(23,7)) <= CheckOverflow((0.100000 * promote_precision(ave#28)), DecimalType(23,7)))

(25) Project [codegen id : 8]
Output [3]: [ss_store_sk#2, ss_item_sk#1, revenue#11]
Input [5]: [ss_store_sk#2, ss_item_sk#1, revenue#11, ss_store_sk#13, ave#28]

(26) Scan parquet default.store
Output [2]: [s_store_sk#30, s_store_name#31]
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>

(27) ColumnarToRow [codegen id : 7]
Input [2]: [s_store_sk#30, s_store_name#31]

(28) Filter [codegen id : 7]
Input [2]: [s_store_sk#30, s_store_name#31]
Condition : isnotnull(s_store_sk#30)

(29) BroadcastExchange
Input [2]: [s_store_sk#30, s_store_name#31]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#32]

(30) BroadcastHashJoin [codegen id : 8]
Left keys [1]: [ss_store_sk#2]
Right keys [1]: [s_store_sk#30]
Join condition: None

(31) Project [codegen id : 8]
Output [3]: [ss_item_sk#1, revenue#11, s_store_name#31]
Input [5]: [ss_store_sk#2, ss_item_sk#1, revenue#11, s_store_sk#30, s_store_name#31]

(32) Exchange
Input [3]: [ss_item_sk#1, revenue#11, s_store_name#31]
Arguments: hashpartitioning(ss_item_sk#1, 5), ENSURE_REQUIREMENTS, [id=#33]

(33) Sort [codegen id : 9]
Input [3]: [ss_item_sk#1, revenue#11, s_store_name#31]
Arguments: [ss_item_sk#1 ASC NULLS FIRST], false, 0

(34) Scan parquet default.item
Output [5]: [i_item_sk#34, i_item_desc#35, i_current_price#36, i_wholesale_cost#37, i_brand#38]
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>

(35) ColumnarToRow [codegen id : 10]
Input [5]: [i_item_sk#34, i_item_desc#35, i_current_price#36, i_wholesale_cost#37, i_brand#38]

(36) Filter [codegen id : 10]
Input [5]: [i_item_sk#34, i_item_desc#35, i_current_price#36, i_wholesale_cost#37, i_brand#38]
Condition : isnotnull(i_item_sk#34)

(37) Exchange
Input [5]: [i_item_sk#34, i_item_desc#35, i_current_price#36, i_wholesale_cost#37, i_brand#38]
Arguments: hashpartitioning(i_item_sk#34, 5), ENSURE_REQUIREMENTS, [id=#39]

(38) Sort [codegen id : 11]
Input [5]: [i_item_sk#34, i_item_desc#35, i_current_price#36, i_wholesale_cost#37, i_brand#38]
Arguments: [i_item_sk#34 ASC NULLS FIRST], false, 0

(39) SortMergeJoin [codegen id : 12]
Left keys [1]: [ss_item_sk#1]
Right keys [1]: [i_item_sk#34]
Join condition: None

(40) Project [codegen id : 12]
Output [6]: [s_store_name#31, i_item_desc#35, revenue#11, i_current_price#36, i_wholesale_cost#37, i_brand#38]
Input [8]: [ss_item_sk#1, revenue#11, s_store_name#31, i_item_sk#34, i_item_desc#35, i_current_price#36, i_wholesale_cost#37, i_brand#38]

(41) TakeOrderedAndProject
Input [6]: [s_store_name#31, i_item_desc#35, revenue#11, i_current_price#36, i_wholesale_cost#37, i_brand#38]
Arguments: 100, [s_store_name#31 ASC NULLS FIRST, i_item_desc#35 ASC NULLS FIRST], [s_store_name#31, i_item_desc#35, revenue#11, i_current_price#36, i_wholesale_cost#37, i_brand#38]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ss_sold_date_sk#4 IN dynamicpruning#5
BroadcastExchange (46)
+- * Project (45)
   +- * Filter (44)
      +- * ColumnarToRow (43)
         +- Scan parquet default.date_dim (42)


(42) Scan parquet default.date_dim
Output [2]: [d_date_sk#6, d_month_seq#40]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_month_seq), GreaterThanOrEqual(d_month_seq,1176), LessThanOrEqual(d_month_seq,1187), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_month_seq:int>

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

(44) Filter [codegen id : 1]
Input [2]: [d_date_sk#6, d_month_seq#40]
Condition : (((isnotnull(d_month_seq#40) AND (d_month_seq#40 >= 1176)) AND (d_month_seq#40 <= 1187)) AND isnotnull(d_date_sk#6))

(45) Project [codegen id : 1]
Output [1]: [d_date_sk#6]
Input [2]: [d_date_sk#6, d_month_seq#40]

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

Subquery:2 Hosting operator id = 11 Hosting Expression = ss_sold_date_sk#15 IN dynamicpruning#5


