[SPARK-29761][SQL] do not output leading 'interval' in CalendarInterval.toString#26401
[SPARK-29761][SQL] do not output leading 'interval' in CalendarInterval.toString#26401cloud-fan wants to merge 3 commits into
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.
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.
Not important but you could leave the code as is, and just do trim() on the result.
|
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.