-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-29926][SQL] Fix weird interval string whose value is only a dangling decimal point #26573
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 1 commit
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 |
|---|---|---|
|
|
@@ -105,7 +105,7 @@ class IntervalUtilsSuite extends SparkFunSuite { | |
| checkFromString("1 day 10 day", new CalendarInterval(0, 11, 0)) | ||
| // Only the seconds units can have the fractional part | ||
| checkFromInvalidString("1.5 days", "'days' cannot have fractional part") | ||
| checkFromInvalidString("1. hour", "'hour' cannot have fractional part") | ||
| checkFromInvalidString("1. hour", "invalid value '1.'") | ||
| checkFromInvalidString("1 hourX", "invalid unit 'hourx'") | ||
| checkFromInvalidString("~1 hour", "unrecognized number '~1'") | ||
| checkFromInvalidString("1 Mour", "invalid unit 'mour'") | ||
|
|
@@ -115,12 +115,12 @@ class IntervalUtilsSuite extends SparkFunSuite { | |
| checkFromInvalidString("2234567890 days", "integer overflow") | ||
| checkFromInvalidString("\n", "Error parsing '\n' to interval") | ||
| checkFromInvalidString("\t", "Error parsing '\t' to interval") | ||
|
|
||
| checkFromInvalidString("1. seconds", "invalid value '1.'") | ||
| checkFromInvalidString(". seconds", "invalid value '.'") | ||
| } | ||
|
|
||
| test("string to interval: seconds with fractional part") { | ||
| checkFromString("0.1 seconds", new CalendarInterval(0, 0, 100000)) | ||
| checkFromString("1. seconds", new CalendarInterval(0, 0, 1000000)) | ||
|
Member
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. Will we explicitly disable this case? scala> sql("select 0.")
res0: org.apache.spark.sql.DataFrame = [0: decimal(1,0)]At least I know Python, Java, Scala and R support this way as well.
Member
Author
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. presto> select interval '1.' second;
_col0
----------------
0 00:00:01.000
(1 row)
Query 20191119_051438_00001_f5kcs, FINISHED, 1 node
Splits: 17 total, 17 done (100.00%)
0:03 [0 rows, 0B] [0 rows/s, 0B/s]
presto> select interval '.' second;
Query 20191119_051452_00002_f5kcs failed: Invalid INTERVAL SECOND value: .Also check with presto, '1.' seconds is valid
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. @HyukjinKwon good point. To be consistent with Spark's own parser, maybe we should allow
Member
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. ^ +1!
Member
Author
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. updated, please recheck, thanks. |
||
| checkFromString("123.001 seconds", new CalendarInterval(0, 0, 123001000)) | ||
| checkFromString("1.001001 seconds", new CalendarInterval(0, 0, 1001001)) | ||
| checkFromString("1 minute 1.001001 seconds", new CalendarInterval(0, 0, 61001001)) | ||
|
|
||
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 just
initialFractionScale?