Skip to content

Commit

Permalink
feat: Support OFFSET for PostgreSQL (#71)
Browse files Browse the repository at this point in the history
* refactor: remove excess condition

* feat: support offset for postgesql

* fix: remove offsetClauseLocation which broke tests

* fix: fix pipeline tests

* docs: actualise license annotations
  • Loading branch information
viladimiru authored Aug 9, 2023
1 parent 38a8c1b commit 7834158
Show file tree
Hide file tree
Showing 11 changed files with 9,934 additions and 527 deletions.
22 changes: 8 additions & 14 deletions src/parsing/parsers/postgresql/jison/select/limit_clause.jison
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
// Licensed to Cloudera, Inc. under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. Cloudera, Inc. licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
// Copyright 2023 YANDEX LLC
//
// http://www.apache.org/licenses/LICENSE-2.0
// Licensed under the Apache License, Version 2.0 (the "License")
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.

OptionalLimitClause
:
Expand All @@ -21,7 +16,6 @@ OptionalLimitClause

LimitClause
: 'LIMIT' UnsignedNumericLiteral
| 'LIMIT' 'VARIABLE_REFERENCE'
;

LimitClause_EDIT
Expand Down
26 changes: 26 additions & 0 deletions src/parsing/parsers/postgresql/jison/select/offset_clause.jison
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2023 YANDEX LLC
//
// Licensed under the Apache License, Version 2.0 (the "License")
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.

OptionalOffsetClause
:
| OffsetClause
;

OffsetClause
: 'OFFSET' ValueExpression
;

OffsetClause_EDIT
: 'OFFSET' 'CURSOR'
{
parser.suggestFunctions({ types: ['BIGINT'] });
}
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"namePrefix": "should suggest OFFSET",
"beforeCursor": "SELECT * FROM testTable LIMIT 100 ",
"afterCursor": "",
"noErrors": true,
"containsKeywords": ["OFFSET"],
"expectedResult": {
"lowerCase": false
}
},
{
"namePrefix": "should not throw errors",
"beforeCursor": "SELECT * FROM testTable OFFSET 100;",
"afterCursor": "",
"noErrors": true,
"containsKeywords": ["SELECT"],
"expectedResult": {
"lowerCase": false
}
},
{
"namePrefix": "should not throw errors",
"beforeCursor": "SELECT * FROM testTable LIMIT 1 OFFSET 12; ",
"afterCursor": "",
"noErrors": true,
"containsKeywords": ["SELECT"],
"expectedResult": {
"lowerCase": false
}
},
{
"namePrefix": "should not throw errors",
"beforeCursor": "SELECT * FROM testTable LIMIT 1; ",
"afterCursor": "",
"noErrors": true,
"containsKeywords": ["SELECT"],
"expectedResult": {
"lowerCase": false
}
}
]
Loading

0 comments on commit 7834158

Please sign in to comment.