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


(1) Scan parquet spark_catalog.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) CometFilter
Input [2]: [s_store_sk#1, s_store_name#2]
Condition : isnotnull(s_store_sk#1)

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

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

(6) Scan parquet spark_catalog.default.date_dim
Output [2]: [d_date_sk#8, d_month_seq#9]
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>

(7) CometFilter
Input [2]: [d_date_sk#8, d_month_seq#9]
Condition : (((isnotnull(d_month_seq#9) AND (d_month_seq#9 >= 1176)) AND (d_month_seq#9 <= 1187)) AND isnotnull(d_date_sk#8))

(8) CometProject
Input [2]: [d_date_sk#8, d_month_seq#9]
Arguments: [d_date_sk#8], [d_date_sk#8]

(9) CometBroadcastExchange
Input [1]: [d_date_sk#8]
Arguments: [d_date_sk#8]

(10) CometBroadcastHashJoin
Left output [4]: [ss_item_sk#3, ss_store_sk#4, ss_sales_price#5, ss_sold_date_sk#6]
Right output [1]: [d_date_sk#8]
Arguments: [ss_sold_date_sk#6], [d_date_sk#8], Inner, BuildRight

(11) CometProject
Input [5]: [ss_item_sk#3, ss_store_sk#4, ss_sales_price#5, ss_sold_date_sk#6, d_date_sk#8]
Arguments: [ss_item_sk#3, ss_store_sk#4, ss_sales_price#5], [ss_item_sk#3, ss_store_sk#4, ss_sales_price#5]

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

(13) HashAggregate [codegen id : 1]
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#10]
Results [3]: [ss_store_sk#4, ss_item_sk#3, sum#11]

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

(15) HashAggregate [codegen id : 2]
Input [3]: [ss_store_sk#4, ss_item_sk#3, sum#11]
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]

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

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

(18) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [s_store_sk#1]
Right keys [1]: [ss_store_sk#4]
Join type: Inner
Join condition: None

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

(20) Scan parquet spark_catalog.default.item
Output [5]: [i_item_sk#14, i_item_desc#15, i_current_price#16, i_wholesale_cost#17, i_brand#18]
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>

(21) CometFilter
Input [5]: [i_item_sk#14, i_item_desc#15, i_current_price#16, i_wholesale_cost#17, i_brand#18]
Condition : isnotnull(i_item_sk#14)

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

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

(24) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [ss_item_sk#3]
Right keys [1]: [i_item_sk#14]
Join type: Inner
Join condition: None

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

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

(27) CometFilter
Input [4]: [ss_item_sk#19, ss_store_sk#20, ss_sales_price#21, ss_sold_date_sk#22]
Condition : isnotnull(ss_store_sk#20)

(28) ReusedExchange [Reuses operator id: 9]
Output [1]: [d_date_sk#24]

(29) CometBroadcastHashJoin
Left output [4]: [ss_item_sk#19, ss_store_sk#20, ss_sales_price#21, ss_sold_date_sk#22]
Right output [1]: [d_date_sk#24]
Arguments: [ss_sold_date_sk#22], [d_date_sk#24], Inner, BuildRight

(30) CometProject
Input [5]: [ss_item_sk#19, ss_store_sk#20, ss_sales_price#21, ss_sold_date_sk#22, d_date_sk#24]
Arguments: [ss_item_sk#19, ss_store_sk#20, ss_sales_price#21], [ss_item_sk#19, ss_store_sk#20, ss_sales_price#21]

(31) ColumnarToRow [codegen id : 4]
Input [3]: [ss_item_sk#19, ss_store_sk#20, ss_sales_price#21]

(32) HashAggregate [codegen id : 4]
Input [3]: [ss_item_sk#19, ss_store_sk#20, ss_sales_price#21]
Keys [2]: [ss_store_sk#20, ss_item_sk#19]
Functions [1]: [partial_sum(UnscaledValue(ss_sales_price#21))]
Aggregate Attributes [1]: [sum#25]
Results [3]: [ss_store_sk#20, ss_item_sk#19, sum#26]

(33) Exchange
Input [3]: [ss_store_sk#20, ss_item_sk#19, sum#26]
Arguments: hashpartitioning(ss_store_sk#20, ss_item_sk#19, 5), ENSURE_REQUIREMENTS, [plan_id=4]

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

(35) HashAggregate [codegen id : 5]
Input [2]: [ss_store_sk#20, revenue#28]
Keys [1]: [ss_store_sk#20]
Functions [1]: [partial_avg(revenue#28)]
Aggregate Attributes [2]: [sum#29, count#30]
Results [3]: [ss_store_sk#20, sum#31, count#32]

(36) Exchange
Input [3]: [ss_store_sk#20, sum#31, count#32]
Arguments: hashpartitioning(ss_store_sk#20, 5), ENSURE_REQUIREMENTS, [plan_id=5]

(37) HashAggregate [codegen id : 6]
Input [3]: [ss_store_sk#20, sum#31, count#32]
Keys [1]: [ss_store_sk#20]
Functions [1]: [avg(revenue#28)]
Aggregate Attributes [1]: [avg(revenue#28)#33]
Results [2]: [ss_store_sk#20, avg(revenue#28)#33 AS ave#34]

(38) Filter [codegen id : 6]
Input [2]: [ss_store_sk#20, ave#34]
Condition : isnotnull(ave#34)

(39) BroadcastExchange
Input [2]: [ss_store_sk#20, ave#34]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=6]

(40) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [ss_store_sk#4]
Right keys [1]: [ss_store_sk#20]
Join type: Inner
Join condition: (cast(revenue#13 as decimal(23,7)) <= (0.1 * ave#34))

(41) Project [codegen id : 7]
Output [6]: [s_store_name#2, i_item_desc#15, revenue#13, i_current_price#16, i_wholesale_cost#17, i_brand#18]
Input [9]: [s_store_name#2, ss_store_sk#4, revenue#13, i_item_desc#15, i_current_price#16, i_wholesale_cost#17, i_brand#18, ss_store_sk#20, ave#34]

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

===== Subqueries =====

Subquery:1 Hosting operator id = 4 Hosting Expression = ss_sold_date_sk#6 IN dynamicpruning#7
BroadcastExchange (47)
+- * ColumnarToRow (46)
   +- CometProject (45)
      +- CometFilter (44)
         +- CometScan parquet spark_catalog.default.date_dim (43)


(43) Scan parquet spark_catalog.default.date_dim
Output [2]: [d_date_sk#8, d_month_seq#9]
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>

(44) CometFilter
Input [2]: [d_date_sk#8, d_month_seq#9]
Condition : (((isnotnull(d_month_seq#9) AND (d_month_seq#9 >= 1176)) AND (d_month_seq#9 <= 1187)) AND isnotnull(d_date_sk#8))

(45) CometProject
Input [2]: [d_date_sk#8, d_month_seq#9]
Arguments: [d_date_sk#8], [d_date_sk#8]

(46) ColumnarToRow [codegen id : 1]
Input [1]: [d_date_sk#8]

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

Subquery:2 Hosting operator id = 26 Hosting Expression = ss_sold_date_sk#22 IN dynamicpruning#7


