-
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
Ports tests from partiql-lang-kotlin
's PTS
#38
Conversation
Build failing due to ISL validation check over typed nulls, which for some reason causes a stack overflow error. Still investigating before marking PR as ready for review. |
Previous validation failure is due to amazon-ion/ion-schema-kotlin#169. Updated the required, nullable field to |
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 of the diff is from these ported PTS files:
select-mysql.ion
- environment specified in lang-kotlin
- tests defined in lang-kotlin
select-postgresql.ion
- environment defined in lang-kotlin
- tests defined in lang-kotlin
@@ -0,0 +1,3 @@ | |||
Directory contains tests that are not formally part of the PartiQL specification or SQL-92. These tests may contain |
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.
Decided to create this directory to hold tests that aren't part of the PartiQL or SQL-92 spec. Currently contains
- Functions that are part of
partiql-lang-kotlin
but not part of the spec. Decided on what's in 'extended' from this doc: https://github.com/partiql/partiql-docs/blob/main/docs/builtins-sql.adoc - Numeric semantics that are operation and implementation-specific. Deferred on the modeling until Decide on modeling of different numeric semantics in test suite #39 is resolved
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.
In the future, this could be a good directory to also put tests with ambiguous behavior that will be sorted out in the future.
@@ -122,7 +122,7 @@ type::{ | |||
type: struct, | |||
fields: { | |||
result: { type: symbol, valid_values: [EvaluationSuccess], occurs: required }, | |||
output: nullable::{ occurs: required }, | |||
output: { type: $any, occurs: required }, |
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.
Change was due to a stack overflow bug (existing issue: amazon-ion/ion-schema-kotlin#169) when validating typed nulls.
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.
So you mean if we didn't have the bug we would go with nullable
?
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, if the ion-schema-kotlin
bug mentioned in amazon-ion/ion-schema-kotlin#169 didn't exist, then we could go with the previous approach (i.e. nullable::{ occurs: required }
), which imo was more understandable. The change here is an equivalent way to specify a nullable, required field.
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.
In that case can we add a TODO
with reference to the bug? last time I checked we didn't have issue with adding comments in .ion
files but not sure about .isl
.
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.
@@ -61,3 +61,79 @@ | |||
result: SyntaxFail | |||
}, | |||
} | |||
|
|||
'select-star'::[ |
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.
PTS didn't distinguish between different error categories, so ported some tests from PTS that were syntax errors. From my read of the SQL-92 BNF, select star with other select list items is not permitted. PostgreSQL does allow some of the following cases, while others like MySQL gives a syntax error. From a discussion with Almann, we couldn't think of a use case where a user would want select star with other projection items, so it may be something we want to disallow in a future spec RFC.
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.
Does it makes sense to put these tests under partiql
namespace to re-iterate the fact that they are not necessarily SQL conformed.
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, it would probably make some sense to indicate that these tests are not necessarily SQL-conformant. I'll wrap these tests in a partiql
namespace and add a comment in the next commit.
], | ||
] | ||
|
||
invalid_function_args::[ |
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.
Function calls with no schema present in STRICT/ERROR typing mode give errors with mistyped function arguments and return MISSING
in PERMISSIVE/COERCE mode. But since a literal is provided in these tests, a static analysis pass could determine that the query has a mistyped argument and give an error.
From discussion with Almann, we determined that these cases (i.e. mistyped function args with statically-knowable types) should "fail-fast" and not wait till evaluation time. Similar reasoning applies to the other static-analysis tests ported in this PR. This type of static-time error will probably necessitate some RFC.
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.
Are you saying the StaticAnalysisFail
symbol may be a richer element, and the RFC will define this?
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.
Not sure what you meant by a "richer element". Could you clarify?
The tests in the fail/static-analysis
directory define tests that will fail at some stage of static analysis or type-checking. These particular tests with invalid number of arguments and invalid function arguments (known at static-time since they involve literals) are classified as static analysis fail tests in this PR. What I meant by needing an RFC was that this particular behavior isn't part of the current PartiQL spec and we should add an RFC to define the static analysis fail behavior.
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 can cut a partiql-spec
issue for static-analysis failures if the above makes sense.
} | ||
] | ||
|
||
'repeated-field-on-struct'::[ |
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.
The COERCE/permissive mode behavior is implementation-dependent as per section 4 of spec. Hence why only the ERROR/strict mode behavior tests are defined.
}, | ||
{ | ||
name:"More than one character given for ESCAPE", | ||
statement:"SELECT * FROM `[true]` WHERE 'a' LIKE 'a' ESCAPE 'aa'", |
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 was the somewhat ambiguous case for an invalid function argument that's not due to typing error -- hence why the behavior is the same for both eval modes. PostgreSQL don't do a "smarter" static check for the escape pattern of a LIKE
operator but gives an evaluator error.
], | ||
] | ||
|
||
invalid_function_args::[ |
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.
Are you saying the StaticAnalysisFail
symbol may be a richer element, and the RFC will define this?
Co-authored-by: R. C. Howell <[email protected]>
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 not sure how we can review this PR effectively; I think this is one of those PRs that we need to skip the thorough review and lean on asserting its correctness by application i.e. relying on test execution in the Kotlin runner—considering this, I did a cursory review and left couple comments.
@@ -61,3 +61,79 @@ | |||
result: SyntaxFail | |||
}, | |||
} | |||
|
|||
'select-star'::[ |
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.
Does it makes sense to put these tests under partiql
namespace to re-iterate the fact that they are not necessarily SQL conformed.
@@ -122,7 +122,7 @@ type::{ | |||
type: struct, | |||
fields: { | |||
result: { type: symbol, valid_values: [EvaluationSuccess], occurs: required }, | |||
output: nullable::{ occurs: required }, | |||
output: { type: $any, occurs: required }, |
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.
So you mean if we didn't have the bug we would go with nullable
?
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 not sure how we can review this PR effectively; I think this is one of those PRs that we need to skip the thorough review and lean on asserting its correctness by application i.e. relying on test execution in the Kotlin runner—considering this, I did a cursory review and left couple comments.
Yeah, I agree given the number of tests being ported. Hopefully running the ported tests through the Kotlin test runner can give more confidence that they were ported correctly and had the spec-conformant behavior properly defined to begin with. Working on the PartiQL Rust implementation should also help us identify potential bugs in the tests.
@@ -122,7 +122,7 @@ type::{ | |||
type: struct, | |||
fields: { | |||
result: { type: symbol, valid_values: [EvaluationSuccess], occurs: required }, | |||
output: nullable::{ occurs: required }, | |||
output: { type: $any, occurs: required }, |
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, if the ion-schema-kotlin
bug mentioned in amazon-ion/ion-schema-kotlin#169 didn't exist, then we could go with the previous approach (i.e. nullable::{ occurs: required }
), which imo was more understandable. The change here is an equivalent way to specify a nullable, required field.
@@ -61,3 +61,79 @@ | |||
result: SyntaxFail | |||
}, | |||
} | |||
|
|||
'select-star'::[ |
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, it would probably make some sense to indicate that these tests are not necessarily SQL-conformant. I'll wrap these tests in a partiql
namespace and add a comment in the next commit.
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.
Thank you for putting together this change; I understand it hasn't been easy.
Closes #7.
Ports tests from
partiql-lang-kotlin
PTS (https://github.com/partiql/partiql-lang-kotlin/tree/main/test/partiql-testscript/pts).Associated Kotlin test runner PR: partiql/partiql-lang-kotlin#829 with an updated skip list.
Tests were ported using a script similar to what was used in porting the
EvaluatorTestSuite.kt
tests frompartiql-lang-kotlin
(#28). This was slightly trickier than the previous PR due to the number of tests being ported and because many of those tests did not have a PERMISSIVE/COERCE evaluation mode behavior defined.TODO:
undecided
directoryBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.