-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-28107][SQL] Support 'DAY TO (HOUR|MINUTE|SECOND)', 'HOUR TO (MINUTE|SECOND)' and 'MINUTE TO SECOND' #25000
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
Conversation
|
ok to test |
|
Test build #107004 has finished for PR 25000 at commit
|
|
Retest this please. |
common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
Outdated
Show resolved
Hide resolved
| seconds = m.group(6) == null ? toLongWithRange("minute", m.group(5), 0, 59) | ||
| : toLongWithRange("second", m.group(7), 0, 59); | ||
| break; | ||
| default: |
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.
If we have only two cases, shall we use if ... else instead of switch?
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
Outdated
Show resolved
Hide resolved
common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
Show resolved
Hide resolved
|
Test build #107150 has finished for PR 25000 at commit
|
|
@HyukjinKwon Thanks for your comments, just did some updates according to your suggestions. |
|
Test build #107179 has finished for PR 25000 at commit
|
|
Retest this please. |
|
Test build #107190 has finished for PR 25000 at commit
|
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
Outdated
Show resolved
Hide resolved
common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
Outdated
Show resolved
Hide resolved
common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
Outdated
Show resolved
Hide resolved
|
Test build #107208 has finished for PR 25000 at commit
|
|
Test build #107216 has finished for PR 25000 at commit
|
|
Retest this please. |
|
Test build #107266 has finished for PR 25000 at commit
|
| */ | ||
| public static CalendarInterval fromDayTimeString(String s) throws IllegalArgumentException { | ||
| CalendarInterval result = null; | ||
| public static CalendarInterval fromDayTimeString(String 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.
We still need throws IllegalArgumentException here.
common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
Show resolved
Hide resolved
| "899 microseconds"))) | ||
| checkAnswer(sql("select interval '40:32.99899999' minute to second"), | ||
| Row(CalendarInterval.fromString("interval 40 minutes 32 seconds 99 milliseconds " + | ||
| "899 microseconds"))) |
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.
Line 1203 ~ 1205 are the same with line 1206 ~ 1208.
| checkAnswer(sql("select interval '10-9' year to month"), | ||
| Row(CalendarInterval.fromString("interval 10 years 9 months"))) | ||
| checkAnswer(sql("select interval '20 15:40:32.99899999' day to hour"), | ||
| Row(CalendarInterval.fromString("interval 2 weeks 6 days 15 hours"))) |
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.
indentation?
|
Test build #107393 has finished for PR 25000 at commit
|
|
Retest this please. |
|
Test build #107409 has finished for PR 25000 at commit
|
common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
Show resolved
Hide resolved
|
Test build #107424 has finished for PR 25000 at commit
|
|
Hi, @lipzhu . I made a PR to your branch. Could you review and merge that? It's just for minimizing and simplifying the diff of the patch. I checked that all newly added UT passed. |
|
Thank you for merging. |
common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
Outdated
Show resolved
Hide resolved
|
Test build #107436 has finished for PR 25000 at commit
|
|
Test build #107438 has finished for PR 25000 at commit
|
|
Retest this please. |
|
Test build #107461 has finished for PR 25000 at commit
|
|
Retest this please |
|
Test build #107471 has finished for PR 25000 at commit
|
|
The first failure is the following.
The second failure is the following.
Both are irrelevant to this PR. |
|
Retest this please |
|
Test build #107482 has finished for PR 25000 at commit
|
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.
+1, LGTM. Merged to master.
Thank you so much, @lipzhu !
|
@dongjoon-hyun Thanks for your patient and work on this. |
| Row(CalendarInterval.fromString("interval 100 milliseconds"))) | ||
| checkAnswer(sql("select interval '10-9' year to month"), | ||
| Row(CalendarInterval.fromString("interval 10 years 9 months"))) | ||
| checkAnswer(sql("select interval '20 15:40:32.99899999' day to hour"), |
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.
All these test cases are positive ones. Could you add the negative cases too? Do they throw an exception? Exception messages make sense?
What changes were proposed in this pull request?
The interval conversion behavior is same with the PostgreSQL.
https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/sql/interval.sql#L180-L203
How was this patch tested?
UT.