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

Add more parse tests from partiql-lang-kotlin; add omitted tests list #11

Merged
merged 2 commits into from
May 16, 2022

Conversation

alancai98
Copy link
Member

Part of #5.

Ports 151 tests from partiql-lang-kotlin (total is now 314). Tests taken from

This 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.

@alancai98 alancai98 added this to the M1: Parser conformance tests milestone May 3, 2022
@alancai98 alancai98 requested review from jpschorr and am357 May 3, 2022 04:50
@alancai98 alancai98 self-assigned this May 3, 2022
Comment on lines +35 to +55
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
Copy link
Member Author

@alancai98 alancai98 May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rendered file.

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

  1. not in spec but likely will be sometime in the future such as DML, DDL, EXEC, LET, etc
  2. tests not really parser related (e.g. performance, default parsed AST, custom type)

Copy link
Member Author

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.


parse::{
name: "double at operator on identifier",
statement: "@ @a",
Copy link
Contributor

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?

Copy link
Member Author

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/cast.ion Outdated Show resolved Hide resolved
},
parse::{
name: "TRIM with TRAILING missing FROM",
statement: "TRIM(trailing '')",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is technically not spec-conformant1, it does not seem ambiguous. And PostGres 9.4-14 seems to support this syntax2.

Which is not to say that we should support it, but I'm also not sure of the utility of the negative test here.

Copy link
Member Author

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.

Comment on lines 14 to 15
- `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
Copy link
Contributor

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?

Copy link
Member Author

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.

partiql-lang-kotlin-omitted-tests.md Show resolved Hide resolved
partiql-lang-kotlin-omitted-tests.md Outdated Show resolved Hide resolved
},
parse::{
name: "TRIM with BOTH missing FROM",
statement: "TRIM(BOTH 'test')",
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

@jpschorr jpschorr left a 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.

partiql-test-data/fail/parser/query/select/joins.ion Outdated Show resolved Hide resolved
- 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
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

@alancai98 alancai98 left a 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 under partiql-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 as fail to pass
  • 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 Show resolved Hide resolved
Comment on lines 14 to 15
- `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
Copy link
Member Author

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
Copy link
Member Author

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",
Copy link
Member Author

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/call.ion Outdated Show resolved Hide resolved
partiql-test-data/fail/parser/primitives/cast.ion Outdated Show resolved Hide resolved
@@ -29,3 +29,129 @@ parse::{
result: ParseOk
}
}

parse::{
Copy link
Member Author

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.

Comment on lines +35 to +55
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
Copy link
Member Author

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::{
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Contributor

@am357 am357 May 12, 2022

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.

Copy link
Member Author

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.

@alancai98 alancai98 merged commit aa75b30 into partiql:main May 16, 2022
@alancai98 alancai98 deleted the add-more-parse-tests branch May 16, 2022 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants