Skip to content

Commit

Permalink
planner/window: check window args first before checking window specs …
Browse files Browse the repository at this point in the history
…fix uts (pingcap#11008)
  • Loading branch information
gaoxingliang authored and root committed Aug 10, 2019
1 parent ee3619c commit f94a75b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 35 deletions.
3 changes: 1 addition & 2 deletions cmd/explaintest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,9 @@ func (t *tester) execute(query query) error {
gotBuf := t.buf.Bytes()[offset:]

buf := make([]byte, t.buf.Len()-offset)
if _, err = t.resultFD.ReadAt(buf, int64(offset)); err != nil {
if _, err = t.resultFD.ReadAt(buf, int64(offset)); !(err == nil || err == io.EOF) {
return errors.Trace(errors.Errorf("run \"%v\" at line %d err, we got \n%s\nbut read result err %s", st.Text(), query.Line, gotBuf, err))
}

if !bytes.Equal(gotBuf, buf) {
return errors.Trace(errors.Errorf("run \"%v\" at line %d err, we need:\n%s\nbut got:\n%s\n", query.Query, query.Line, buf, gotBuf))
}
Expand Down
66 changes: 33 additions & 33 deletions cmd/explaintest/r/window_function.result
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,48 @@ 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
Projection_8 10000.00 root sum(a) over()
└─Window_9 10000.00 root sum(cast(test.t.a)) over()
└─TableReader_11 10000.00 root data:TableScan_10
└─TableScan_10 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_10 10000.00 root index:IndexScan_9
└─IndexScan_9 10000.00 cop table:t, index:a, range:[NULL,+inf], keep order:true, stats:pseudo
Projection_8 10000.00 root sum(a) over(partition by a)
└─Window_9 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 range between unbounded preceding and current row)
└─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
Projection_8 10000.00 root sum(a) over(partition by a order by b)
└─Window_9 10000.00 root sum(cast(test.t.a)) over(partition by test.t.a order by test.t.b asc range between unbounded preceding and current row)
└─Sort_12 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_11 10000.00 root data:TableScan_10
└─TableScan_10 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_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
Projection_8 10000.00 root sum(a) over(partition by a order by b rows unbounded preceding)
└─Window_9 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_12 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_11 10000.00 root data:TableScan_10
└─TableScan_10 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_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
Projection_8 10000.00 root sum(a) over(partition by a order by b rows between 1 preceding and 1 following)
└─Window_9 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_12 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_11 10000.00 root data:TableScan_10
└─TableScan_10 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_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
Projection_8 10000.00 root sum(a) over(partition by a order by b range between 1 preceding and 1 following)
└─Window_9 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_12 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_11 10000.00 root data:TableScan_10
└─TableScan_10 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_11 10000.00 root test.t.a:asc, test.t.c:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
Projection_8 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_9 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_12 10000.00 root test.t.a:asc, test.t.c:asc
└─TableReader_11 10000.00 root data:TableScan_10
└─TableScan_10 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo

0 comments on commit f94a75b

Please sign in to comment.