[SPARK-38332][SQL] Add the DATEADD() and DATE_ADD() aliases for TIMESTAMPADD()#35661
[SPARK-38332][SQL] Add the DATEADD() and DATE_ADD() aliases for TIMESTAMPADD()#35661MaxGekk wants to merge 6 commits intoapache:masterfrom
DATEADD() and DATE_ADD() aliases for TIMESTAMPADD()#35661Conversation
DATEADD() and DATE_ADD() aliases for TIMESTAMPADD()DATEADD() and DATE_ADD() aliases for TIMESTAMPADD()
|
@srielau @entong @superdupershant Any feedback is welcome. |
HyukjinKwon
left a comment
There was a problem hiding this comment.
I'm fine w/ this. Look fine.
superdupershant
left a comment
There was a problem hiding this comment.
Looks good except the return type shouldn't always be TIMESTAMP if the input expression and operation fit within a DATE type.
Sorry for missing this in the original TIMESTAMPADD change as well.
|
|
||
|
|
||
| -- !query | ||
| select date_add(DAY, 367, date'2022-02-25') |
There was a problem hiding this comment.
I think the convention is if the third argument is of type DATE the expression's return type is:
DATE if the unit is DAY or larger
TIMESTAMP if the unit is smaller than DAY i.e. (HOUR, MINUTE, SECOND, etc...)
There was a problem hiding this comment.
I don't think we should do such kind of changes in the PR which just introduces aliases. Let's do that separately w/ tests if the feature is supported by other DBMSs as well.
Also I would prefer to not link such changes to DATEADD since they affect TIMESTAMPADD. It is slightly strange to me that a timestamp function will return date type. Let's discuss this separately.
There was a problem hiding this comment.
Do you mean timestampadd can take date inputs but dateadd can't take timestamp inputs? Then it's not a simple alias any more.
There was a problem hiding this comment.
@cloud-fan no both expressions can take date and timestamp inputs it is just a simple alias.
@MaxGekk yes I agree fixing it in a separate PR makes sense.
superdupershant
left a comment
There was a problem hiding this comment.
LGTM let's just fix the return types in a separate PR.
|
|
||
|
|
||
| -- !query | ||
| select date_add(DAY, 367, date'2022-02-25') |
There was a problem hiding this comment.
@cloud-fan no both expressions can take date and timestamp inputs it is just a simple alias.
@MaxGekk yes I agree fixing it in a separate PR makes sense.
|
Merging to master. Thank you, @HyukjinKwon @superdupershant @cloud-fan @gengliangwang for review. |
What changes were proposed in this pull request?
In the PR, I propose to add two aliases for the
TIMESTAMPADD()function introduced by #35502:DATEADD()DATE_ADD()Why are the changes needed?
Does this PR introduce any user-facing change?
No. The new aliases just extend Spark SQL API.
How was this patch tested?