-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nom-sql: Fix GROUP BY parsing for Postgres
Postgres allows you to identify columns in a `GROUP BY` clause by their ordinal position in the column list of a query; however our parser was written with the assumption that this was only possible for MySQL. This commit updates our parser to support column indices in the `GROUP BY` clause for both MySQL *and* Postgres. Release-Note-Core: Fixed an issue where Readyset was not correctly handling entries in the `GROUP BY` clause that identified columns by their position in the column list of the query Change-Id: Ib84789e903ca8b7137b780ee1e8e791439dab1ae Reviewed-on: https://gerrit.readyset.name/c/readyset/+/6980 Tested-by: Buildkite CI Reviewed-by: Luke Osborne <[email protected]>
- Loading branch information
Showing
2 changed files
with
63 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
statement ok | ||
create table t ( | ||
id int, | ||
val int | ||
); | ||
|
||
statement ok | ||
insert into t (id, val) values | ||
(1, 1), | ||
(2, 1), | ||
(3, 2), | ||
(4, 2); | ||
|
||
query II nosort | ||
select id, val from t order by 1 | ||
---- | ||
1 | ||
1 | ||
2 | ||
1 | ||
3 | ||
2 | ||
4 | ||
2 | ||
|
||
|
||
query II nosort | ||
select val, id from t order by 2 | ||
---- | ||
1 | ||
1 | ||
1 | ||
2 | ||
2 | ||
3 | ||
2 | ||
4 | ||
|
||
query II rowsort | ||
select max(id), val from t group by 2 | ||
---- | ||
2 | ||
1 | ||
4 | ||
2 | ||
|
||
|
||
query II nosort | ||
select max(id), val from t group by 2 order by 2 desc | ||
---- | ||
4 | ||
2 | ||
2 | ||
1 |
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