-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-31939][SQL][test-java11] Fix Parsing day of year when year field pattern is missing #28766
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
Changes from all commits
6afd5f7
2d797e0
a11a049
f78db47
b7da48e
cd55187
20b585d
b3cdccf
6b8dec4
52184fc
04ce7ee
1899e81
78c676e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- TESTS FOR DATETIME PARSING FUNCTIONS WITH INVALID VALUES --- | ||
|
|
||
| -- parsing invalid values with pattern 'D' | ||
| select to_timestamp('366', 'D'); | ||
| select to_timestamp('9', 'DD'); | ||
| -- in java 8 this case is invalid, but valid in java 11, disabled for jenkins | ||
| -- select to_timestamp('100', 'DD'); | ||
| select to_timestamp('366', 'DD'); | ||
| select to_timestamp('9', 'DDD'); | ||
| select to_timestamp('99', 'DDD'); | ||
| select to_timestamp('30-365', 'dd-DDD'); | ||
| select to_timestamp('11-365', 'MM-DDD'); | ||
| select to_timestamp('2019-366', 'yyyy-DDD'); | ||
| select to_timestamp('12-30-365', 'MM-dd-DDD'); | ||
| select to_timestamp('2020-01-365', 'yyyy-dd-DDD'); | ||
| select to_timestamp('2020-10-350', 'yyyy-MM-DDD'); | ||
| select to_timestamp('2020-11-31-366', 'yyyy-MM-dd-DDD'); | ||
| -- add a special case to test csv, because the legacy formatter it uses is lenient then Spark should | ||
| -- throw SparkUpgradeException | ||
| select from_csv('2018-366', 'date Date', map('dateFormat', 'yyyy-DDD')) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add a comment to explain why we need to test csv: because it's lenient and Spark should throw upgrade exception. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --SET spark.sql.legacy.timeParserPolicy=LEGACY | ||
| --IMPORT datetime-parsing.sql |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- TESTS FOR DATETIME PARSING FUNCTIONS --- | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are a lot more tests should be added here later :) |
||
|
|
||
| -- parsing with pattern 'D' | ||
| select to_timestamp('9', 'D'); | ||
| select to_timestamp('300', 'D'); | ||
| select to_timestamp('09', 'DD'); | ||
| select to_timestamp('99', 'DD'); | ||
| select to_timestamp('009', 'DDD'); | ||
| select to_timestamp('365', 'DDD'); | ||
| select to_timestamp('31-365', 'dd-DDD'); | ||
| select to_timestamp('12-365', 'MM-DDD'); | ||
| select to_timestamp('2020-365', 'yyyy-DDD'); | ||
| select to_timestamp('12-31-365', 'MM-dd-DDD'); | ||
| select to_timestamp('2020-30-365', 'yyyy-dd-DDD'); | ||
| select to_timestamp('2020-12-350', 'yyyy-MM-DDD'); | ||
| select to_timestamp('2020-12-31-366', 'yyyy-MM-dd-DDD'); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| -- Automatically generated by SQLQueryTestSuite | ||
| -- Number of queries: 13 | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('366', 'D') | ||
| -- !query schema | ||
| struct<to_timestamp(366, D):timestamp> | ||
| -- !query output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('9', 'DD') | ||
| -- !query schema | ||
| struct<> | ||
| -- !query output | ||
| org.apache.spark.SparkUpgradeException | ||
| You may get a different result due to the upgrading of Spark 3.0: Fail to parse '9' in the new parser. You can set spark.sql.legacy.timeParserPolicy to LEGACY to restore the behavior before Spark 3.0, or set to CORRECTED and treat it as an invalid datetime string. | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('366', 'DD') | ||
| -- !query schema | ||
| struct<to_timestamp(366, DD):timestamp> | ||
| -- !query output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('9', 'DDD') | ||
| -- !query schema | ||
| struct<> | ||
| -- !query output | ||
| org.apache.spark.SparkUpgradeException | ||
| You may get a different result due to the upgrading of Spark 3.0: Fail to parse '9' in the new parser. You can set spark.sql.legacy.timeParserPolicy to LEGACY to restore the behavior before Spark 3.0, or set to CORRECTED and treat it as an invalid datetime string. | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('99', 'DDD') | ||
| -- !query schema | ||
| struct<> | ||
| -- !query output | ||
| org.apache.spark.SparkUpgradeException | ||
| You may get a different result due to the upgrading of Spark 3.0: Fail to parse '99' in the new parser. You can set spark.sql.legacy.timeParserPolicy to LEGACY to restore the behavior before Spark 3.0, or set to CORRECTED and treat it as an invalid datetime string. | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('30-365', 'dd-DDD') | ||
| -- !query schema | ||
| struct<to_timestamp(30-365, dd-DDD):timestamp> | ||
| -- !query output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('11-365', 'MM-DDD') | ||
| -- !query schema | ||
| struct<to_timestamp(11-365, MM-DDD):timestamp> | ||
| -- !query output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('2019-366', 'yyyy-DDD') | ||
| -- !query schema | ||
| struct<to_timestamp(2019-366, yyyy-DDD):timestamp> | ||
| -- !query output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('12-30-365', 'MM-dd-DDD') | ||
| -- !query schema | ||
| struct<to_timestamp(12-30-365, MM-dd-DDD):timestamp> | ||
| -- !query output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('2020-01-365', 'yyyy-dd-DDD') | ||
| -- !query schema | ||
| struct<to_timestamp(2020-01-365, yyyy-dd-DDD):timestamp> | ||
| -- !query output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('2020-10-350', 'yyyy-MM-DDD') | ||
| -- !query schema | ||
| struct<to_timestamp(2020-10-350, yyyy-MM-DDD):timestamp> | ||
| -- !query output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query | ||
| select to_timestamp('2020-11-31-366', 'yyyy-MM-dd-DDD') | ||
| -- !query schema | ||
| struct<to_timestamp(2020-11-31-366, yyyy-MM-dd-DDD):timestamp> | ||
| -- !query output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query | ||
| select from_csv('2018-366', 'date Date', map('dateFormat', 'yyyy-DDD')) | ||
| -- !query schema | ||
| struct<> | ||
| -- !query output | ||
| org.apache.spark.SparkUpgradeException | ||
| You may get a different result due to the upgrading of Spark 3.0: Fail to parse '2018-366' in the new parser. You can set spark.sql.legacy.timeParserPolicy to LEGACY to restore the behavior before Spark 3.0, or set to CORRECTED and treat it as an invalid datetime string. |
Uh oh!
There was an error while loading. Please reload this page.