Skip to content

Commit

Permalink
add more tests for lead/lag (#5792)
Browse files Browse the repository at this point in the history
ref #5579
  • Loading branch information
SeaRise authored Sep 7, 2022
1 parent c9ce318 commit 51d54e1
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/fullstack-test/expr/lead_lag.test
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,51 @@ mysql> set @@tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp=1; sele
| NULL |
+------------------------------------------------------+

## test offset
mysql> set @@tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp=1; select 'a', lead(value_str, -1) over w from test.test_str window w as(PARTITION BY part ORDER BY orde) order by orde;
{#REGEXP}.*You have an error in your SQL syntax.*
mysql> set @@tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp=1; select 'a', lead(value_str, 0) over w from test.test_str window w as(PARTITION BY part ORDER BY orde) order by orde;
+---+---------------------------+
| a | lead(value_str, 0) over w |
+---+---------------------------+
| a | 1 |
| a | |
| a | 3 |
| a | 4 |
| a | 5 |
| a | NULL |
| a | 7 |
| a | 8 |
+---+---------------------------+
mysql> set @@tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp=1; select 'a', lead(value_str, 1) over w from test.test_str window w as(PARTITION BY part ORDER BY orde) order by orde;
+---+---------------------------+
| a | lead(value_str, 1) over w |
+---+---------------------------+
| a | |
| a | 3 |
| a | 4 |
| a | NULL |
| a | NULL |
| a | 7 |
| a | 8 |
| a | NULL |
+---+---------------------------+
mysql> set @@tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp=1; select 'a', orde, part, value_str, lead(value_str, 18446744073709551615) over w from test.test_str window w as(PARTITION BY part ORDER BY orde) order by orde;
+---+------+------+-----------+----------------------------------------------+
| a | orde | part | value_str | lead(value_str, 18446744073709551615) over w |
+---+------+------+-----------+----------------------------------------------+
| a | 1 | 1 | 1 | NULL |
| a | 2 | 1 | | 1 |
| a | 3 | 1 | 3 | |
| a | 4 | 1 | 4 | 3 |
| a | 5 | 2 | 5 | NULL |
| a | 6 | 2 | NULL | 5 |
| a | 7 | 2 | 7 | NULL |
| a | 8 | 2 | 8 | 7 |
+---+------+------+-----------+----------------------------------------------+
mysql> set @@tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp=1; select 'a', lead(value_str, 18446744073709551616) over w from test.test_str window w as(PARTITION BY part ORDER BY orde) order by orde;
{#REGEXP}.*Incorrect arguments.*

mysql> drop table if exists test.test_str
mysql> drop table if exists test.test_int
mysql> drop table if exists test.test_float
Expand Down

0 comments on commit 51d54e1

Please sign in to comment.