-
Notifications
You must be signed in to change notification settings - Fork 610
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
feat(timestamps): add support for timestamp/date +/- intervals for additional backends #9799
Conversation
ACTION NEEDED Ibis follows the Conventional Commits specification for release automation. The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
month = alltypes.date_string_col[:2] | ||
day = alltypes.date_string_col[3:5] | ||
year = alltypes.date_string_col[6:8] | ||
date_col = ("20" + year + "-" + month + "-" + day).cast("date") |
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.
More backends implement the primitives here than the previous code, which used arrays.
…and clean up use of `sge.Var`
… month, week, and day granularity
…n integer to an interval
@@ -404,6 +400,8 @@ def visit_Cast(self, op, *, arg, to): | |||
return arg | |||
elif from_.is_integer() and to.is_timestamp(): | |||
return self.f.dateadd(self.v.s, arg, "1970-01-01 00:00:00") | |||
elif from_.is_integer() and to.is_interval(): | |||
return sge.Interval(this=arg, unit=self.v[to.unit.singular]) |
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.
Since this is such a common implementation I'm going to try and encode the logic in the base implementation of visit_Cast
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.
Looks good -- not sure if you wanted to handle the casting work in this PR or separately
I'll do it in a follow-up now that you mention it. |
Lemme run the clouds |
Based on #9794, I decided to investigate whether we can do a bit better on date/timestamp +/- interval-style operations.
Many backends support adding and subtracting intervals from dates and timestamps, but do not support intervals as a first-class type, and we can allow that functionality to work.
This PR adds support for those operations to mssql and oracle and consolidates some existing implementation details around the
IntervalFromInteger
operation.