== Physical Plan ==
* ColumnarToRow (52)
+- CometTakeOrderedAndProject (51)
   +- CometProject (50)
      +- CometBroadcastHashJoin (49)
         :- CometProject (47)
         :  +- CometBroadcastHashJoin (46)
         :     :- CometProject (42)
         :     :  +- CometSortMergeJoin (41)
         :     :     :- CometSort (23)
         :     :     :  +- CometColumnarExchange (22)
         :     :     :     +- RowToColumnar (21)
         :     :     :        +- * Project (20)
         :     :     :           +- * Filter (19)
         :     :     :              +- Window (18)
         :     :     :                 +- WindowGroupLimit (17)
         :     :     :                    +- * ColumnarToRow (16)
         :     :     :                       +- CometSort (15)
         :     :     :                          +- CometColumnarExchange (14)
         :     :     :                             +- RowToColumnar (13)
         :     :     :                                +- WindowGroupLimit (12)
         :     :     :                                   +- * Sort (11)
         :     :     :                                      +- * Filter (10)
         :     :     :                                         +- * HashAggregate (9)
         :     :     :                                            +- * ColumnarToRow (8)
         :     :     :                                               +- CometColumnarExchange (7)
         :     :     :                                                  +- RowToColumnar (6)
         :     :     :                                                     +- * HashAggregate (5)
         :     :     :                                                        +- * ColumnarToRow (4)
         :     :     :                                                           +- CometProject (3)
         :     :     :                                                              +- CometFilter (2)
         :     :     :                                                                 +- CometScan parquet spark_catalog.default.store_sales (1)
         :     :     +- CometSort (40)
         :     :        +- CometColumnarExchange (39)
         :     :           +- RowToColumnar (38)
         :     :              +- * Project (37)
         :     :                 +- * Filter (36)
         :     :                    +- Window (35)
         :     :                       +- WindowGroupLimit (34)
         :     :                          +- * ColumnarToRow (33)
         :     :                             +- CometSort (32)
         :     :                                +- CometColumnarExchange (31)
         :     :                                   +- RowToColumnar (30)
         :     :                                      +- WindowGroupLimit (29)
         :     :                                         +- * Sort (28)
         :     :                                            +- * Filter (27)
         :     :                                               +- * HashAggregate (26)
         :     :                                                  +- * ColumnarToRow (25)
         :     :                                                     +- ReusedExchange (24)
         :     +- CometBroadcastExchange (45)
         :        +- CometFilter (44)
         :           +- CometScan parquet spark_catalog.default.item (43)
         +- ReusedExchange (48)


(1) Scan parquet spark_catalog.default.store_sales
Output [4]: [ss_item_sk#1, ss_store_sk#2, ss_net_profit#3, ss_sold_date_sk#4]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store_sales]
PushedFilters: [IsNotNull(ss_store_sk), EqualTo(ss_store_sk,4)]
ReadSchema: struct<ss_item_sk:int,ss_store_sk:int,ss_net_profit:decimal(7,2)>

(2) CometFilter
Input [4]: [ss_item_sk#1, ss_store_sk#2, ss_net_profit#3, ss_sold_date_sk#4]
Condition : (isnotnull(ss_store_sk#2) AND (ss_store_sk#2 = 4))

(3) CometProject
Input [4]: [ss_item_sk#1, ss_store_sk#2, ss_net_profit#3, ss_sold_date_sk#4]
Arguments: [ss_item_sk#1, ss_net_profit#3], [ss_item_sk#1, ss_net_profit#3]

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

(5) HashAggregate [codegen id : 1]
Input [2]: [ss_item_sk#1, ss_net_profit#3]
Keys [1]: [ss_item_sk#1]
Functions [1]: [partial_avg(UnscaledValue(ss_net_profit#3))]
Aggregate Attributes [2]: [sum#5, count#6]
Results [3]: [ss_item_sk#1, sum#7, count#8]

(6) RowToColumnar
Input [3]: [ss_item_sk#1, sum#7, count#8]

(7) CometColumnarExchange
Input [3]: [ss_item_sk#1, sum#7, count#8]
Arguments: hashpartitioning(ss_item_sk#1, 5), ENSURE_REQUIREMENTS, CometColumnarShuffle, [plan_id=1]

(8) ColumnarToRow [codegen id : 2]
Input [3]: [ss_item_sk#1, sum#7, count#8]

(9) HashAggregate [codegen id : 2]
Input [3]: [ss_item_sk#1, sum#7, count#8]
Keys [1]: [ss_item_sk#1]
Functions [1]: [avg(UnscaledValue(ss_net_profit#3))]
Aggregate Attributes [1]: [avg(UnscaledValue(ss_net_profit#3))#9]
Results [2]: [ss_item_sk#1 AS item_sk#10, cast((avg(UnscaledValue(ss_net_profit#3))#9 / 100.0) as decimal(11,6)) AS rank_col#11]

(10) Filter [codegen id : 2]
Input [2]: [item_sk#10, rank_col#11]
Condition : (isnotnull(rank_col#11) AND (cast(rank_col#11 as decimal(13,7)) > (0.9 * Subquery scalar-subquery#12, [id=#13])))

(11) Sort [codegen id : 2]
Input [2]: [item_sk#10, rank_col#11]
Arguments: [rank_col#11 ASC NULLS FIRST], false, 0

(12) WindowGroupLimit
Input [2]: [item_sk#10, rank_col#11]
Arguments: [rank_col#11 ASC NULLS FIRST], rank(rank_col#11), 10, Partial

(13) RowToColumnar
Input [2]: [item_sk#10, rank_col#11]

(14) CometColumnarExchange
Input [2]: [item_sk#10, rank_col#11]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, CometColumnarShuffle, [plan_id=2]

(15) CometSort
Input [2]: [item_sk#10, rank_col#11]
Arguments: [item_sk#10, rank_col#11], [rank_col#11 ASC NULLS FIRST]

(16) ColumnarToRow [codegen id : 3]
Input [2]: [item_sk#10, rank_col#11]

(17) WindowGroupLimit
Input [2]: [item_sk#10, rank_col#11]
Arguments: [rank_col#11 ASC NULLS FIRST], rank(rank_col#11), 10, Final

(18) Window
Input [2]: [item_sk#10, rank_col#11]
Arguments: [rank(rank_col#11) windowspecdefinition(rank_col#11 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rnk#14], [rank_col#11 ASC NULLS FIRST]

(19) Filter [codegen id : 4]
Input [3]: [item_sk#10, rank_col#11, rnk#14]
Condition : ((rnk#14 < 11) AND isnotnull(item_sk#10))

(20) Project [codegen id : 4]
Output [2]: [item_sk#10, rnk#14]
Input [3]: [item_sk#10, rank_col#11, rnk#14]

(21) RowToColumnar
Input [2]: [item_sk#10, rnk#14]

(22) CometColumnarExchange
Input [2]: [item_sk#10, rnk#14]
Arguments: hashpartitioning(rnk#14, 5), ENSURE_REQUIREMENTS, CometColumnarShuffle, [plan_id=3]

(23) CometSort
Input [2]: [item_sk#10, rnk#14]
Arguments: [item_sk#10, rnk#14], [rnk#14 ASC NULLS FIRST]

(24) ReusedExchange [Reuses operator id: 7]
Output [3]: [ss_item_sk#15, sum#16, count#17]

(25) ColumnarToRow [codegen id : 6]
Input [3]: [ss_item_sk#15, sum#16, count#17]

(26) HashAggregate [codegen id : 6]
Input [3]: [ss_item_sk#15, sum#16, count#17]
Keys [1]: [ss_item_sk#15]
Functions [1]: [avg(UnscaledValue(ss_net_profit#18))]
Aggregate Attributes [1]: [avg(UnscaledValue(ss_net_profit#18))#19]
Results [2]: [ss_item_sk#15 AS item_sk#20, cast((avg(UnscaledValue(ss_net_profit#18))#19 / 100.0) as decimal(11,6)) AS rank_col#21]

(27) Filter [codegen id : 6]
Input [2]: [item_sk#20, rank_col#21]
Condition : (isnotnull(rank_col#21) AND (cast(rank_col#21 as decimal(13,7)) > (0.9 * ReusedSubquery Subquery scalar-subquery#12, [id=#13])))

(28) Sort [codegen id : 6]
Input [2]: [item_sk#20, rank_col#21]
Arguments: [rank_col#21 DESC NULLS LAST], false, 0

(29) WindowGroupLimit
Input [2]: [item_sk#20, rank_col#21]
Arguments: [rank_col#21 DESC NULLS LAST], rank(rank_col#21), 10, Partial

(30) RowToColumnar
Input [2]: [item_sk#20, rank_col#21]

(31) CometColumnarExchange
Input [2]: [item_sk#20, rank_col#21]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, CometColumnarShuffle, [plan_id=4]

(32) CometSort
Input [2]: [item_sk#20, rank_col#21]
Arguments: [item_sk#20, rank_col#21], [rank_col#21 DESC NULLS LAST]

(33) ColumnarToRow [codegen id : 7]
Input [2]: [item_sk#20, rank_col#21]

(34) WindowGroupLimit
Input [2]: [item_sk#20, rank_col#21]
Arguments: [rank_col#21 DESC NULLS LAST], rank(rank_col#21), 10, Final

(35) Window
Input [2]: [item_sk#20, rank_col#21]
Arguments: [rank(rank_col#21) windowspecdefinition(rank_col#21 DESC NULLS LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rnk#22], [rank_col#21 DESC NULLS LAST]

(36) Filter [codegen id : 8]
Input [3]: [item_sk#20, rank_col#21, rnk#22]
Condition : ((rnk#22 < 11) AND isnotnull(item_sk#20))

(37) Project [codegen id : 8]
Output [2]: [item_sk#20, rnk#22]
Input [3]: [item_sk#20, rank_col#21, rnk#22]

(38) RowToColumnar
Input [2]: [item_sk#20, rnk#22]

(39) CometColumnarExchange
Input [2]: [item_sk#20, rnk#22]
Arguments: hashpartitioning(rnk#22, 5), ENSURE_REQUIREMENTS, CometColumnarShuffle, [plan_id=5]

(40) CometSort
Input [2]: [item_sk#20, rnk#22]
Arguments: [item_sk#20, rnk#22], [rnk#22 ASC NULLS FIRST]

(41) CometSortMergeJoin
Left output [2]: [item_sk#10, rnk#14]
Right output [2]: [item_sk#20, rnk#22]
Arguments: [rnk#14], [rnk#22], Inner

(42) CometProject
Input [4]: [item_sk#10, rnk#14, item_sk#20, rnk#22]
Arguments: [item_sk#10, rnk#14, item_sk#20], [item_sk#10, rnk#14, item_sk#20]

(43) Scan parquet spark_catalog.default.item
Output [2]: [i_item_sk#23, i_product_name#24]
Batched: true
Location [not included in comparison]/{warehouse_dir}/item]
PushedFilters: [IsNotNull(i_item_sk)]
ReadSchema: struct<i_item_sk:int,i_product_name:string>

(44) CometFilter
Input [2]: [i_item_sk#23, i_product_name#24]
Condition : isnotnull(i_item_sk#23)

(45) CometBroadcastExchange
Input [2]: [i_item_sk#23, i_product_name#24]
Arguments: [i_item_sk#23, i_product_name#24]

(46) CometBroadcastHashJoin
Left output [3]: [item_sk#10, rnk#14, item_sk#20]
Right output [2]: [i_item_sk#23, i_product_name#24]
Arguments: [item_sk#10], [i_item_sk#23], Inner, BuildRight

(47) CometProject
Input [5]: [item_sk#10, rnk#14, item_sk#20, i_item_sk#23, i_product_name#24]
Arguments: [rnk#14, item_sk#20, i_product_name#24], [rnk#14, item_sk#20, i_product_name#24]

(48) ReusedExchange [Reuses operator id: 45]
Output [2]: [i_item_sk#25, i_product_name#26]

(49) CometBroadcastHashJoin
Left output [3]: [rnk#14, item_sk#20, i_product_name#24]
Right output [2]: [i_item_sk#25, i_product_name#26]
Arguments: [item_sk#20], [i_item_sk#25], Inner, BuildRight

(50) CometProject
Input [5]: [rnk#14, item_sk#20, i_product_name#24, i_item_sk#25, i_product_name#26]
Arguments: [rnk#14, best_performing#27, worst_performing#28], [rnk#14, i_product_name#24 AS best_performing#27, i_product_name#26 AS worst_performing#28]

(51) CometTakeOrderedAndProject
Input [3]: [rnk#14, best_performing#27, worst_performing#28]
Arguments: TakeOrderedAndProject(limit=100, orderBy=[rnk#14 ASC NULLS FIRST], output=[rnk#14,best_performing#27,worst_performing#28]), [rnk#14, best_performing#27, worst_performing#28], 100, [rnk#14 ASC NULLS FIRST], [rnk#14, best_performing#27, worst_performing#28]

(52) ColumnarToRow [codegen id : 9]
Input [3]: [rnk#14, best_performing#27, worst_performing#28]

===== Subqueries =====

Subquery:1 Hosting operator id = 10 Hosting Expression = Subquery scalar-subquery#12, [id=#13]
* HashAggregate (61)
+- * ColumnarToRow (60)
   +- CometColumnarExchange (59)
      +- RowToColumnar (58)
         +- * HashAggregate (57)
            +- * ColumnarToRow (56)
               +- CometProject (55)
                  +- CometFilter (54)
                     +- CometScan parquet spark_catalog.default.store_sales (53)


(53) Scan parquet spark_catalog.default.store_sales
Output [4]: [ss_addr_sk#29, ss_store_sk#30, ss_net_profit#31, ss_sold_date_sk#32]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store_sales]
PushedFilters: [IsNotNull(ss_store_sk), EqualTo(ss_store_sk,4), IsNull(ss_addr_sk)]
ReadSchema: struct<ss_addr_sk:int,ss_store_sk:int,ss_net_profit:decimal(7,2)>

(54) CometFilter
Input [4]: [ss_addr_sk#29, ss_store_sk#30, ss_net_profit#31, ss_sold_date_sk#32]
Condition : ((isnotnull(ss_store_sk#30) AND (ss_store_sk#30 = 4)) AND isnull(ss_addr_sk#29))

(55) CometProject
Input [4]: [ss_addr_sk#29, ss_store_sk#30, ss_net_profit#31, ss_sold_date_sk#32]
Arguments: [ss_store_sk#30, ss_net_profit#31], [ss_store_sk#30, ss_net_profit#31]

(56) ColumnarToRow [codegen id : 1]
Input [2]: [ss_store_sk#30, ss_net_profit#31]

(57) HashAggregate [codegen id : 1]
Input [2]: [ss_store_sk#30, ss_net_profit#31]
Keys [1]: [ss_store_sk#30]
Functions [1]: [partial_avg(UnscaledValue(ss_net_profit#31))]
Aggregate Attributes [2]: [sum#33, count#34]
Results [3]: [ss_store_sk#30, sum#35, count#36]

(58) RowToColumnar
Input [3]: [ss_store_sk#30, sum#35, count#36]

(59) CometColumnarExchange
Input [3]: [ss_store_sk#30, sum#35, count#36]
Arguments: hashpartitioning(ss_store_sk#30, 5), ENSURE_REQUIREMENTS, CometColumnarShuffle, [plan_id=6]

(60) ColumnarToRow [codegen id : 2]
Input [3]: [ss_store_sk#30, sum#35, count#36]

(61) HashAggregate [codegen id : 2]
Input [3]: [ss_store_sk#30, sum#35, count#36]
Keys [1]: [ss_store_sk#30]
Functions [1]: [avg(UnscaledValue(ss_net_profit#31))]
Aggregate Attributes [1]: [avg(UnscaledValue(ss_net_profit#31))#37]
Results [1]: [cast((avg(UnscaledValue(ss_net_profit#31))#37 / 100.0) as decimal(11,6)) AS rank_col#38]

Subquery:2 Hosting operator id = 27 Hosting Expression = ReusedSubquery Subquery scalar-subquery#12, [id=#13]


