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

Fix SQL grammar issues #108

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions syncode/parsers/grammars/sql_grammar.lark
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ JOIN_DIRECTION: "FULL"i | "LEFT"i | "RIGHT"i
| "RANK"i "(" ")" window_form -> rank_expression
| "DENSE_RANK"i "(" ")" window_form -> dense_rank_expression
| "COALESCE"i "(" [(expression_math ",")*] expression_math ")" -> coalesce_expression
| subquery -> subquery_expression

window_form: "OVER"i "(" ["PARTITION"i "BY"i (partition_by ",")* partition_by] ["ORDER"i "BY"i (order ",")* order [ row_range_clause ] ] ")"

Expand Down
10 changes: 9 additions & 1 deletion tests/test_grammar_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ def test_sql_parser3(self):
r = inc_parser.get_acceptable_next_terminals(partial_code)
assert r.remainder == 'NOT'
assert r.remainder_state == RemainderState.MAYBE_COMPLETE


def test_sql_parser4(self):
inc_parser.reset()
# partial_code = "SELECT first_name, age FROM Customers where Customers.age = (select MAX(age) from Customers)"
partial_code = "SELECT * FROM cars_data WHERE weight < (SELECT"
r = inc_parser.get_acceptable_next_terminals(partial_code)
assert r.remainder == 'SELECT'
assert r.remainder_state == RemainderState.MAYBE_COMPLETE

Loading