-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-29364][SQL] Return an interval from date subtract according to SQL standard #26112
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
Closed
Closed
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
18bc09b
Add SubtractDates
MaxGekk 141d3da
Add tests for SubtractDates
MaxGekk dc37bc7
Use SubtractDates for dates subtract
MaxGekk e82f027
Update the SQL migration guide
MaxGekk e74f81b
Regen date.sql.out
MaxGekk 4a8173b
Regen datetime.sql.out
MaxGekk 27de6b8
Add config spark.sql.legacy.datesSubtraction.enabled
MaxGekk fbd2723
TimestampDiff -> SubtractTimestamps
MaxGekk 199adff
Update config description regarding datediff
MaxGekk 8b49c9b
Regen datetime.sql.out
MaxGekk 85f17f7
Revert "Update config description regarding datediff"
MaxGekk 228673d
Revert "Add config spark.sql.legacy.datesSubtraction.enabled"
MaxGekk f232b64
Revert "Update the SQL migration guide"
MaxGekk c6ec211
Use DateDiff in the PostgreSQL dialect
MaxGekk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -482,93 +482,93 @@ SELECT date '5874898-01-01' | |
| -- !query 46 | ||
| SELECT f1 - date '2000-01-01' AS `Days From 2K` FROM DATE_TBL | ||
| -- !query 46 schema | ||
| struct<Days From 2K:int> | ||
| struct<Days From 2K:interval> | ||
| -- !query 46 output | ||
| -1035 | ||
| -1036 | ||
| -1037 | ||
| -1400 | ||
| -1401 | ||
| -1402 | ||
| -1403 | ||
| -15542 | ||
| -15607 | ||
| 13977 | ||
| 14343 | ||
| 14710 | ||
| 91 | ||
| 92 | ||
| 93 | ||
| interval -2 years -10 months | ||
| interval -2 years -10 months -1 days | ||
| interval -2 years -9 months -4 weeks -2 days | ||
| interval -3 years -10 months | ||
| interval -3 years -10 months -1 days | ||
| interval -3 years -10 months -2 days | ||
| interval -3 years -9 months -4 weeks -2 days | ||
| interval -42 years -6 months -2 weeks -4 days | ||
| interval -42 years -8 months -3 weeks -1 days | ||
| interval 3 months | ||
| interval 3 months 1 days | ||
| interval 3 months 2 days | ||
| interval 38 years 3 months 1 weeks | ||
| interval 39 years 3 months 1 weeks 1 days | ||
| interval 40 years 3 months 1 weeks 2 days | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These results are inconsistent with PostgreSQL: |
||
|
|
||
| -- !query 47 | ||
| SELECT f1 - date 'epoch' AS `Days From Epoch` FROM DATE_TBL | ||
| -- !query 47 schema | ||
| struct<Days From Epoch:int> | ||
| struct<Days From Epoch:interval> | ||
| -- !query 47 output | ||
| -4585 | ||
| -4650 | ||
| 11048 | ||
| 11049 | ||
| 11050 | ||
| 24934 | ||
| 25300 | ||
| 25667 | ||
| 9554 | ||
| 9555 | ||
| 9556 | ||
| 9557 | ||
| 9920 | ||
| 9921 | ||
| 9922 | ||
| interval -12 years -6 months -2 weeks -4 days | ||
| interval -12 years -8 months -3 weeks -1 days | ||
| interval 26 years 1 months 3 weeks 6 days | ||
| interval 26 years 1 months 4 weeks | ||
| interval 26 years 2 months | ||
| interval 26 years 2 months 1 days | ||
| interval 27 years 1 months 3 weeks 6 days | ||
| interval 27 years 2 months | ||
| interval 27 years 2 months 1 days | ||
| interval 30 years 3 months | ||
| interval 30 years 3 months 1 days | ||
| interval 30 years 3 months 2 days | ||
| interval 68 years 3 months 1 weeks | ||
| interval 69 years 3 months 1 weeks 1 days | ||
| interval 70 years 3 months 1 weeks 2 days | ||
|
|
||
|
|
||
| -- !query 48 | ||
| SELECT date 'yesterday' - date 'today' AS `One day` | ||
| -- !query 48 schema | ||
| struct<One day:int> | ||
| struct<One day:interval> | ||
| -- !query 48 output | ||
| -1 | ||
| interval -1 days | ||
|
|
||
|
|
||
| -- !query 49 | ||
| SELECT date 'today' - date 'tomorrow' AS `One day` | ||
| -- !query 49 schema | ||
| struct<One day:int> | ||
| struct<One day:interval> | ||
| -- !query 49 output | ||
| -1 | ||
| interval -1 days | ||
|
|
||
|
|
||
| -- !query 50 | ||
| SELECT date 'yesterday' - date 'tomorrow' AS `Two days` | ||
| -- !query 50 schema | ||
| struct<Two days:int> | ||
| struct<Two days:interval> | ||
| -- !query 50 output | ||
| -2 | ||
| interval -2 days | ||
|
|
||
|
|
||
| -- !query 51 | ||
| SELECT date 'tomorrow' - date 'today' AS `One day` | ||
| -- !query 51 schema | ||
| struct<One day:int> | ||
| struct<One day:interval> | ||
| -- !query 51 output | ||
| 1 | ||
| interval 1 days | ||
|
|
||
|
|
||
| -- !query 52 | ||
| SELECT date 'today' - date 'yesterday' AS `One day` | ||
| -- !query 52 schema | ||
| struct<One day:int> | ||
| struct<One day:interval> | ||
| -- !query 52 output | ||
| 1 | ||
| interval 1 days | ||
|
|
||
|
|
||
| -- !query 53 | ||
| SELECT date 'tomorrow' - date 'yesterday' AS `Two days` | ||
| -- !query 53 schema | ||
| struct<Two days:int> | ||
| struct<Two days:interval> | ||
| -- !query 53 output | ||
| 2 | ||
| interval 2 days | ||
|
|
||
|
|
||
| -- !query 54 | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
seems like we should use
DateDiffif the dialect is pgsql.