-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
[SPARK-32785][SQL] Interval with dangling parts should not results null #29635
Conversation
cc @cloud-fan @MaxGekk @maropu @HyukjinKwon thanks for reviewing |
Test build #128248 has finished for PR 29635 at commit
|
@@ -77,6 +77,19 @@ class IntervalUtilsSuite extends SparkFunSuite with SQLHelper { | |||
} | |||
} | |||
|
|||
test("string to interval: interval with dangling parts should not results null") { | |||
checkFromInvalidString("+", "dangling interval value sign '+'") | |||
checkFromInvalidString("-", "dangling interval value sign '-'") |
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.
how about Expect a number after '-' but hit EOL
checkFromInvalidString("-", "dangling interval value sign '-'") | ||
checkFromInvalidString("+ 2", "dangling interval value '2'") | ||
checkFromInvalidString("- 1", "dangling interval value '1'") | ||
checkFromInvalidString("1", "dangling interval value '1'") |
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.
how about Expect a unit name after '1' but hit EOL
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.
done, but looks a bit weird for interval '-.'
to expect a unit name
Test build #128254 has finished for PR 29635 at commit
|
Test build #128261 has finished for PR 29635 at commit
|
can we add a migration guide? |
OK, are you targeting this to 3.0 or not? |
yea we should target 3.0. Let's add migration guide for 3.1 in this PR, and do the same for 3.0.2 in the backport PR. |
Test build #128293 has finished for PR 29635 at commit
|
thanks, merging to master! |
…t null THIS PR brings #29635 to branch-3.0 and targets v3.0.2 ### What changes were proposed in this pull request? bugfix for incomplete interval values, e.g. interval '1', interval '1 day 2', currently these cases will result null, but actually we should fail them with IllegalArgumentsException ### Why are the changes needed? correctness ### Does this PR introduce _any_ user-facing change? yes, incomplete intervals will throw exception now #### before ``` bin/spark-sql -S -e "select interval '1', interval '+', interval '1 day -'" NULL NULL NULL ``` #### after ``` -- !query select interval '1' -- !query schema struct<> -- !query output org.apache.spark.sql.catalyst.parser.ParseException Cannot parse the INTERVAL value: 1(line 1, pos 7) == SQL == select interval '1' ``` ### How was this patch tested? unit tests added Closes #29658 from yaooqinn/SPARK-32785-30. Authored-by: Kent Yao <yaooqinn@hotmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@@ -40,6 +40,8 @@ license: | | |||
|
|||
- In Spark 3.1, `path` option cannot coexist when the following methods are called with path parameter(s): `DataFrameReader.load()`, `DataFrameWriter.save()`, `DataStreamReader.load()`, or `DataStreamWriter.start()`. In addition, `paths` option cannot coexist for `DataFrameReader.load()`. For example, `spark.read.format("csv").option("path", "/tmp").load("/tmp2")` or `spark.read.option("path", "/tmp").csv("/tmp2")` will throw `org.apache.spark.sql.AnalysisException`. In Spark version 3.0 and below, `path` option is overwritten if one path parameter is passed to above methods; `path` option is added to the overall paths if multiple path parameters are passed to `DataFrameReader.load()`. To restore the behavior before Spark 3.1, you can set `spark.sql.legacy.pathOptionBehavior.enabled` to `true`. | |||
|
|||
- In Spark 3.1, incomplete interval literals, e.g. `INTERVAL '1'`, `INTERVAL '1 DAY 2'` will fail with IllegalArgumentException. In Spark 3.0, they result `NULL`s. |
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 Spark 3.1, incomplete interval literals, e.g.
INTERVAL '1'
,INTERVAL '1 DAY 2'
will fail with IllegalArgumentException. In Spark 3.0, they resultNULL
s.
=>
In Spark 3.1, IllegalArgumentException is returned for the incomplete interval literals, e.g.
INTERVAL '1'
,INTERVAL '1 DAY 2'
, which are invalid. In Spark 3.0, these literals result inNULL
s.
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 fix it in followup, @yaooqinn ?
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.
OK, I will raise a PR today~
…lete interval literals ### What changes were proposed in this pull request? Address comments #29635 (comment) to improve migration guide ### Why are the changes needed? improve migration guide ### Does this PR introduce _any_ user-facing change? NO,only doc update ### How was this patch tested? passing GitHub action Closes #30113 from yaooqinn/SPARK-32785-F. Authored-by: Kent Yao <yaooqinn@hotmail.com> Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org>
…complete interval literals ### What changes were proposed in this pull request? Address comments #29635 (comment) to improve migration guide ### Why are the changes needed? improve migration guide ### Does this PR introduce _any_ user-facing change? NO,only doc update ### How was this patch tested? passing GitHub action Closes #30117 from yaooqinn/SPARK-32785-F30. Authored-by: Kent Yao <yaooqinn@hotmail.com> Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org>
…t null THIS PR brings apache#29635 to branch-3.0 and targets v3.0.2 ### What changes were proposed in this pull request? bugfix for incomplete interval values, e.g. interval '1', interval '1 day 2', currently these cases will result null, but actually we should fail them with IllegalArgumentsException ### Why are the changes needed? correctness ### Does this PR introduce _any_ user-facing change? yes, incomplete intervals will throw exception now #### before ``` bin/spark-sql -S -e "select interval '1', interval '+', interval '1 day -'" NULL NULL NULL ``` #### after ``` -- !query select interval '1' -- !query schema struct<> -- !query output org.apache.spark.sql.catalyst.parser.ParseException Cannot parse the INTERVAL value: 1(line 1, pos 7) == SQL == select interval '1' ``` ### How was this patch tested? unit tests added Closes apache#29658 from yaooqinn/SPARK-32785-30. Authored-by: Kent Yao <yaooqinn@hotmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…complete interval literals ### What changes were proposed in this pull request? Address comments apache#29635 (comment) to improve migration guide ### Why are the changes needed? improve migration guide ### Does this PR introduce _any_ user-facing change? NO,only doc update ### How was this patch tested? passing GitHub action Closes apache#30117 from yaooqinn/SPARK-32785-F30. Authored-by: Kent Yao <yaooqinn@hotmail.com> Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org>
What changes were proposed in this pull request?
bugfix for incomplete interval values, e.g. interval '1', interval '1 day 2', currently these cases will result null, but actually we should fail them with IllegalArgumentsException
Why are the changes needed?
correctness
Does this PR introduce any user-facing change?
yes, incomplete intervals will throw exception now
before
after
How was this patch tested?
unit tests added