-
Notifications
You must be signed in to change notification settings - Fork 811
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
Improved Temporal and Decimal Arithmetic #3999
Comments
Having a kernel like I agree traits would likely be nicer than arcane names. One thing I think would be a step back was if the traits were complicated enough to express things like why use a trait for
|
The eventual idea would be to not have such a kernel at all, instead you would just call
What are your thoughts on these error messages?
Mainly for consistency with the use of
The intention is for the traits to be implemented for the concrete types, filling the role of the "typed kernels", whilst also being implemented for the trait objects filling the role of the "dyn kernels". The trait-dispatch machinery in Rust will automatically work out which one is appropriate to call. |
The other thing I wanted to mention was that we already have some non trivial changes in flight (e.g ArrayData, etc) and one thing I think we should try to is wrap up outstanding refactorings before we take on another substantial refactor |
100% agree, I intend to have these done in time for the next release at the end of the coming week. I'm queuing this up as the next big ticket item 😄 |
✅ This one seems good
This one is also ok given there are only two options and they are probably what the user wants. However, I think in reality there would be so many impls that the ones I cared about (for adding timestamps) would not make it into the actual message (they would be hidden behind Maybe this could be handled with sufficiently good and detailed examples and messages. |
It would appear the cut off is 8, which I don't think we will exceed for any type Even then I think this is still better than the current approach of using method names to define overloads, at least the compiler tries to help you, instead of always forcing you to search the docs for the specific method signature you want? |
I am not sure I agree that the compiler's help is better in this case, but that is a personal preference. I certainly don't oppose this proposal on this grounds, but I wanted to explore it |
Perhaps you might articulate what your personal preference would be for? |
I guess I would prefer a runtime error with a clear error message that "timestamp + timestamp is not supported" |
Using the dyn variants will yield that behaviour |
I think for a trait approach, the advantage would be a cleaner implementation. It might be easier to maintain for long term. The concerns I have are basically: 1. performance. I'm not sure if such trait-based dispatch could bring performance penalty even it is slight. 2. special needs. Adding arcane method names is because there are special needs for computation (e.g. checked, opt, overflow-allowing, etc). In order to match such requirements, I think one trait is not necessary but it will lead to some special traits for special need. So eventually we might still have arcane trait names 😂 . |
Trait-based dispatch is zero-cost, and behaves the same as normal function dispatch. Trait-object dispatch, i.e. using
Yes, we will need to keep an eye out for this. I'm optimistic we can get by with traits for the type of operation, i.e. Divide, Add, Substract, etc... with checked and unchecked member functions. Divide might need a third for divide by zero => NULL, but that is perfectly fine imo |
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
The current support for arithmetic on temporal and decimal types is limited and fairly inconsistent:
Timestamp
fromTimestamp
should produce aDuration
(notTimestamp
) #3964dyn Any
in Scalar dyn Kernels #2842Describe the solution you'd like
It is not a fully formed design, but I would like to implement something inspired by the
std::ops
traits used for Rust arithmetic.In particular something like
Aside from solving the above problems, it would make for a more idiomatic design that is easier to extend and maintain. We would then deprecate and remove the old kernels.
This would also be a pattern that could be translated to support other kernels that run into similar issues with scalars, e.g. arrow-ord and arrow-string.
Describe alternatives you've considered
We could drop support for arithmetic with statically typed arguments, and add further kernels for performing arithmetic on
dyn Scalar
Additional context
The text was updated successfully, but these errors were encountered: