-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-29761][SQL] do not output leading 'interval' in CalendarInterval.toString #26401
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
|
Ur, I see, this change looks reasonable. Actually, it seems pgSQL does so; |
|
I have been confusing this weird prefix for a long time,but how about we use sql standard output style? |
|
AFAIK pgsql has configs to change the interval output string. We can think about it later. |
|
Test build #113271 has finished for PR 26401 at commit
|
|
Test build #113273 has finished for PR 26401 at commit
|
| private void appendUnit(StringBuilder sb, long value, String unit) { | ||
| if (value != 0) { | ||
| sb.append(' ').append(value).append(' ').append(unit).append('s'); | ||
| sb.append(value).append(' ').append(unit).append('s').append(' '); |
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.
nit: Less .append() calls:
| sb.append(value).append(' ').append(unit).append('s').append(' '); | |
| sb.append(value).append(' ').append(unit).append("s "); |
| } | ||
|
|
||
| sb.setLength(sb.length() - 1); | ||
| return sb.toString(); |
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.
Not important but you could leave the code as is, and just do trim() on the result.
common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
Show resolved
Hide resolved
|
Test build #113278 has finished for PR 26401 at commit
|
|
Thank you for pinging me, @cloud-fan . I'm +1 for this, but it seems that we need a migration guide in order to avoid surprises because the output change might affect the old Spark application which expects that prefix. (cc @gatorsmile ) This PR already shows that kind of side effects. - df.selectExpr(s"d - $i"),
+ df.selectExpr(s"d - INTERVAL'$i'"), |
The particular case you pointed out is not a breaking change. It relies on it does change the result when casting interval to string. Let me add a migration guide in case users rely on that string. |
|
Test build #113297 has finished for PR 26401 at commit
|
|
retest this please |
|
Test build #113303 has finished for PR 26401 at commit
|
|
retest this please |
|
Test build #113306 has finished for PR 26401 at commit
|
|
Test build #113357 has finished for PR 26401 at commit
|
|
thanks for the review, merging to master! |
What changes were proposed in this pull request?
remove the leading "interval" in
CalendarInterval.toString.Why are the changes needed?
Although it's allowed to have "interval" prefix when casting string to int, it's not recommended.
This is also consistent with pgsql:
Does this PR introduce any user-facing change?
yes, when display a dataframe with interval type column, the result is different.
How was this patch tested?
updated tests.