== 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, [plan_id=1]

(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))#9]
Results [3]: [ss_store_sk#2, ss_item_sk#1, MakeDecimal(sum(UnscaledValue(ss_sales_price#3))#9,17,2) AS revenue#10]

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

(11) Scan parquet default.store_sales
Output [4]: [ss_item_sk#11, ss_store_sk#12, ss_sales_price#13, ss_sold_date_sk#14]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#14), dynamicpruningexpression(ss_sold_date_sk#14 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#11, ss_store_sk#12, ss_sales_price#13, ss_sold_date_sk#14]

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

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

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

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

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

(18) Exchange
Input [3]: [ss_store_sk#12, ss_item_sk#11, sum#17]
Arguments: hashpartitioning(ss_store_sk#12, ss_item_sk#11, 5), ENSURE_REQUIREMENTS, [plan_id=2]

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

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

(21) Exchange
Input [3]: [ss_store_sk#12, sum#22, count#23]
Arguments: hashpartitioning(ss_store_sk#12, 5), ENSURE_REQUIREMENTS, [plan_id=3]

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

(23) BroadcastExchange
Input [2]: [ss_store_sk#12, ave#25]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=4]

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

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

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

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

(29) BroadcastExchange
Input [2]: [s_store_sk#26, s_store_name#27]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=5]

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

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

(32) Exchange
Input [3]: [ss_item_sk#1, revenue#10, s_store_name#27]
Arguments: hashpartitioning(ss_item_sk#1, 5), ENSURE_REQUIREMENTS, [plan_id=6]

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

(34) Scan parquet default.item
Output [5]: [i_item_sk#28, i_item_desc#29, i_current_price#30, i_wholesale_cost#31, i_brand#32]
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#28, i_item_desc#29, i_current_price#30, i_wholesale_cost#31, i_brand#32]

(36) Filter [codegen id : 10]
Input [5]: [i_item_sk#28, i_item_desc#29, i_current_price#30, i_wholesale_cost#31, i_brand#32]
Condition : isnotnull(i_item_sk#28)

(37) Exchange
Input [5]: [i_item_sk#28, i_item_desc#29, i_current_price#30, i_wholesale_cost#31, i_brand#32]
Arguments: hashpartitioning(i_item_sk#28, 5), ENSURE_REQUIREMENTS, [plan_id=7]

(38) Sort [codegen id : 11]
Input [5]: [i_item_sk#28, i_item_desc#29, i_current_price#30, i_wholesale_cost#31, i_brand#32]
Arguments: [i_item_sk#28 ASC NULLS FIRST], false, 0

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

(40) Project [codegen id : 12]
Output [6]: [s_store_name#27, i_item_desc#29, revenue#10, i_current_price#30, i_wholesale_cost#31, i_brand#32]
Input [8]: [ss_item_sk#1, revenue#10, s_store_name#27, i_item_sk#28, i_item_desc#29, i_current_price#30, i_wholesale_cost#31, i_brand#32]

(41) TakeOrderedAndProject
Input [6]: [s_store_name#27, i_item_desc#29, revenue#10, i_current_price#30, i_wholesale_cost#31, i_brand#32]
Arguments: 100, [s_store_name#27 ASC NULLS FIRST, i_item_desc#29 ASC NULLS FIRST], [s_store_name#27, i_item_desc#29, revenue#10, i_current_price#30, i_wholesale_cost#31, i_brand#32]

===== 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#33]
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#33]

(44) Filter [codegen id : 1]
Input [2]: [d_date_sk#6, d_month_seq#33]
Condition : (((isnotnull(d_month_seq#33) AND (d_month_seq#33 >= 1176)) AND (d_month_seq#33 <= 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#33]

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

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


