-
Notifications
You must be signed in to change notification settings - Fork 1
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 spec-defined SqlParserTest tests; fix ParseError symbol #10
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
39 changes: 39 additions & 0 deletions
39
partiql-test-data/pass/parser/primitives/aggregate-function-call.ion
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,39 @@ | ||
parse::{ | ||
name: "COUNT aggregate function call", | ||
statement: "COUNT(a)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "SUM DISTINCT aggregate function call", | ||
statement: "SUM(DISTINCT a)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "COUNT star aggregate function call", | ||
statement: "COUNT(*)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "COUNT DISTINCT aggregate function call", | ||
statement: "COUNT(DISTINCT a)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} |
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,137 @@ | ||
parse::{ | ||
name: "call empty", | ||
statement: "foobar()", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "call one argument", | ||
statement: "foobar(1)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "call two arguments", | ||
statement: "foobar(1, 2)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "call with multiple", | ||
statement: "foobar(1, 2, 3)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "call with case insensitive function name", | ||
statement: "mY_fUnCtIoN(a)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
|
||
'substring'::[ | ||
parse::{ | ||
name: "call SUBSTRING sql92 syntax", | ||
statement: "substring('test' from 100)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "call SUBSTRING sql92 syntax with length", | ||
statement: "substring('test' from 100 for 50)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "call SUBSTRING normal syntax", | ||
statement: "substring('test', 100)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "call SUBSTRING normal syntax with length", | ||
statement: "substring('test', 100, 50)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
] | ||
|
||
'trim'::[ | ||
parse::{ | ||
name: "call TRIM single argument", | ||
statement: "trim('test')", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "call TRIM two arguments default specification", | ||
statement: "trim(' ' from 'test')", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "call TRIM two arguments using BOTH", | ||
statement: "trim(both from 'test')", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "call TRIM two arguments using LEADING", | ||
statement: "trim(leading from 'test')", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "call TRIM two arguments using TRAILING", | ||
statement: "trim(trailing from 'test')", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
] |
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,59 @@ | ||
'searched-case'::[ | ||
parse::{ | ||
name: "searched CASE single WHEN no ELSE", | ||
statement: "CASE WHEN name = 'zoe' THEN 1 END", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "searched CASE single WHEN with ELSE", | ||
statement: "CASE WHEN name = 'zoe' THEN 1 ELSE 0 END", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "searched CASE multi WHEN with ELSE", | ||
statement: "CASE WHEN name = 'zoe' THEN 1 WHEN name > 'kumo' THEN 2 ELSE 0 END", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
] | ||
|
||
'simple-case'::[ | ||
parse::{ | ||
name: "simple CASE single WHEN no ELSE", | ||
statement: "CASE name WHEN 'zoe' THEN 1 END", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "simple CASE single WHEN with ELSE", | ||
statement: "CASE name WHEN 'zoe' THEN 1 ELSE 0 END", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "simple CASE multi WHEN with ELSE ", | ||
statement: "CASE name WHEN 'zoe' THEN 1 WHEN 'kumo' THEN 2 WHEN 'mary' THEN 3 ELSE 0 END", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
] |
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,79 @@ | ||
parse::{ | ||
name: "CAST as VARCHAR", | ||
statement: "CAST(5 AS VARCHAR)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "CAST as VARCHAR with length", | ||
statement: "CAST(5 AS VARCHAR(5))", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "CAST as DECIMAL", | ||
statement: "CAST(a AS DECIMAL)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "CAST as DECIMAL scale only", | ||
statement: "CAST(a AS DECIMAL(1))", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "CAST as DECIMAL scale and precision", | ||
statement: "CAST(a AS DECIMAL(1, 2))", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "CAST as NUMERIC", | ||
statement: "CAST(a AS NUMERIC)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "CAST as NUMERIC scale only", | ||
statement: "CAST(a AS NUMERIC(1))", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
|
||
parse::{ | ||
name: "CAST as NUMERIC scale and precision", | ||
statement: "CAST(a AS NUMERIC(1, 2))", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} |
41 changes: 41 additions & 0 deletions
41
partiql-test-data/pass/parser/primitives/container-constructors.ion
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,41 @@ | ||
'row-value-constructor'::[ | ||
parse::{ | ||
name: "row value constructor with simple expressions", | ||
statement: "(1, 2, 3, 4)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "row value constructor with row value constructors", | ||
statement: "((1, 2), (3, 4))", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
] | ||
|
||
'table-value-constructor'::[ | ||
parse::{ | ||
name: "table value constructor with row value constructors", | ||
statement: "VALUES (1, 2), (3, 4)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
}, | ||
parse::{ | ||
name: "table value constructor with singleton row value constructors", | ||
statement: "VALUES (1), (2), (3)", | ||
assert: [ | ||
{ | ||
result: ParseOk | ||
}, | ||
] | ||
} | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this and other lines that it applies: by normal do we mean PartiQL syntax? If so, how about changing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more about this, should we consider porting the sql92, etc. to namespaces?
E.g.:
'sql92'::[ parse::{ ... } ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, "normal" referred to the PartiQL function call syntax. I can change to use a more specific term.
Good suggestion. I will enclose the sql92-related syntax in its own namespace.