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


(1) CometScan 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) CometColumnarToRow [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) CometColumnarExchange
Input [3]: [ss_item_sk#1, sum#7, count#8]
Arguments: hashpartitioning(ss_item_sk#1, 5), ENSURE_REQUIREMENTS, CometColumnarShuffle, [plan_id=1]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(38) CometScan 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>

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

(40) CometProject
Input [2]: [i_item_sk#23, i_product_name#24]
Arguments: [i_item_sk#23, i_product_name#25], [i_item_sk#23, staticinvoke(class org.apache.spark.sql.catalyst.util.CharVarcharCodegenUtils, StringType, readSidePadding, i_product_name#24, 50, true, false, true) AS i_product_name#25]

(41) CometBroadcastExchange
Input [2]: [i_item_sk#23, i_product_name#25]
Arguments: [i_item_sk#23, i_product_name#25]

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

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

(44) ReusedExchange [Reuses operator id: 41]
Output [2]: [i_item_sk#26, i_product_name#27]

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

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

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

(48) CometColumnarToRow [codegen id : 9]
Input [3]: [rnk#14, best_performing#28, worst_performing#29]

===== Subqueries =====

Subquery:1 Hosting operator id = 9 Hosting Expression = Subquery scalar-subquery#12, [id=#13]
* HashAggregate (56)
+- * CometColumnarToRow (55)
   +- CometColumnarExchange (54)
      +- * HashAggregate (53)
         +- * CometColumnarToRow (52)
            +- CometProject (51)
               +- CometFilter (50)
                  +- CometScan parquet spark_catalog.default.store_sales (49)


(49) CometScan parquet spark_catalog.default.store_sales
Output [4]: [ss_addr_sk#30, ss_store_sk#31, ss_net_profit#32, ss_sold_date_sk#33]
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)>

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

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

(52) CometColumnarToRow [codegen id : 1]
Input [2]: [ss_store_sk#31, ss_net_profit#32]

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

(54) CometColumnarExchange
Input [3]: [ss_store_sk#31, sum#36, count#37]
Arguments: hashpartitioning(ss_store_sk#31, 5), ENSURE_REQUIREMENTS, CometColumnarShuffle, [plan_id=6]

(55) CometColumnarToRow [codegen id : 2]
Input [3]: [ss_store_sk#31, sum#36, count#37]

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

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


