== Physical Plan ==
AdaptiveSparkPlan (160)
+- == Final Plan ==
   NativeTakeOrdered (101)
   +- NativeProject (100)
      +- NativeWindow (99)
         +- NativeSort (98)
            +- InputAdapter (97)
               +- AQEShuffleRead (96)
                  +- ShuffleQueryStage (95), Statistics(X)
                     +- NativeShuffleExchange (94)
                        +- NativeProject (93)
                           +- NativeHashAggregate (92)
                              +- InputAdapter (91)
                                 +- AQEShuffleRead (90)
                                    +- ShuffleQueryStage (89), Statistics(X)
                                       +- NativeShuffleExchange (88)
                                          +- NativeHashAggregate (87)
                                             +- NativeProject (86)
                                                +- NativeExpand (85)
                                                   +- NativeProject (84)
                                                      +- NativeSortMergeJoin Inner (83)
                                                         :- NativeSort (24)
                                                         :  +- InputAdapter (23)
                                                         :     +- AQEShuffleRead (22)
                                                         :        +- ShuffleQueryStage (21), Statistics(X)
                                                         :           +- NativeShuffleExchange (20)
                                                         :              +- NativeProject (19)
                                                         :                 +- NativeSortMergeJoin Inner (18)
                                                         :                    :- NativeSort (8)
                                                         :                    :  +- InputAdapter (7)
                                                         :                    :     +- AQEShuffleRead (6)
                                                         :                    :        +- ShuffleQueryStage (5), Statistics(X)
                                                         :                    :           +- NativeShuffleExchange (4)
                                                         :                    :              +- NativeFilter (3)
                                                         :                    :                 +- InputAdapter (2)
                                                         :                    :                    +- NativeParquetScan  (1)
                                                         :                    +- NativeSort (17)
                                                         :                       +- InputAdapter (16)
                                                         :                          +- AQEShuffleRead (15)
                                                         :                             +- ShuffleQueryStage (14), Statistics(X)
                                                         :                                +- NativeShuffleExchange (13)
                                                         :                                   +- NativeProject (12)
                                                         :                                      +- NativeFilter (11)
                                                         :                                         +- InputAdapter (10)
                                                         :                                            +- NativeParquetScan  (9)
                                                         +- NativeSort (82)
                                                            +- InputAdapter (81)
                                                               +- AQEShuffleRead (80)
                                                                  +- ShuffleQueryStage (79), Statistics(X)
                                                                     +- NativeShuffleExchange (78)
                                                                        +- NativeSortMergeJoin LeftSemi (77)
                                                                           :- NativeSort (32)
                                                                           :  +- InputAdapter (31)
                                                                           :     +- AQEShuffleRead (30)
                                                                           :        +- ShuffleQueryStage (29), Statistics(X)
                                                                           :           +- NativeShuffleExchange (28)
                                                                           :              +- NativeFilter (27)
                                                                           :                 +- InputAdapter (26)
                                                                           :                    +- NativeParquetScan  (25)
                                                                           +- NativeProject (76)
                                                                              +- NativeFilter (75)
                                                                                 +- NativeWindow (74)
                                                                                    +- NativeWindowGroupLimit (73)
                                                                                       +- NativeSort (72)
                                                                                          +- NativeProject (71)
                                                                                             +- NativeHashAggregate (70)
                                                                                                +- InputAdapter (69)
                                                                                                   +- AQEShuffleRead (68)
                                                                                                      +- ShuffleQueryStage (67), Statistics(X)
                                                                                                         +- NativeShuffleExchange (66)
                                                                                                            +- NativeHashAggregate (65)
                                                                                                               +- NativeProject (64)
                                                                                                                  +- NativeProject (63)
                                                                                                                     +- NativeSortMergeJoin Inner (62)
                                                                                                                        :- NativeSort (55)
                                                                                                                        :  +- InputAdapter (54)
                                                                                                                        :     +- AQEShuffleRead (53)
                                                                                                                        :        +- ShuffleQueryStage (52), Statistics(X)
                                                                                                                        :           +- NativeShuffleExchange (51)
                                                                                                                        :              +- NativeProject (50)
                                                                                                                        :                 +- NativeSortMergeJoin Inner (49)
                                                                                                                        :                    :- NativeSort (40)
                                                                                                                        :                    :  +- InputAdapter (39)
                                                                                                                        :                    :     +- AQEShuffleRead (38)
                                                                                                                        :                    :        +- ShuffleQueryStage (37), Statistics(X)
                                                                                                                        :                    :           +- NativeShuffleExchange (36)
                                                                                                                        :                    :              +- NativeFilter (35)
                                                                                                                        :                    :                 +- InputAdapter (34)
                                                                                                                        :                    :                    +- NativeParquetScan  (33)
                                                                                                                        :                    +- NativeSort (48)
                                                                                                                        :                       +- InputAdapter (47)
                                                                                                                        :                          +- AQEShuffleRead (46)
                                                                                                                        :                             +- ShuffleQueryStage (45), Statistics(X)
                                                                                                                        :                                +- NativeShuffleExchange (44)
                                                                                                                        :                                   +- NativeFilter (43)
                                                                                                                        :                                      +- InputAdapter (42)
                                                                                                                        :                                         +- NativeParquetScan  (41)
                                                                                                                        +- NativeSort (61)
                                                                                                                           +- InputAdapter (60)
                                                                                                                              +- InputAdapter (59)
                                                                                                                                 +- AQEShuffleRead (58)
                                                                                                                                    +- ShuffleQueryStage (57), Statistics(X)
                                                                                                                                       +- ReusedExchange (56)
+- == Initial Plan ==
   TakeOrderedAndProject (159)
   +- Project (158)
      +- Window (157)
         +- Sort (156)
            +- Exchange (155)
               +- HashAggregate (154)
                  +- Exchange (153)
                     +- HashAggregate (152)
                        +- Expand (151)
                           +- Project (150)
                              +- SortMergeJoin Inner (149)
                                 :- Sort (114)
                                 :  +- Exchange (113)
                                 :     +- Project (112)
                                 :        +- SortMergeJoin Inner (111)
                                 :           :- Sort (105)
                                 :           :  +- Exchange (104)
                                 :           :     +- Filter (103)
                                 :           :        +- Scan parquet (102)
                                 :           +- Sort (110)
                                 :              +- Exchange (109)
                                 :                 +- Project (108)
                                 :                    +- Filter (107)
                                 :                       +- Scan parquet (106)
                                 +- Sort (148)
                                    +- Exchange (147)
                                       +- SortMergeJoin LeftSemi (146)
                                          :- Sort (118)
                                          :  +- Exchange (117)
                                          :     +- Filter (116)
                                          :        +- Scan parquet (115)
                                          +- Project (145)
                                             +- Filter (144)
                                                +- Window (143)
                                                   +- WindowGroupLimit (142)
                                                      +- Sort (141)
                                                         +- HashAggregate (140)
                                                            +- Exchange (139)
                                                               +- HashAggregate (138)
                                                                  +- Project (137)
                                                                     +- SortMergeJoin Inner (136)
                                                                        :- Sort (130)
                                                                        :  +- Exchange (129)
                                                                        :     +- Project (128)
                                                                        :        +- SortMergeJoin Inner (127)
                                                                        :           :- Sort (122)
                                                                        :           :  +- Exchange (121)
                                                                        :           :     +- Filter (120)
                                                                        :           :        +- Scan parquet (119)
                                                                        :           +- Sort (126)
                                                                        :              +- Exchange (125)
                                                                        :                 +- Filter (124)
                                                                        :                    +- Scan parquet (123)
                                                                        +- Sort (135)
                                                                           +- Exchange (134)
                                                                              +- Project (133)
                                                                                 +- Filter (132)
                                                                                    +- Scan parquet (131)


(102) Scan parquet
Output [3]: [ss_sold_date_sk#1, ss_store_sk#2, ss_net_profit#3]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(ss_sold_date_sk), IsNotNull(ss_store_sk)]
ReadSchema: struct<ss_sold_date_sk:int,ss_store_sk:int,ss_net_profit:decimal(7,2)>

(2) InputAdapter
Input [3]: [ss_sold_date_sk#1, ss_store_sk#2, ss_net_profit#3]
Arguments: [#1, #2, #3]

(3) NativeFilter
Input [3]: [#1#1, #2#2, #3#3]
Condition : (isnotnull(ss_sold_date_sk#1) AND isnotnull(ss_store_sk#2))

(4) NativeShuffleExchange
Input [3]: [#1#1, #2#2, #3#3]
Arguments: hashpartitioning(ss_sold_date_sk#1, 100), ENSURE_REQUIREMENTS, [plan_id=1]

(5) ShuffleQueryStage
Output [3]: [#1#1, #2#2, #3#3]
Arguments: X

(6) AQEShuffleRead
Input [3]: [#1#1, #2#2, #3#3]
Arguments: coalesced

(7) InputAdapter
Input [3]: [#1#1, #2#2, #3#3]

(8) NativeSort
Input [3]: [#1#1, #2#2, #3#3]
Arguments: [ss_sold_date_sk#1 ASC NULLS FIRST], false

(106) Scan parquet
Output [2]: [d_date_sk#4, d_month_seq#5]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(d_month_seq), GreaterThanOrEqual(d_month_seq,1200), LessThanOrEqual(d_month_seq,1211), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_month_seq:int>

(10) InputAdapter
Input [2]: [d_date_sk#4, d_month_seq#5]
Arguments: [#4, #5]

(11) NativeFilter
Input [2]: [#4#4, #5#5]
Condition : (((isnotnull(d_month_seq#5) AND (d_month_seq#5 >= 1200)) AND (d_month_seq#5 <= 1211)) AND isnotnull(d_date_sk#4))

(12) NativeProject
Output [1]: [d_date_sk#4]
Input [2]: [#4#4, #5#5]

(13) NativeShuffleExchange
Input [1]: [d_date_sk#4]
Arguments: hashpartitioning(d_date_sk#4, 100), ENSURE_REQUIREMENTS, [plan_id=2]

(14) ShuffleQueryStage
Output [1]: [d_date_sk#4]
Arguments: X

(15) AQEShuffleRead
Input [1]: [d_date_sk#4]
Arguments: coalesced

(16) InputAdapter
Input [1]: [d_date_sk#4]

(17) NativeSort
Input [1]: [d_date_sk#4]
Arguments: [d_date_sk#4 ASC NULLS FIRST], false

(18) NativeSortMergeJoin
Left keys [1]: [ss_sold_date_sk#1]
Right keys [1]: [d_date_sk#4]
Join type: Inner
Join condition: None

(19) NativeProject
Output [2]: [ss_store_sk#2, ss_net_profit#3]
Input [4]: [#1#1, #2#2, #3#3, d_date_sk#4]

(20) NativeShuffleExchange
Input [2]: [ss_store_sk#2, ss_net_profit#3]
Arguments: hashpartitioning(ss_store_sk#2, 100), ENSURE_REQUIREMENTS, [plan_id=3]

(21) ShuffleQueryStage
Output [2]: [ss_store_sk#2, ss_net_profit#3]
Arguments: X

(22) AQEShuffleRead
Input [2]: [ss_store_sk#2, ss_net_profit#3]
Arguments: coalesced

(23) InputAdapter
Input [2]: [ss_store_sk#2, ss_net_profit#3]

(24) NativeSort
Input [2]: [ss_store_sk#2, ss_net_profit#3]
Arguments: [ss_store_sk#2 ASC NULLS FIRST], false

(115) Scan parquet
Output [3]: [s_store_sk#6, s_county#7, s_state#8]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(s_store_sk)]
ReadSchema: struct<s_store_sk:int,s_county:string,s_state:string>

(26) InputAdapter
Input [3]: [s_store_sk#6, s_county#7, s_state#8]
Arguments: [#6, #7, #8]

(27) NativeFilter
Input [3]: [#6#6, #7#7, #8#8]
Condition : isnotnull(s_store_sk#6)

(28) NativeShuffleExchange
Input [3]: [#6#6, #7#7, #8#8]
Arguments: hashpartitioning(s_state#8, 100), ENSURE_REQUIREMENTS, [plan_id=4]

(29) ShuffleQueryStage
Output [3]: [#6#6, #7#7, #8#8]
Arguments: X

(30) AQEShuffleRead
Input [3]: [#6#6, #7#7, #8#8]
Arguments: coalesced

(31) InputAdapter
Input [3]: [#6#6, #7#7, #8#8]

(32) NativeSort
Input [3]: [#6#6, #7#7, #8#8]
Arguments: [s_state#8 ASC NULLS FIRST], false

(119) Scan parquet
Output [3]: [ss_sold_date_sk#9, ss_store_sk#10, ss_net_profit#11]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(ss_store_sk), IsNotNull(ss_sold_date_sk)]
ReadSchema: struct<ss_sold_date_sk:int,ss_store_sk:int,ss_net_profit:decimal(7,2)>

(34) InputAdapter
Input [3]: [ss_sold_date_sk#9, ss_store_sk#10, ss_net_profit#11]
Arguments: [#9, #10, #11]

(35) NativeFilter
Input [3]: [#9#9, #10#10, #11#11]
Condition : (isnotnull(ss_store_sk#10) AND isnotnull(ss_sold_date_sk#9))

(36) NativeShuffleExchange
Input [3]: [#9#9, #10#10, #11#11]
Arguments: hashpartitioning(ss_store_sk#10, 100), ENSURE_REQUIREMENTS, [plan_id=5]

(37) ShuffleQueryStage
Output [3]: [#9#9, #10#10, #11#11]
Arguments: X

(38) AQEShuffleRead
Input [3]: [#9#9, #10#10, #11#11]
Arguments: coalesced

(39) InputAdapter
Input [3]: [#9#9, #10#10, #11#11]

(40) NativeSort
Input [3]: [#9#9, #10#10, #11#11]
Arguments: [ss_store_sk#10 ASC NULLS FIRST], false

(123) Scan parquet
Output [2]: [s_store_sk#12, s_state#13]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(s_store_sk)]
ReadSchema: struct<s_store_sk:int,s_state:string>

(42) InputAdapter
Input [2]: [s_store_sk#12, s_state#13]
Arguments: [#12, #13]

(43) NativeFilter
Input [2]: [#12#12, #13#13]
Condition : isnotnull(s_store_sk#12)

(44) NativeShuffleExchange
Input [2]: [#12#12, #13#13]
Arguments: hashpartitioning(s_store_sk#12, 100), ENSURE_REQUIREMENTS, [plan_id=6]

(45) ShuffleQueryStage
Output [2]: [#12#12, #13#13]
Arguments: X

(46) AQEShuffleRead
Input [2]: [#12#12, #13#13]
Arguments: coalesced

(47) InputAdapter
Input [2]: [#12#12, #13#13]

(48) NativeSort
Input [2]: [#12#12, #13#13]
Arguments: [s_store_sk#12 ASC NULLS FIRST], false

(49) NativeSortMergeJoin
Left keys [1]: [ss_store_sk#10]
Right keys [1]: [s_store_sk#12]
Join type: Inner
Join condition: None

(50) NativeProject
Output [3]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13]
Input [5]: [#9#9, #10#10, #11#11, #12#12, #13#13]

(51) NativeShuffleExchange
Input [3]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13]
Arguments: hashpartitioning(ss_sold_date_sk#9, 100), ENSURE_REQUIREMENTS, [plan_id=7]

(52) ShuffleQueryStage
Output [3]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13]
Arguments: X

(53) AQEShuffleRead
Input [3]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13]
Arguments: coalesced

(54) InputAdapter
Input [3]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13]

(55) NativeSort
Input [3]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13]
Arguments: [ss_sold_date_sk#9 ASC NULLS FIRST], false

(56) ReusedExchange [Reuses operator id: 13]
Output [1]: [d_date_sk#14]

(57) ShuffleQueryStage
Output [1]: [d_date_sk#14]
Arguments: X

(58) AQEShuffleRead
Input [1]: [d_date_sk#14]
Arguments: coalesced

(59) InputAdapter
Input [1]: [d_date_sk#14]
Arguments: [#14]

(60) InputAdapter
Input [1]: [#14#14]

(61) NativeSort
Input [1]: [#14#14]
Arguments: [d_date_sk#14 ASC NULLS FIRST], false

(62) NativeSortMergeJoin
Left keys [1]: [ss_sold_date_sk#9]
Right keys [1]: [d_date_sk#14]
Join type: Inner
Join condition: None

(63) NativeProject
Output [2]: [ss_net_profit#11, s_state#13]
Input [4]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13, #14#14]

(64) NativeProject
Output [2]: [s_state#13 AS s_state#13, UnscaledValue(ss_net_profit#11) AS _c1#15]
Input [2]: [ss_net_profit#11, s_state#13]

(65) NativeHashAggregate
Input [2]: [s_state#13, _c1#15]
Keys [1]: [s_state#13]
Functions [1]: [partial_sum(_c1#15)]
Aggregate Attributes [1]: [sum#16]
Results [2]: [s_state#13, #17]

(66) NativeShuffleExchange
Input [2]: [s_state#13, #17]
Arguments: hashpartitioning(s_state#13, 100), ENSURE_REQUIREMENTS, [plan_id=8]

(67) ShuffleQueryStage
Output [2]: [s_state#13, #17]
Arguments: X

(68) AQEShuffleRead
Input [2]: [s_state#13, #17]
Arguments: coalesced

(69) InputAdapter
Input [2]: [s_state#13, #17]

(70) NativeHashAggregate
Input [2]: [s_state#13, #17]
Keys [1]: [s_state#13]
Functions [1]: [sum(UnscaledValue(ss_net_profit#11))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_net_profit#11))#18]
Results [2]: [s_state#13, sum(UnscaledValue(ss_net_profit#11))#18]

(71) NativeProject
Output [3]: [s_state#13, s_state#13, MakeDecimal(sum(UnscaledValue(ss_net_profit#11))#18,17,2) AS _w1#19]
Input [2]: [s_state#13, sum(UnscaledValue(ss_net_profit#11))#18]

(72) NativeSort
Input [3]: [s_state#13, s_state#13, _w1#19]
Arguments: [s_state#13 ASC NULLS FIRST, _w1#19 DESC NULLS LAST], false

(73) NativeWindowGroupLimit
Input [3]: [s_state#13, s_state#13, _w1#19]
Arguments: [rank(_w1#19) windowspecdefinition(s_state#13, _w1#19 DESC NULLS LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS __window_expression__#20], [s_state#13], [_w1#19 DESC NULLS LAST], 5

(74) NativeWindow
Input [3]: [s_state#13, s_state#13, _w1#19]
Arguments: [rank(_w1#19) windowspecdefinition(s_state#13, _w1#19 DESC NULLS LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS ranking#21], [s_state#13], [_w1#19 DESC NULLS LAST]

(75) NativeFilter
Input [4]: [s_state#13, s_state#13, _w1#19, ranking#21]
Condition : (ranking#21 <= 5)

(76) NativeProject
Output [1]: [s_state#13]
Input [4]: [s_state#13, s_state#13, _w1#19, ranking#21]

(77) NativeSortMergeJoin
Left keys [1]: [s_state#8]
Right keys [1]: [s_state#13]
Join type: LeftSemi
Join condition: None

(78) NativeShuffleExchange
Input [3]: [#6#6, #7#7, #8#8]
Arguments: hashpartitioning(s_store_sk#6, 100), ENSURE_REQUIREMENTS, [plan_id=9]

(79) ShuffleQueryStage
Output [3]: [#6#6, #7#7, #8#8]
Arguments: X

(80) AQEShuffleRead
Input [3]: [#6#6, #7#7, #8#8]
Arguments: coalesced

(81) InputAdapter
Input [3]: [#6#6, #7#7, #8#8]

(82) NativeSort
Input [3]: [#6#6, #7#7, #8#8]
Arguments: [s_store_sk#6 ASC NULLS FIRST], false

(83) NativeSortMergeJoin
Left keys [1]: [ss_store_sk#2]
Right keys [1]: [s_store_sk#6]
Join type: Inner
Join condition: None

(84) NativeProject
Output [3]: [ss_net_profit#3, s_state#8, s_county#7]
Input [5]: [ss_store_sk#2, ss_net_profit#3, #6#6, #7#7, #8#8]

(85) NativeExpand
Input [3]: [ss_net_profit#3, s_state#8, s_county#7]
Arguments: [[ss_net_profit#3, s_state#8, s_county#7, 0], [ss_net_profit#3, s_state#8, null, 1], [ss_net_profit#3, null, null, 3]], [ss_net_profit#3, s_state#22, s_county#23, spark_grouping_id#24]

(86) NativeProject
Output [4]: [s_state#22 AS s_state#22, s_county#23 AS s_county#23, spark_grouping_id#24 AS spark_grouping_id#24, UnscaledValue(ss_net_profit#3) AS _c3#25]
Input [4]: [ss_net_profit#3, s_state#22, s_county#23, spark_grouping_id#24]

(87) NativeHashAggregate
Input [4]: [s_state#22, s_county#23, spark_grouping_id#24, _c3#25]
Keys [3]: [s_state#22, s_county#23, spark_grouping_id#24]
Functions [1]: [partial_sum(_c3#25)]
Aggregate Attributes [1]: [sum#26]
Results [4]: [s_state#22, s_county#23, spark_grouping_id#24, #17]

(88) NativeShuffleExchange
Input [4]: [s_state#22, s_county#23, spark_grouping_id#24, #17]
Arguments: hashpartitioning(s_state#22, s_county#23, spark_grouping_id#24, 100), ENSURE_REQUIREMENTS, [plan_id=10]

(89) ShuffleQueryStage
Output [4]: [s_state#22, s_county#23, spark_grouping_id#24, #17]
Arguments: X

(90) AQEShuffleRead
Input [4]: [s_state#22, s_county#23, spark_grouping_id#24, #17]
Arguments: coalesced

(91) InputAdapter
Input [4]: [s_state#22, s_county#23, spark_grouping_id#24, #17]

(92) NativeHashAggregate
Input [4]: [s_state#22, s_county#23, spark_grouping_id#24, #17]
Keys [3]: [s_state#22, s_county#23, spark_grouping_id#24]
Functions [1]: [sum(UnscaledValue(ss_net_profit#3))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_net_profit#3))#27]
Results [4]: [s_state#22, s_county#23, spark_grouping_id#24, sum(UnscaledValue(ss_net_profit#3))#27]

(93) NativeProject
Output [7]: [MakeDecimal(sum(UnscaledValue(ss_net_profit#3))#27,17,2) AS total_sum#28, s_state#22, s_county#23, (cast((shiftright(spark_grouping_id#24, 1) & 1) as tinyint) + cast((shiftright(spark_grouping_id#24, 0) & 1) as tinyint)) AS lochierarchy#29, MakeDecimal(sum(UnscaledValue(ss_net_profit#3))#27,17,2) AS _w0#30, (cast((shiftright(spark_grouping_id#24, 1) & 1) as tinyint) + cast((shiftright(spark_grouping_id#24, 0) & 1) as tinyint)) AS _w1#31, CASE WHEN (cast((shiftright(spark_grouping_id#24, 0) & 1) as tinyint) = 0) THEN s_state#22 END AS _w2#32]
Input [4]: [s_state#22, s_county#23, spark_grouping_id#24, sum(UnscaledValue(ss_net_profit#3))#27]

(94) NativeShuffleExchange
Input [7]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32]
Arguments: hashpartitioning(_w1#31, _w2#32, 100), ENSURE_REQUIREMENTS, [plan_id=11]

(95) ShuffleQueryStage
Output [7]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32]
Arguments: X

(96) AQEShuffleRead
Input [7]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32]
Arguments: coalesced

(97) InputAdapter
Input [7]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32]

(98) NativeSort
Input [7]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32]
Arguments: [_w1#31 ASC NULLS FIRST, _w2#32 ASC NULLS FIRST, _w0#30 DESC NULLS LAST], false

(99) NativeWindow
Input [7]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32]
Arguments: [rank(_w0#30) windowspecdefinition(_w1#31, _w2#32, _w0#30 DESC NULLS LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rank_within_parent#33], [_w1#31, _w2#32], [_w0#30 DESC NULLS LAST]

(100) NativeProject
Output [5]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, rank_within_parent#33]
Input [8]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32, rank_within_parent#33]

(101) NativeTakeOrdered
Input [5]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, rank_within_parent#33]
Arguments: X, X, [lochierarchy#29 DESC NULLS LAST, CASE WHEN (lochierarchy#29 = 0) THEN s_state#22 END ASC NULLS FIRST, rank_within_parent#33 ASC NULLS FIRST]

(102) Scan parquet
Output [3]: [ss_sold_date_sk#1, ss_store_sk#2, ss_net_profit#3]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(ss_sold_date_sk), IsNotNull(ss_store_sk)]
ReadSchema: struct<ss_sold_date_sk:int,ss_store_sk:int,ss_net_profit:decimal(7,2)>

(103) Filter
Input [3]: [ss_sold_date_sk#1, ss_store_sk#2, ss_net_profit#3]
Condition : (isnotnull(ss_sold_date_sk#1) AND isnotnull(ss_store_sk#2))

(104) Exchange
Input [3]: [ss_sold_date_sk#1, ss_store_sk#2, ss_net_profit#3]
Arguments: hashpartitioning(ss_sold_date_sk#1, 100), ENSURE_REQUIREMENTS, [plan_id=12]

(105) Sort
Input [3]: [ss_sold_date_sk#1, ss_store_sk#2, ss_net_profit#3]
Arguments: [ss_sold_date_sk#1 ASC NULLS FIRST], false, 0

(106) Scan parquet
Output [2]: [d_date_sk#4, d_month_seq#5]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(d_month_seq), GreaterThanOrEqual(d_month_seq,1200), LessThanOrEqual(d_month_seq,1211), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_month_seq:int>

(107) Filter
Input [2]: [d_date_sk#4, d_month_seq#5]
Condition : (((isnotnull(d_month_seq#5) AND (d_month_seq#5 >= 1200)) AND (d_month_seq#5 <= 1211)) AND isnotnull(d_date_sk#4))

(108) Project
Output [1]: [d_date_sk#4]
Input [2]: [d_date_sk#4, d_month_seq#5]

(109) Exchange
Input [1]: [d_date_sk#4]
Arguments: hashpartitioning(d_date_sk#4, 100), ENSURE_REQUIREMENTS, [plan_id=13]

(110) Sort
Input [1]: [d_date_sk#4]
Arguments: [d_date_sk#4 ASC NULLS FIRST], false, 0

(111) SortMergeJoin
Left keys [1]: [ss_sold_date_sk#1]
Right keys [1]: [d_date_sk#4]
Join type: Inner
Join condition: None

(112) Project
Output [2]: [ss_store_sk#2, ss_net_profit#3]
Input [4]: [ss_sold_date_sk#1, ss_store_sk#2, ss_net_profit#3, d_date_sk#4]

(113) Exchange
Input [2]: [ss_store_sk#2, ss_net_profit#3]
Arguments: hashpartitioning(ss_store_sk#2, 100), ENSURE_REQUIREMENTS, [plan_id=14]

(114) Sort
Input [2]: [ss_store_sk#2, ss_net_profit#3]
Arguments: [ss_store_sk#2 ASC NULLS FIRST], false, 0

(115) Scan parquet
Output [3]: [s_store_sk#6, s_county#7, s_state#8]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(s_store_sk)]
ReadSchema: struct<s_store_sk:int,s_county:string,s_state:string>

(116) Filter
Input [3]: [s_store_sk#6, s_county#7, s_state#8]
Condition : isnotnull(s_store_sk#6)

(117) Exchange
Input [3]: [s_store_sk#6, s_county#7, s_state#8]
Arguments: hashpartitioning(s_state#8, 100), ENSURE_REQUIREMENTS, [plan_id=15]

(118) Sort
Input [3]: [s_store_sk#6, s_county#7, s_state#8]
Arguments: [s_state#8 ASC NULLS FIRST], false, 0

(119) Scan parquet
Output [3]: [ss_sold_date_sk#9, ss_store_sk#10, ss_net_profit#11]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(ss_store_sk), IsNotNull(ss_sold_date_sk)]
ReadSchema: struct<ss_sold_date_sk:int,ss_store_sk:int,ss_net_profit:decimal(7,2)>

(120) Filter
Input [3]: [ss_sold_date_sk#9, ss_store_sk#10, ss_net_profit#11]
Condition : (isnotnull(ss_store_sk#10) AND isnotnull(ss_sold_date_sk#9))

(121) Exchange
Input [3]: [ss_sold_date_sk#9, ss_store_sk#10, ss_net_profit#11]
Arguments: hashpartitioning(ss_store_sk#10, 100), ENSURE_REQUIREMENTS, [plan_id=16]

(122) Sort
Input [3]: [ss_sold_date_sk#9, ss_store_sk#10, ss_net_profit#11]
Arguments: [ss_store_sk#10 ASC NULLS FIRST], false, 0

(123) Scan parquet
Output [2]: [s_store_sk#12, s_state#13]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(s_store_sk)]
ReadSchema: struct<s_store_sk:int,s_state:string>

(124) Filter
Input [2]: [s_store_sk#12, s_state#13]
Condition : isnotnull(s_store_sk#12)

(125) Exchange
Input [2]: [s_store_sk#12, s_state#13]
Arguments: hashpartitioning(s_store_sk#12, 100), ENSURE_REQUIREMENTS, [plan_id=17]

(126) Sort
Input [2]: [s_store_sk#12, s_state#13]
Arguments: [s_store_sk#12 ASC NULLS FIRST], false, 0

(127) SortMergeJoin
Left keys [1]: [ss_store_sk#10]
Right keys [1]: [s_store_sk#12]
Join type: Inner
Join condition: None

(128) Project
Output [3]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13]
Input [5]: [ss_sold_date_sk#9, ss_store_sk#10, ss_net_profit#11, s_store_sk#12, s_state#13]

(129) Exchange
Input [3]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13]
Arguments: hashpartitioning(ss_sold_date_sk#9, 100), ENSURE_REQUIREMENTS, [plan_id=18]

(130) Sort
Input [3]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13]
Arguments: [ss_sold_date_sk#9 ASC NULLS FIRST], false, 0

(131) Scan parquet
Output [2]: [d_date_sk#14, d_month_seq#34]
Batched: true
Location: InMemoryFileIndex [file:/<warehouse_dir>]
PushedFilters: [IsNotNull(d_month_seq), GreaterThanOrEqual(d_month_seq,1200), LessThanOrEqual(d_month_seq,1211), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_month_seq:int>

(132) Filter
Input [2]: [d_date_sk#14, d_month_seq#34]
Condition : (((isnotnull(d_month_seq#34) AND (d_month_seq#34 >= 1200)) AND (d_month_seq#34 <= 1211)) AND isnotnull(d_date_sk#14))

(133) Project
Output [1]: [d_date_sk#14]
Input [2]: [d_date_sk#14, d_month_seq#34]

(134) Exchange
Input [1]: [d_date_sk#14]
Arguments: hashpartitioning(d_date_sk#14, 100), ENSURE_REQUIREMENTS, [plan_id=19]

(135) Sort
Input [1]: [d_date_sk#14]
Arguments: [d_date_sk#14 ASC NULLS FIRST], false, 0

(136) SortMergeJoin
Left keys [1]: [ss_sold_date_sk#9]
Right keys [1]: [d_date_sk#14]
Join type: Inner
Join condition: None

(137) Project
Output [2]: [ss_net_profit#11, s_state#13]
Input [4]: [ss_sold_date_sk#9, ss_net_profit#11, s_state#13, d_date_sk#14]

(138) HashAggregate
Input [2]: [ss_net_profit#11, s_state#13]
Keys [1]: [s_state#13]
Functions [1]: [partial_sum(UnscaledValue(ss_net_profit#11))]
Aggregate Attributes [1]: [sum#16]
Results [2]: [s_state#13, sum#35]

(139) Exchange
Input [2]: [s_state#13, sum#35]
Arguments: hashpartitioning(s_state#13, 100), ENSURE_REQUIREMENTS, [plan_id=20]

(140) HashAggregate
Input [2]: [s_state#13, sum#35]
Keys [1]: [s_state#13]
Functions [1]: [sum(UnscaledValue(ss_net_profit#11))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_net_profit#11))#18]
Results [3]: [s_state#13, s_state#13, MakeDecimal(sum(UnscaledValue(ss_net_profit#11))#18,17,2) AS _w1#19]

(141) Sort
Input [3]: [s_state#13, s_state#13, _w1#19]
Arguments: [s_state#13 ASC NULLS FIRST, _w1#19 DESC NULLS LAST], false, 0

(142) WindowGroupLimit
Input [3]: [s_state#13, s_state#13, _w1#19]
Arguments: [s_state#13], [_w1#19 DESC NULLS LAST], rank(_w1#19), 5, Final

(143) Window
Input [3]: [s_state#13, s_state#13, _w1#19]
Arguments: [rank(_w1#19) windowspecdefinition(s_state#13, _w1#19 DESC NULLS LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS ranking#21], [s_state#13], [_w1#19 DESC NULLS LAST]

(144) Filter
Input [4]: [s_state#13, s_state#13, _w1#19, ranking#21]
Condition : (ranking#21 <= 5)

(145) Project
Output [1]: [s_state#13]
Input [4]: [s_state#13, s_state#13, _w1#19, ranking#21]

(146) SortMergeJoin
Left keys [1]: [s_state#8]
Right keys [1]: [s_state#13]
Join type: LeftSemi
Join condition: None

(147) Exchange
Input [3]: [s_store_sk#6, s_county#7, s_state#8]
Arguments: hashpartitioning(s_store_sk#6, 100), ENSURE_REQUIREMENTS, [plan_id=21]

(148) Sort
Input [3]: [s_store_sk#6, s_county#7, s_state#8]
Arguments: [s_store_sk#6 ASC NULLS FIRST], false, 0

(149) SortMergeJoin
Left keys [1]: [ss_store_sk#2]
Right keys [1]: [s_store_sk#6]
Join type: Inner
Join condition: None

(150) Project
Output [3]: [ss_net_profit#3, s_state#8, s_county#7]
Input [5]: [ss_store_sk#2, ss_net_profit#3, s_store_sk#6, s_county#7, s_state#8]

(151) Expand
Input [3]: [ss_net_profit#3, s_state#8, s_county#7]
Arguments: [[ss_net_profit#3, s_state#8, s_county#7, 0], [ss_net_profit#3, s_state#8, null, 1], [ss_net_profit#3, null, null, 3]], [ss_net_profit#3, s_state#22, s_county#23, spark_grouping_id#24]

(152) HashAggregate
Input [4]: [ss_net_profit#3, s_state#22, s_county#23, spark_grouping_id#24]
Keys [3]: [s_state#22, s_county#23, spark_grouping_id#24]
Functions [1]: [partial_sum(UnscaledValue(ss_net_profit#3))]
Aggregate Attributes [1]: [sum#26]
Results [4]: [s_state#22, s_county#23, spark_grouping_id#24, sum#36]

(153) Exchange
Input [4]: [s_state#22, s_county#23, spark_grouping_id#24, sum#36]
Arguments: hashpartitioning(s_state#22, s_county#23, spark_grouping_id#24, 100), ENSURE_REQUIREMENTS, [plan_id=22]

(154) HashAggregate
Input [4]: [s_state#22, s_county#23, spark_grouping_id#24, sum#36]
Keys [3]: [s_state#22, s_county#23, spark_grouping_id#24]
Functions [1]: [sum(UnscaledValue(ss_net_profit#3))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_net_profit#3))#27]
Results [7]: [MakeDecimal(sum(UnscaledValue(ss_net_profit#3))#27,17,2) AS total_sum#28, s_state#22, s_county#23, (cast((shiftright(spark_grouping_id#24, 1) & 1) as tinyint) + cast((shiftright(spark_grouping_id#24, 0) & 1) as tinyint)) AS lochierarchy#29, MakeDecimal(sum(UnscaledValue(ss_net_profit#3))#27,17,2) AS _w0#30, (cast((shiftright(spark_grouping_id#24, 1) & 1) as tinyint) + cast((shiftright(spark_grouping_id#24, 0) & 1) as tinyint)) AS _w1#31, CASE WHEN (cast((shiftright(spark_grouping_id#24, 0) & 1) as tinyint) = 0) THEN s_state#22 END AS _w2#32]

(155) Exchange
Input [7]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32]
Arguments: hashpartitioning(_w1#31, _w2#32, 100), ENSURE_REQUIREMENTS, [plan_id=23]

(156) Sort
Input [7]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32]
Arguments: [_w1#31 ASC NULLS FIRST, _w2#32 ASC NULLS FIRST, _w0#30 DESC NULLS LAST], false, 0

(157) Window
Input [7]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32]
Arguments: [rank(_w0#30) windowspecdefinition(_w1#31, _w2#32, _w0#30 DESC NULLS LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS rank_within_parent#33], [_w1#31, _w2#32], [_w0#30 DESC NULLS LAST]

(158) Project
Output [5]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, rank_within_parent#33]
Input [8]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, _w0#30, _w1#31, _w2#32, rank_within_parent#33]

(159) TakeOrderedAndProject
Input [5]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, rank_within_parent#33]
Arguments: X, [lochierarchy#29 DESC NULLS LAST, CASE WHEN (lochierarchy#29 = 0) THEN s_state#22 END ASC NULLS FIRST, rank_within_parent#33 ASC NULLS FIRST], [total_sum#28, s_state#22, s_county#23, lochierarchy#29, rank_within_parent#33]

(160) AdaptiveSparkPlan
Output [5]: [total_sum#28, s_state#22, s_county#23, lochierarchy#29, rank_within_parent#33]
Arguments: isFinalPlan=true

