== Physical Plan ==
TakeOrderedAndProject (39)
+- * Project (38)
   +- * BroadcastHashJoin Inner BuildLeft (37)
      :- BroadcastExchange (33)
      :  +- * Project (32)
      :     +- * BroadcastHashJoin Inner BuildLeft (31)
      :        :- BroadcastExchange (27)
      :        :  +- * Project (26)
      :        :     +- * BroadcastHashJoin Inner BuildRight (25)
      :        :        :- * Filter (10)
      :        :        :  +- * HashAggregate (9)
      :        :        :     +- Exchange (8)
      :        :        :        +- * HashAggregate (7)
      :        :        :           +- * Project (6)
      :        :        :              +- * BroadcastHashJoin Inner BuildRight (5)
      :        :        :                 :- * Filter (3)
      :        :        :                 :  +- * ColumnarToRow (2)
      :        :        :                 :     +- Scan parquet spark_catalog.default.store_sales (1)
      :        :        :                 +- ReusedExchange (4)
      :        :        +- BroadcastExchange (24)
      :        :           +- * Filter (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 spark_catalog.default.store_sales (11)
      :        :                                      +- ReusedExchange (14)
      :        +- * Filter (30)
      :           +- * ColumnarToRow (29)
      :              +- Scan parquet spark_catalog.default.store (28)
      +- * Filter (36)
         +- * ColumnarToRow (35)
            +- Scan parquet spark_catalog.default.item (34)


(1) Scan parquet spark_catalog.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), (ss_sold_date_sk#4 >= 2451911), (ss_sold_date_sk#4 <= 2452275), 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: 44]
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 type: Inner
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 : 7]
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 : 7]
Input [3]: [ss_store_sk#2, ss_item_sk#1, revenue#10]
Condition : isnotnull(revenue#10)

(11) Scan parquet spark_catalog.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), (ss_sold_date_sk#14 >= 2451911), (ss_sold_date_sk#14 <= 2452275), 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: 44]
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 type: Inner
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) Filter [codegen id : 6]
Input [2]: [ss_store_sk#12, ave#25]
Condition : isnotnull(ave#25)

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

(25) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [ss_store_sk#2]
Right keys [1]: [ss_store_sk#12]
Join type: Inner
Join condition: (cast(revenue#10 as decimal(23,7)) <= (0.1 * ave#25))

(26) Project [codegen id : 7]
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]

(27) BroadcastExchange
Input [3]: [ss_store_sk#2, ss_item_sk#1, revenue#10]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=5]

(28) Scan parquet spark_catalog.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>

(29) ColumnarToRow
Input [2]: [s_store_sk#26, s_store_name#27]

(30) Filter
Input [2]: [s_store_sk#26, s_store_name#27]
Condition : isnotnull(s_store_sk#26)

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

(32) 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]

(33) BroadcastExchange
Input [3]: [ss_item_sk#1, revenue#10, s_store_name#27]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=6]

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

(36) Filter
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) BroadcastHashJoin [codegen id : 9]
Left keys [1]: [ss_item_sk#1]
Right keys [1]: [i_item_sk#28]
Join type: Inner
Join condition: None

(38) Project [codegen id : 9]
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]

(39) 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 (44)
+- * Project (43)
   +- * Filter (42)
      +- * ColumnarToRow (41)
         +- Scan parquet spark_catalog.default.date_dim (40)


(40) Scan parquet spark_catalog.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,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>

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

(42) 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 >= 1212)) AND (d_month_seq#33 <= 1223)) AND (d_date_sk#6 >= 2451911)) AND (d_date_sk#6 <= 2452275)) AND isnotnull(d_date_sk#6))

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

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

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


