Skip to content
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

select interval '1 month' + date/timestamp doesn't work #6205

Closed
Tracked by #5753
alamb opened this issue May 3, 2023 · 0 comments · Fixed by #6270
Closed
Tracked by #5753

select interval '1 month' + date/timestamp doesn't work #6205

alamb opened this issue May 3, 2023 · 0 comments · Fixed by #6270
Labels
bug Something isn't working

Comments

@alamb
Copy link
Contributor

alamb commented May 3, 2023

Describe the bug

I can add a date and an interval using the interval syntax

❯ select '2012-01-01'::date + interval '1 month';
+----------------------------------------------------------------------------+
| Utf8("2012-01-01") + IntervalMonthDayNano("79228162514264337593543950336") |
+----------------------------------------------------------------------------+
| 2012-02-01                                                                 |
+----------------------------------------------------------------------------+

I can add a interval and date using the explicit ::interval syntax:

❯ select '1 month'::interval + '2012-01-01'::date;
+--------------------------------------+
| Utf8("1 month") + Utf8("2012-01-01") |
+--------------------------------------+
| 2012-02-01                           |
+--------------------------------------+

However, I can not add a interval and date using interval sytnax 🤯

❯ select interval '1 month' + '2012-01-01'::date;
This feature is not implemented: Unsupported interval argument. Expected string literal, got: BinaryOp { left: Value(SingleQuotedString("1 month")), op: Plus, right: Cast { expr: Value(SingleQuotedString("2012-01-01")), data_type: Date } }

To Reproduce

❯ select interval '1 month' + '2012-01-01'::date;

Expected behavior

+--------------------------------------+
| Utf8("1 month") + Utf8("2012-01-01") |
+--------------------------------------+
| 2012-02-01                           |
+--------------------------------------+

Additional context

This looks like potentially a sqlparser-rs bug (or something about how datafusion handles the resulting AST)

Originally filed by @jackwener as #6180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant