Skip to content

Commit ec8b9ea

Browse files
committed
[PostgreSQL] Over clause support
1 parent d260847 commit ec8b9ea

File tree

5 files changed

+9540
-8543
lines changed

5 files changed

+9540
-8543
lines changed

Diff for: headless-services/commons/jpql/grammars/PostgreSqlParser.g4

+20-6
Original file line numberDiff line numberDiff line change
@@ -1384,15 +1384,29 @@ frame_clause
13841384
: (RANGE | ROWS) frame_start
13851385
| (RANGE | ROWS) BETWEEN frame_start AND frame_end
13861386
;
1387-
1387+
1388+
window_definition_list
1389+
: window_definition (COMMA window_definition)*
1390+
;
1391+
13881392
window_definition
1389-
: window_name
1390-
| PARTITION BY expr (COMMA expr)*
1391-
| order_by_clause
1393+
: window_name AS window_specification
13921394
;
13931395

13941396
window_clause
1395-
: WINDOW window_name AS OPEN_PAREN window_definition CLOSE_PAREN
1397+
: WINDOW window_definition_list
1398+
;
1399+
1400+
window_specification
1401+
: OPEN_PAREN window_name? partition_clause? order_by_clause? frame_clause? CLOSE_PAREN
1402+
;
1403+
1404+
partition_clause
1405+
: PARTITION BY expr (COMMA expr)*
1406+
;
1407+
1408+
over_clause
1409+
: OVER (window_specification | window_name)
13961410
;
13971411

13981412
combine_clause
@@ -1482,7 +1496,7 @@ expr
14821496
| expr op=IS (bool_expr | NULL | NOT NULL)
14831497
| expr IS NOT? DISTINCT FROM expr
14841498
| op=(NOT | ALL ) expr
1485-
| func_call
1499+
| func_call over_clause?
14861500
| identifier
14871501
| CAST OPEN_PAREN expr AS data_type CLOSE_PAREN
14881502
| correlation_name DOT column_name

0 commit comments

Comments
 (0)