-
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 more parse tests from partiql-lang-kotlin
; add omitted tests list
#11
Conversation
Unsure if should be included: | ||
- `expectedCastAsIntArity`, `expectedCastAsRealArity` -- type supplied with parameter; not sure is parse error | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L172-L204 | ||
- `expectedUnsupportedLiteralsGroupBy` -- not part of the PartiQL spec; SQL92 says group by must use a column name | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L417-L429 | ||
- also for `groupByOrdinal`, `groupByOutOfBoundsOrdinal`, `groupByBadOrdinal`, `groupByStringConstantOrdinal` https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L953-L1007 | ||
- `idIsNotGroupMissing` -- type surrounded by parens | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L782-L794 | ||
- `castToVarCharToTooBigLength`, `castToDecimalToTooBigLength_1`, `castToDecimalToTooBigLength_2`, `castToNumericToTooBigLength_1`, `castToNumericToTooBigLength_2` -- not quite a parse error; more so a semantic error | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L220-L288 | ||
- Similarly for `castNegativeArg` | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L883-L895 | ||
- `offsetBeforeLimit` -- not part of spec; postgresql allows; kotlin impl+mysql+sqlite don't allow; included as test for now | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1221-L1233 | ||
- date_add/date_diff tests - date_add and date_diff aren't part of specs | ||
- https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/syntax/SqlParserTest.kt#L957-L1036 | ||
- https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1743-L1858 | ||
- `countExpressionStar` | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1966-L1978 | ||
- `*` and path `*` with other select list items | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1903-L1936 |
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.
Would be good to get another pair of eyes on this file, in particular the "Unsure if should be included" section for tests I was unsure to include (i.e. tests not part of the PartiQL/SQL spec but are defined as errors by the Kotlin implementation).
The "Tests excluded" (L3-33) may also be relevant to look at. These were tests that were
- not in spec but likely will be sometime in the future such as DML, DDL, EXEC, LET, etc
- tests not really parser related (e.g. performance, default parsed AST, custom type)
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.
Rendered file link updated following 26a5720 commit.
partiql-test-data/fail/parser/primitives/aggregate-function-call.ion
Outdated
Show resolved
Hide resolved
|
||
parse::{ | ||
name: "double at operator on identifier", | ||
statement: "@ @a", |
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.
Is the space between the @
intended?
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, it's intentional. Test taken from here. Would another test without the space be helpful to add?
partiql-test-data/fail/parser/primitives/operators/at-operator.ion
Outdated
Show resolved
Hide resolved
partiql-test-data/fail/parser/primitives/operators/is-operator.ion
Outdated
Show resolved
Hide resolved
}, | ||
parse::{ | ||
name: "TRIM with TRAILING missing FROM", | ||
statement: "TRIM(trailing '')", |
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.
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.
I'm also unsure of the utility of having this test as a negative test. Tested with MySQL and SQLite, which resulted in errors.
For now, deleted the test from fail/parse
and added this test to the "unsure" section of partiql-lang-kotlin-omitted-tests.md
.
partiql-lang-kotlin-omitted-tests.md
Outdated
- `expectedSelectMissingFrom` -- not part of the PartiQL spec | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L403-L415 |
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.
This is just SELECT a FROM data
which has had a 'typo' dropping the FROM
, right?
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, the FROM
was missing from that query. Looking at that example again, it should probably be a parse error. I'll move it to the parse error tests in the next commit.
}, | ||
parse::{ | ||
name: "TRIM with BOTH missing FROM", | ||
statement: "TRIM(BOTH 'test')", |
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.
This is implementation-dependent as to whether it's a 'parse' error or a type/semantic error
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.
Agreed. I ended up moving most of the tests in this file to fail/semantic
.
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.
Most (though not all) of the fail
tests added here seem to be legitimate cases where an error should be thrown. However, depending on implementation, it may not error during parse, but perhaps later in compile (type check for example).
Potentially semantic failures (e.g. not just unbalanced parens and missing clauses) should likely be moved to a set of "semantic" failure tests. Some implementations may fail them in the parse if they strictly implement SQL standard's EBNF, but some may fail them via other means.
- https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1743-L1858 | ||
- `countExpressionStar` | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1966-L1978 | ||
- `*` and path `*` with other select list items |
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.
Is that because you consider them as a semantic error?
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.
I'm unsure it would be an error to begin with. The Kotlin implementation doesn't allow using *
in a select list with other items.
I can't find a section of the PartiQL or SQL92 spec that forbids this. PostgreSQL + SQLite allow those cases. MySQL seems to only allow *
as the first item in the select list (can have other columns following the *).
For now, leaving in the "unsure" section, but open to moving if there's something I missed from the spec.
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.
Thanks for the reviews!
26a5720 makes the following changes based on the feedback:
- Creates a
semantic
directory underpartiql-test-data/fail
for tests related to semantic/type-checking errors that aren't strictly parsing errors - Moves some parse error tests w/ the "call" syntax to
semantic
directory - Moves some
JOIN
tests that were misclassified asfail
topass
- Updates some of the test descriptions in
partiql-lang-kotlin-omitted-tests.md
- Updates some
JOIN
parse error tests to use a more "error-explicit" name
partiql-lang-kotlin-omitted-tests.md
Outdated
- `expectedSelectMissingFrom` -- not part of the PartiQL spec | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L403-L415 |
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, the FROM
was missing from that query. Looking at that example again, it should probably be a parse error. I'll move it to the parse error tests in the next commit.
- https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1743-L1858 | ||
- `countExpressionStar` | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1966-L1978 | ||
- `*` and path `*` with other select list items |
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.
I'm unsure it would be an error to begin with. The Kotlin implementation doesn't allow using *
in a select list with other items.
I can't find a section of the PartiQL or SQL92 spec that forbids this. PostgreSQL + SQLite allow those cases. MySQL seems to only allow *
as the first item in the select list (can have other columns following the *).
For now, leaving in the "unsure" section, but open to moving if there's something I missed from the spec.
|
||
parse::{ | ||
name: "double at operator on identifier", | ||
statement: "@ @a", |
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, it's intentional. Test taken from here. Would another test without the space be helpful to add?
partiql-test-data/fail/parser/primitives/operators/at-operator.ion
Outdated
Show resolved
Hide resolved
@@ -29,3 +29,129 @@ parse::{ | |||
result: ParseOk | |||
} | |||
} | |||
|
|||
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.
These tests from L33-157 were mistakenly marked as fail
in the first commit. Moved to pass
in 26a5720.
Unsure if should be included: | ||
- `expectedCastAsIntArity`, `expectedCastAsRealArity` -- type supplied with parameter; not sure is parse error | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L172-L204 | ||
- `expectedUnsupportedLiteralsGroupBy` -- not part of the PartiQL spec; SQL92 says group by must use a column name | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L417-L429 | ||
- also for `groupByOrdinal`, `groupByOutOfBoundsOrdinal`, `groupByBadOrdinal`, `groupByStringConstantOrdinal` https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L953-L1007 | ||
- `idIsNotGroupMissing` -- type surrounded by parens | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L782-L794 | ||
- `castToVarCharToTooBigLength`, `castToDecimalToTooBigLength_1`, `castToDecimalToTooBigLength_2`, `castToNumericToTooBigLength_1`, `castToNumericToTooBigLength_2` -- not quite a parse error; more so a semantic error | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L220-L288 | ||
- Similarly for `castNegativeArg` | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L883-L895 | ||
- `offsetBeforeLimit` -- not part of spec; postgresql allows; kotlin impl+mysql+sqlite don't allow; included as test for now | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1221-L1233 | ||
- date_add/date_diff tests - date_add and date_diff aren't part of specs | ||
- https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/syntax/SqlParserTest.kt#L957-L1036 | ||
- https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1743-L1858 | ||
- `countExpressionStar` | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1966-L1978 | ||
- `*` and path `*` with other select list items | ||
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1903-L1936 |
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.
Rendered file link updated following 26a5720 commit.
@@ -0,0 +1,111 @@ | |||
trim::[ | |||
semantic::{ |
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.
Nit.: Just occurred to me and might be applicable to other files as well—could all these tests be under one semantic
namespace?
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.
Could you clarify "under one semantic
namespace? Is the suggestion to wrap all the tests in a top-level namespace called semantic
? Such as
semantic::[
trim::[
semantic::{
name: "TRIM too many arguments",
statement: "TRIM(BOTH ' ' FROM 'test' 2)",
assert: {
result: SemanticError
},
},
... // other trim tests
]
extract::[
... // extract tests
]
... // other tests
]
The most recent commit, 26a5720, added the semantic
test annotation (different from parse
or eval
). I'm not too sure what having a semantic
namespace provides.
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.
Sorry, perhaps I should've been more clear; I think the ambiguity is because I'm still trying to wrap my head around the test model. The motivation for my comment was to have the tests in such a way that we can avoid repeating the annotation (in this case semantic
). This is not a blocker and I know requires more changes in case it makes sense. So feel free to merge and we can discuss further 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.
Ah, I get what you mean. The test model is still subject to change as we continue defining tests, especially as we define the formal schema and verification in #3. Regarding the test category annotation, I'd say the primary benefits are that
- the parsing of the test cases by the test runner doesn't need to keep track of the test category from an outer namespace or file path
- e.g.
partiql-lang-rust
parsing of test case: https://github.com/partiql/partiql-lang-rust/blob/5acb46609fc5e9e57494d77b137c394fe7c60622/partiql-conformance-test-generator/src/lib.rs#L111-L141
- e.g.
- could allow for mixing different test categories within a file/namespace
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.
Yep I totally get it, the model is to be finalized. On the same note, I don't see the point of tracking the test category via the annotation when we have the Assertion. Basically, if there is a ParseError
, I think it already gives enough information about the failure.
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.
Yeah there seems to be some unnecessary redundancy involving the assertion's result
and the category annotation. The annotation only provides the test category, while the assertion result
provides the test category and the expected result (e.g. ok or error). Some further discussion will be needed to see if this test category annotation is necessary.
Part of #5.
Ports 151 tests from
partiql-lang-kotlin
(total is now 314). Tests taken fromThis PR also adds a file to keep track of some tests omitted from the Kotlin implementation's test suite:
partiql-lang-kotlin-omitted-tests.md
. I may need a reviewer to check over the tests I'm unsure about for possible inclusion and check the tests excluded (mostly due to not being part of the PartiQL/SQL spec).Decided to add the DATE and TIME tests in an upcoming PR since there were a lot of tests involving the constructors.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.