Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more tests for lead/lag #5792

Merged
merged 3 commits into from
Sep 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
+---+------+------+-----------+----------------------------------------------+
Comment on lines +265 to +277
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is UInt64 overflow, but tidb and tiflash behave the same :)
And the max value of mysql8.0 is 9223372036854775807.

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