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

Port DATE and TIME parse tests from Kotlin implementation #14

Merged
merged 1 commit into from
Jun 17, 2022
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
5 changes: 3 additions & 2 deletions partiql-lang-kotlin-omitted-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf
- semicolon semantic tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit. unrelated to this PR: looks like the indentation is incorrect.

Copy link
Member Author

Choose a reason for hiding this comment

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

In the rendered markdown, the indentation is consistent with the other tests in that list.

image

- https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1860-L1886
- https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/syntax/SqlParserTest.kt#L4025-L4064
- TIME constructor with additional arguments
- AM/PM: https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/syntax/SqlParserDateTimeTests.kt#L420-L437
- specifying timezone abbreviations (e.g. PST): https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/syntax/SqlParserDateTimeTests.kt#L685-L693

Unsure if should be included:
- `expectedCastAsIntArity`, `expectedCastAsRealArity` -- type supplied with parameter; not sure is parse error
Expand Down Expand Up @@ -66,6 +69,4 @@ https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf
https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L1627-L1639

To be included:
- DATE and TIME tests from [SqlParserDateTimeTests.kt](https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/syntax/SqlParserDateTimeTests.kt)
and [ParserErrorsTest.kt](https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/errors/ParserErrorsTest.kt#L2848-L3099)
- Operator precedence tests from [SqlParserPrecedenceTest.kt](https://github.com/partiql/partiql-lang-kotlin/blob/34625c68dbcbaf7b8ae60df7a4cf65c60b2a3b79/lang/test/org/partiql/lang/syntax/SqlParserPrecedenceTest.kt)
183 changes: 183 additions & 0 deletions partiql-test-data/fail/parser/primitives/date-constructor.ion
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
parse::{
name: "missing DATE string",
statement: "DATE",
assert: {
result: ParseError
},
}

parse::{
name: "invalid type INT for DATE string",
statement: "DATE 2012",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string without single quotes",
statement: "DATE 2012-08-28",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string using Ion literal",
statement: "DATE `2012-08-28`",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE STRING literal",
statement: "DATE 'date_string'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string format missing dashes",
statement: "DATE '20210310'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string format unexpected colons",
statement: "DATE '2021:03:10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string no starting single quotation",
statement: "DATE 2021-03-10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string no ending single quotation",
statement: "DATE '2021-03-10",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string format MMDDYYYY",
statement: "DATE '03-25-2021'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string format DDMMYYYY",
statement: "DATE '25-03-2021'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string minus before year",
statement: "DATE '-9999-03-10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string plus before year",
statement: "DATE '+9999-03-10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string extra minus between year and month",
statement: "DATE '2021--03-10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string plus between year and month",
statement: "DATE '2021-+03-10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string extra minus between month and day",
statement: "DATE '2021-03--10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string plus between month and day",
statement: "DATE '2021-03-+10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string month out of range",
statement: "DATE '2021-12345-10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string day out of range",
statement: "DATE '2021-03-12345'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string year missing padded zero",
statement: "DATE '123-03-10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string month missing padded zero",
statement: "DATE '2021-3-10'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string day missing padded zero",
statement: "DATE '2021-03-1'",
assert: {
result: ParseError
},
}

parse::{
name: "invalid DATE string year beyond 9999",
statement: "DATE '12345-03-10'",
assert: {
result: ParseError
},
}
Comment on lines +153 to +183
Copy link
Member Author

Choose a reason for hiding this comment

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

The SQL-92 spec says the year is 4 digits while month and day are both 2 digits:

Within a <datetime literal>, the <years value> shall contain
            four digits. The <seconds integer value> and other datetime
            components, with the exception of <seconds fraction>, shall each
            contain two digits.

PostgreSQL allows these other DATEs (e.g. missing leading zero or year with more than 4 digis).

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, let's leave it at SQL Compatibility for now.

Loading