Uh oh!
There was an error while loading. Please reload this page.
[SPARK-31410][SPARK-30668][SQL][FOLLOWUP] Raise exception instead of silent change for new DateFormatter - #27537
[SPARK-31410][SPARK-30668][SQL][FOLLOWUP] Raise exception instead of silent change for new DateFormatter#27537xuanyuanking wants to merge 14 commits into
Conversation
SparkQA
commented
Feb 11, 2020
Test build #118205 has finished for PR 27537 at commit
|
SparkQA
commented
Feb 12, 2020
Test build #118271 has finished for PR 27537 at commit
|
cloud-fan
commented
Feb 18, 2020
@xuanyuanking can you fix the conflicts? |
xuanyuanking
commented
Feb 18, 2020
Sure, will also reuse the |
b9b3c8f to
c07d09dCompareSparkQA
commented
Feb 21, 2020
Test build #118754 has finished for PR 27537 at commit
|
Uh oh!
There was an error while loading. Please reload this page.
HyukjinKwon
commented
Feb 21, 2020
cc @MaxGekk |
SparkQA
commented
Feb 24, 2020
Test build #118846 has finished for PR 27537 at commit
|
86313e5 to
6f51b13CompareThere was a problem hiding this comment.
This is used to create DateFormatter and TimestampFormatter, and I'm pretty sure these 2 formatters are used in many expressions and other places like the json parser.
I think it's better to put the logic in the formatter, not in some expressions.
There was a problem hiding this comment.
Thanks, got it. I moved this logic into formatter in cc9fd4f.
SparkQA
commented
Feb 24, 2020
Test build #118856 has finished for PR 27537 at commit
|
SparkQA
commented
Feb 27, 2020
Test build #119021 has finished for PR 27537 at commit
|
There was a problem hiding this comment.
different places can create different legacy formatter. It's better to always create the legacy formatter, and the new formatter just carry the instance of legacy formatter.
There was a problem hiding this comment.
IIRC some places just call formatter and catch NonFatal. Can you do some checks and make sure we don't catch non-fatal blindly?
There was a problem hiding this comment.
Thanks for reminding, fix for the non-codegen in fbac26d.
SparkQA
commented
Feb 27, 2020
Test build #119034 has finished for PR 27537 at commit
|
SparkQA
commented
Feb 27, 2020
Test build #119035 has finished for PR 27537 at commit
|
0242629 to
fbac26dCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
46dbf9b to
1a92e0fCompare| } | ||
| // When legacy time parser policy set to EXCEPTION, check whether we will get different results | ||
| // between legacy format and new format. For legacy parser, DateTimeParseException will not be |
| // When legacy time parser policy set to EXCEPTION, check whether we will get different results | ||
| // between legacy format and new format. For legacy parser, DateTimeParseException will not be | ||
| // thrown. On the contrary, if the legacy policy set to CORRECTED, DateTimeParseException will |
There was a problem hiding this comment.
For legacy parser, DateTimeParseException will not be thrown
I think it should beIf new parser fails but legacy parser works, throw a SparkUpgradeException.
There was a problem hiding this comment.
On the contrary, if the legacy policy set to CORRECTED ...
If the legacy policy set to CORRECTED, do nothing and let the exception propagate.
| case _: Throwable => None | ||
| } | ||
| if (res.nonEmpty) { | ||
| throw new SparkUpgradeException("3.0", s"Set ${SQLConf.LEGACY_TIME_PARSER_POLICY.key} to " + |
There was a problem hiding this comment.
We should explain what happened.
Fail to parse '$s' in the new parser. You can set ... to LEGACY to restore ..., or set it to CORRECTED and treat it as an invalid datetime string.
| val msg = intercept[SparkException] { | ||
| df2.collect() | ||
| }.getCause.getMessage | ||
| assert(msg.contains(s"Set ${SQLConf.LEGACY_TIME_PARSER_POLICY.key} to LEGACY to restore " + |
There was a problem hiding this comment.
I think it's good enough to test if the cause is SparkUpgradeException
| val message = intercept[SparkException] { | ||
| df.collect() | ||
| }.getCause.getMessage | ||
| assert(message.contains(s"Set ${SQLConf.LEGACY_TIME_PARSER_POLICY.key} to LEGACY to restore " + |
| val msg = intercept[SparkException] { | ||
| csv.collect() | ||
| }.getCause.getMessage | ||
| assert(msg.contains(s"Set ${SQLConf.LEGACY_TIME_PARSER_POLICY.key} to LEGACY to restore " + |
| val msg = intercept[SparkException] { | ||
| json.collect() | ||
| }.getCause.getMessage | ||
| assert(msg.contains(s"Set ${SQLConf.LEGACY_TIME_PARSER_POLICY.key} to LEGACY to restore " + |
| * Exception thrown when Spark returns different result after upgrading to a new version. | ||
| */ | ||
| private[spark] class SparkUpgradeException(version: String, message: String, cause: Throwable) | ||
| extends SparkException(s"Exception for upgrading to Spark $version: $message", cause) |
There was a problem hiding this comment.
You may get a different result due to the upgrading of Spark $version: $message
SparkQA
commented
Mar 4, 2020
Test build #119299 has finished for PR 27537 at commit
|
| checkExceptionInExpression[SparkUpgradeException]( | ||
| GetTimestamp( | ||
| Literal("2020-01-27T20:06:11.847-0800"), | ||
| Literal("yyyy-MM-dd'T'HH:mm:ss.SSSz")), "Exception for upgrading to Spark 3.0") |
SparkQA
commented
Mar 4, 2020
Test build #119306 has finished for PR 27537 at commit
|
SparkQA
commented
Mar 5, 2020
Test build #119355 has finished for PR 27537 at commit
|
cloud-fan
commented
Mar 5, 2020
thanks, merging to master/3.0! |
… for new DateFormatter This is a follow-up work for #27441. For the cases of new TimestampFormatter return null while legacy formatter can return a value, we need to throw an exception instead of silent change. The legacy config will be referenced in the error message. Avoid silent result change for new behavior in 3.0. Yes, an exception is thrown when we detect legacy formatter can parse the string and the new formatter return null. Extend existing UT. Closes#27537 from xuanyuanking/SPARK-30668-follow. Authored-by: Yuanjian Li <xyliyuanjian@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 7db0af5) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
xuanyuanking
commented
Mar 5, 2020
Thanks for the review! |
… for new DateFormatter ### What changes were proposed in this pull request? This is a follow-up work for apache#27441. For the cases of new TimestampFormatter return null while legacy formatter can return a value, we need to throw an exception instead of silent change. The legacy config will be referenced in the error message. ### Why are the changes needed? Avoid silent result change for new behavior in 3.0. ### Does this PR introduce any user-facing change? Yes, an exception is thrown when we detect legacy formatter can parse the string and the new formatter return null. ### How was this patch tested? Extend existing UT. Closesapache#27537 from xuanyuanking/SPARK-30668-follow. Authored-by: Yuanjian Li <xyliyuanjian@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
This is a follow-up work for #27441. For the cases of new TimestampFormatter return null while legacy formatter can return a value, we need to throw an exception instead of silent change. The legacy config will be referenced in the error message.
Why are the changes needed?
Avoid silent result change for new behavior in 3.0.
Does this PR introduce any user-facing change?
Yes, an exception is thrown when we detect legacy formatter can parse the string and the new formatter return null.
How was this patch tested?
Extend existing UT.