-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-29713][SQL] Support Interval Unit Abbreviations in Interval Literals #26359
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
|
Test build #113087 has finished for PR 26359 at commit
|
|
Test build #113101 has finished for PR 26359 at commit
|
sql/core/src/test/resources/sql-tests/inputs/higher-order-functions.sql
Outdated
Show resolved
Hide resolved
|
Test build #113105 has finished for PR 26359 at commit
|
| DATABASES: 'DATABASES' | 'SCHEMAS'; | ||
| DAY: 'DAY'; | ||
| DAYS: 'DAYS'; | ||
| DAYS: 'DAYS'| 'D'; |
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.
D is not even a keyword in pgsql: https://www.postgresql.org/docs/8.1/sql-keywords-appendix.html
I'm curious how pgsql supports these abbreviations.
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.
yes, not abbreviation but also its plural
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.
It seems that in pg the type_name interval is required
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.
postgres=# select '1 s 2 days 6 weeks 3 seconds';
?column?
------------------------------
1 s 2 days 6 weeks 3 seconds
(1 row)
postgres=# select '1 s 2 days 6 weeks';
?column?
--------------------
1 s 2 days 6 weeks
(1 row)
postgres=# select interval '1 s 2 days 6 weeks';
interval
------------------
44 days 00:00:01
(1 row)
postgres=# select interval '1 s 2 days 3 weeks';
interval
------------------
23 days 00:00:01
(1 row)
postgres=# select interval '1 s 2 days d weeks';
interval
-----------------
2 days 00:00:01
(1 row)
postgres=# select interval '1 s 2 days days weeks';
interval
-----------------
2 days 00:00:01
(1 row)
postgres=# select interval '1 s 2 days year weeks';
interval
-----------------
2 days 00:00:01
(1 row)
postgres=# select interval '1 s 2 yrs days weeks';
interval
------------------
2 years 00:00:01
postgres=# select interval '1s 2yrs days weeks';
interval
------------------
2 years 00:00:01
(1 row)
(1 row)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.
proposed a new approach to parse intervals in the form of abbreviations, without adding new keywords to parser, please take a look, thanks.
|
Test build #113194 has finished for PR 26359 at commit
|
|
Test build #113200 has finished for PR 26359 at commit
|
|
Test build #113453 has finished for PR 26359 at commit
|
|
Test build #113496 has finished for PR 26359 at commit
|
|
Test build #113497 has finished for PR 26359 at commit
|
|
Test build #113498 has finished for PR 26359 at commit
|
|
Test build #113500 has finished for PR 26359 at commit
|
|
Test build #113537 has finished for PR 26359 at commit
|
| /** | ||
| * A safe version of `fromString`. It returns null for invalid input string. | ||
| */ | ||
| def safeFromString(str: String): CalendarInterval = { |
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.
This method is removed because never used
|
Test build #113539 has finished for PR 26359 at commit
|
|
Test build #113541 has finished for PR 26359 at commit
|
|
Test build #113542 has finished for PR 26359 at commit
|
|
Test build #113543 has finished for PR 26359 at commit
|
|
Test build #113560 has finished for PR 26359 at commit
|
|
Test build #113564 has finished for PR 26359 at commit
|
|
Without adding extra keywords to parser to support abbreviations and plurals, we need to directly parse the interval string instead of delegating it to the catalyst parser again. Features pending on this:
postgres=# select interval '1-10 5 1:1:1';
interval
--------------------------------
1 year 10 mons 5 days 01:01:01
(1 row)
gently ping @cloud-fan again. |
What changes were proposed in this pull request?
Currently we only support year[s], month[s] etc to define interval literals.. this pr support its common abbreviations to define.
Why are the changes needed?
Postgres Feature Parity
Does this PR introduce any user-facing change?
yes, before we only can define interval literals in
now we can use abbreviations of the units
How was this patch tested?
ADD UT