Uh oh!
There was an error while loading. Please reload this page.
[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
cloud-fan
commented
Nov 5, 2019
maropu
commented
Nov 5, 2019
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? |
cloud-fan
commented
Nov 5, 2019
AFAIK pgsql has configs to change the interval output string. We can think about it later. |
SparkQA
commented
Nov 5, 2019
Test build #113271 has finished for PR 26401 at commit
|
SparkQA
commented
Nov 5, 2019
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.
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Nov 5, 2019
Test build #113278 has finished for PR 26401 at commit
|
dongjoon-hyun
commented
Nov 6, 2019
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'"), |
cloud-fan
commented
Nov 6, 2019
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. |
SparkQA
commented
Nov 6, 2019
Test build #113297 has finished for PR 26401 at commit
|
cloud-fan
commented
Nov 6, 2019
retest this please |
SparkQA
commented
Nov 6, 2019
Test build #113303 has finished for PR 26401 at commit
|
cloud-fan
commented
Nov 6, 2019
retest this please |
SparkQA
commented
Nov 6, 2019
Test build #113306 has finished for PR 26401 at commit
|
SparkQA
commented
Nov 7, 2019
Test build #113357 has finished for PR 26401 at commit
|
cloud-fan
commented
Nov 7, 2019
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.