-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[C++] Change Scalar::CastTo to do safe cast by default and allow to specify cast options ? #35040
Comments
I think this is a good idea. The result will probably be a slight bit slower but working with scalars is already slightly slower anyways and it would be nice to have only a single implementation. |
Also, we've since extracted the cast kernels from the rest of the kernels and declared them as "essential kernels" that will always be present (even if ARROW_COMPUTE is OFF) so I think it is safe to rely on them. |
FYI I tried swapping the Scalar.cast() implementation to the compute kernel and current (but small) test suite passed while also fixing #35370.
|
) ### Rationale for this change Scalar cast should use the computer kernel just like Arrays, instead of its own custom implementation. ### Are these changes tested? Added test cases for GH-35370, GH-34901, and GH-35040 ### Are there any user-facing changes? The Scalar.cast() API is enhanced and backwards compatible. * Closes: #35040 Authored-by: Dane Pitkin <[email protected]> Signed-off-by: Alenka Frim <[email protected]>
Casting of scalar now uses the compute kernel in pyarrow: #35395 Do we want to keep this issue open to also make changes to the |
I created #35560 to track the issue! |
Great Dane, thanks! |
apache#35395) ### Rationale for this change Scalar cast should use the computer kernel just like Arrays, instead of its own custom implementation. ### Are these changes tested? Added test cases for apacheGH-35370, apacheGH-34901, and apacheGH-35040 ### Are there any user-facing changes? The Scalar.cast() API is enhanced and backwards compatible. * Closes: apache#35040 Authored-by: Dane Pitkin <[email protected]> Signed-off-by: Alenka Frim <[email protected]>
apache#35395) ### Rationale for this change Scalar cast should use the computer kernel just like Arrays, instead of its own custom implementation. ### Are these changes tested? Added test cases for apacheGH-35370, apacheGH-34901, and apacheGH-35040 ### Are there any user-facing changes? The Scalar.cast() API is enhanced and backwards compatible. * Closes: apache#35040 Authored-by: Dane Pitkin <[email protected]> Signed-off-by: Alenka Frim <[email protected]>
…s because it requires tz database
…use it requires tz database (#35735) ### Rationale for this change Fix up of #35395, skipping one of the tests added in that PR on Windows, because the test requires access to a tz database. Authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
Describe the enhancement requested
See #34901 for a longer discussion, but summarizing: the
pyarrow.Scalar
object has acast()
method, but in contrast with other cast methods in pyarrow it does an unsafe cast by default. We should probably change this to do a safe cast by default, and at the same time also allow to specify CastOptions (so a user can still choose to do an unsafe cast).Example:
The python cast() method calls the C++
Scalar::ToCast
:arrow/cpp/src/arrow/scalar.h
Lines 99 to 100 in e488942
which currently indeed doesn't have the option to pass CastOptions.
In addition, it seems that for casting Scalars, we do have a somewhat custom implementation, and this doesn't use the generic Cast implementation (from the compute kernels), but has a custom
CastImpl
in scalar.cc. Not fully sure about the reason for this, but maybe historically we wanted to have scalar casting without relying on the optional compute module? (cfr #25025)Component(s)
C++
The text was updated successfully, but these errors were encountered: