-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support Date32
arguments for generate_series
#9420
Conversation
Date32
, Date64
, Interval(MonthDayNano)
argumnet types in and generate_series
Date32
, Date64
, Interval(MonthDayNano)
argumnet types in and generate_seriesDate32
, argument types in and generate_series
Date32
, argument types in and generate_seriesDate32
arguments for generate_series
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.
Thank you @Lordworms -- this looks great
I also tried it locally and it worked great (I found using unnest was easier to see the results)
❯ select unnest(range(DATE '1992-09-01', DATE '1993-03-01', INTERVAL '1' MONTH));
+------------------------------------------------------------------------------------------------------------+
| unnest(range(Utf8("1992-09-01"),Utf8("1993-03-01"),IntervalMonthDayNano("79228162514264337593543950336"))) |
+------------------------------------------------------------------------------------------------------------+
| 1992-09-01 |
| 1992-10-01 |
| 1992-11-01 |
| 1992-12-01 |
| 1993-01-01 |
| 1993-02-01 |
+------------------------------------------------------------------------------------------------------------+
6 rows in set. Query took 0.007 seconds.
❯ select unnest(range(DATE '1992-09-01', DATE '1993-03-01', INTERVAL '1' DAY));
+---------------------------------------------------------------------------------------------------+
| unnest(range(Utf8("1992-09-01"),Utf8("1993-03-01"),IntervalMonthDayNano("18446744073709551616"))) |
+---------------------------------------------------------------------------------------------------+
| 1992-09-01 |
| 1992-09-02 |
| 1992-09-03 |
| 1992-09-04 |
...
I think it just needs a few more tests and this PR will be ready to go
@@ -38,7 +38,8 @@ path = "src/lib.rs" | |||
|
|||
[dependencies] | |||
arrow = { workspace = true } | |||
datafusion-common = { workspace = true, default-features = true } | |||
arrow-array = { workspace = true } |
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.
I wonder why we need to add arrow-array explicilty? Isn't everything we need already exported via arrow
?
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.
I will remove it. I was trying to use some methods in that crate so imported that, I will remove it
range(1, -5, -1), | ||
range(DATE '1992-09-01', DATE '1993-03-01', INTERVAL '1' MONTH), | ||
range(DATE '1993-02-01', DATE '1993-01-01', INTERVAL '-1' DAY), | ||
range(DATE '1989-04-01', DATE '1993-03-01', INTERVAL '1' YEAR) |
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.
Can you please also add tests for null handling?
For example
range(DATE '1992-09-01', DATE '1993-03-01', NULL,
range(DATE '1992-09-01', NULL , INTERVAL '1' MONTH),
range(NULL, DATE '1993-03-01', INTERVAL '1' MONTH),
Also, can you add negative tests (like when start is > stop by the the interval is positive (I think the code will error in this case, but it would be good to verify this
range(DATE '1993-03-01', DATE '1989-04-01', INTERVAL '1' YEAR)
range(, DATE '1989-04-01', DATE '1993-03-01', INTERVAL '-1' YEAR)
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.
OK, I will do it now
Bonus points for updating the docs to mention the new support for date: https://arrow.apache.org/datafusion/user-guide/sql/scalar_functions.html#range (we can do this as a follow on PR as well) |
Yes, I will do it in next PR, along with finishing port of regx function today |
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.
Thank you @Lordworms
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.
Thanks again @Lordworms
Which issue does this PR close?
Closes #9353
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?