-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
planner/core: refine explain for window function (#9270)
- Loading branch information
Showing
8 changed files
with
147 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use test; | ||
drop table if exists t; | ||
create table t (a int, b int, c timestamp, index idx(a)); | ||
set @@tidb_enable_window_function = 1; | ||
explain select sum(a) over() from t; | ||
id count task operator info | ||
Projection_7 10000.00 root sum(a) over() | ||
└─Window_8 10000.00 root sum(cast(test.t.a)) over() | ||
└─TableReader_10 10000.00 root data:TableScan_9 | ||
└─TableScan_9 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo | ||
explain select sum(a) over(partition by a) from t; | ||
id count task operator info | ||
Projection_7 10000.00 root sum(a) over(partition by a) | ||
└─Window_8 10000.00 root sum(cast(test.t.a)) over(partition by test.t.a) | ||
└─IndexReader_11 10000.00 root index:IndexScan_10 | ||
└─IndexScan_10 10000.00 cop table:t, index:a, range:[NULL,+inf], keep order:true, stats:pseudo | ||
explain select sum(a) over(partition by a order by b) from t; | ||
id count task operator info | ||
Projection_7 10000.00 root sum(a) over(partition by a order by b) | ||
└─Window_8 10000.00 root sum(cast(test.t.a)) over(partition by test.t.a order by test.t.b asc) | ||
└─Sort_14 10000.00 root test.t.a:asc, test.t.b:asc | ||
└─TableReader_13 10000.00 root data:TableScan_12 | ||
└─TableScan_12 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo | ||
explain select sum(a) over(partition by a order by b rows unbounded preceding) from t; | ||
id count task operator info | ||
Projection_7 10000.00 root sum(a) over(partition by a order by b rows unbounded preceding) | ||
└─Window_8 10000.00 root sum(cast(test.t.a)) over(partition by test.t.a order by test.t.b asc rows between unbounded preceding and current row) | ||
└─Sort_14 10000.00 root test.t.a:asc, test.t.b:asc | ||
└─TableReader_13 10000.00 root data:TableScan_12 | ||
└─TableScan_12 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo | ||
explain select sum(a) over(partition by a order by b rows between 1 preceding and 1 following) from t; | ||
id count task operator info | ||
Projection_7 10000.00 root sum(a) over(partition by a order by b rows between 1 preceding and 1 following) | ||
└─Window_8 10000.00 root sum(cast(test.t.a)) over(partition by test.t.a order by test.t.b asc rows between 1 preceding and 1 following) | ||
└─Sort_14 10000.00 root test.t.a:asc, test.t.b:asc | ||
└─TableReader_13 10000.00 root data:TableScan_12 | ||
└─TableScan_12 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo | ||
explain select sum(a) over(partition by a order by b range between 1 preceding and 1 following) from t; | ||
id count task operator info | ||
Projection_7 10000.00 root sum(a) over(partition by a order by b range between 1 preceding and 1 following) | ||
└─Window_8 10000.00 root sum(cast(test.t.a)) over(partition by test.t.a order by test.t.b asc range between 1 preceding and 1 following) | ||
└─Sort_14 10000.00 root test.t.a:asc, test.t.b:asc | ||
└─TableReader_13 10000.00 root data:TableScan_12 | ||
└─TableScan_12 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo | ||
explain select sum(a) over(partition by a order by c range between interval '2:30' minute_second preceding and interval '2:30' minute_second following) from t; | ||
id count task operator info | ||
Projection_7 10000.00 root sum(a) over(partition by a order by c range between interval '2:30' minute_second preceding and interval '2:30' minute_second following) | ||
└─Window_8 10000.00 root sum(cast(test.t.a)) over(partition by test.t.a order by test.t.c asc range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following) | ||
└─Sort_14 10000.00 root test.t.a:asc, test.t.c:asc | ||
└─TableReader_13 10000.00 root data:TableScan_12 | ||
└─TableScan_12 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use test; | ||
drop table if exists t; | ||
create table t (a int, b int, c timestamp, index idx(a)); | ||
set @@tidb_enable_window_function = 1; | ||
explain select sum(a) over() from t; | ||
explain select sum(a) over(partition by a) from t; | ||
explain select sum(a) over(partition by a order by b) from t; | ||
explain select sum(a) over(partition by a order by b rows unbounded preceding) from t; | ||
explain select sum(a) over(partition by a order by b rows between 1 preceding and 1 following) from t; | ||
explain select sum(a) over(partition by a order by b range between 1 preceding and 1 following) from t; | ||
explain select sum(a) over(partition by a order by c range between interval '2:30' minute_second preceding and interval '2:30' minute_second following) from t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters