-
Notifications
You must be signed in to change notification settings - Fork 875
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
Add temporal kernels for arithmetic with timestamps and durations #527
Comments
FYI @velvia |
anyone taking this? also is there any reference implementation in other languages? |
@jimexist no one that I know of is taking this on. If you were interested that would be awesome The reference implementation would probably still be postgres in my mind. There is a nice table https://www.postgresql.org/docs/current/functions-datetime.html#OPERATORS-DATETIME-TABLE that describes all the operators, input types, and output types. I think it helps because certain combinations, such as @velvia / @andygrove / @jorgecarleitao any thoughts? |
this also relates to #45 |
This is definitely a good feature. It seems to me that in most cases, that time/duration manipulations could be based on existing arithmetic kernels, that'd be one way to go about it. Or at least, leveraging existing math kernels would make a ton of sense. |
I agree -- it may be that since the date/time arrays are My selfish initial desire is to be able to write a filter like "the last 5 minutes" in DataFusion so something like SELECT ...
WHERE
timestamp_column > (now() - interval `5 minutes') |
I would say that we need to generalize the compute arithmetic kernels to support We do this in arrow2 thanks to @elferherrera, here: https://github.com/jorgecarleitao/arrow2/blob/main/src/compute/arithmetics/mod.rs#L126 |
I very much support this notion -- I have filed #558 to track it. I can take a crack at the proposed interface if this seems reasonable to people |
I have some kernels doing time arithmetic for a personal project. I think it is helpful to consider more than just durations since, those are the easiest case. Specifically, we should also be able to add intervals to timestamps. I think it may be difficult to do these using existing arithmetic kernels. For the case of fixed durations (5000 seconds) it may be possible, but when handling intervals we'll need special kernels (eg., add 5 calendar days). One possible interface would be something like Then we can use |
Yeah, handling intervals will take some finagling / handling intervals that aren't fixed numbers of seconds. However, I think the type system can represent such durations (using a |
I don't think that entirely works for two reasons -- first, there are actually multiple
From an implementation, I think we can do this using
Then the implementation is basically iterating over a pair of arrays and callling |
That looks like a great idea to me. Nice |
Added a rough draft. The temporal values are a bit odd -- it looks like there is |
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I am trying to arithmetically create date / time columns. In my case I want to add some duration (7 days) to a Date32 column
Describe the solution you'd like
I would like temporal kernels that allowed operations such as:
TimestampNanosecondArray + Duration --> TimestampNanosecondArray
Date32Array + Duration --> Date32Array
etc.
I would like to be able to do something like
Describe alternatives you've considered
It might be nice to extend the
arithmetic
kernels to takeArc<dyn Array>
rather than thePrimitiveArray
as they do now and do the casting / calling specific implementations directly.Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: