-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Refactor spark bit_get() signature away from user defined
#18836
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
Conversation
| pub fn new() -> Self { | ||
| Self { | ||
| signature: Signature::user_defined(Volatility::Immutable), | ||
| signature: Signature::coercible( |
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.
Signature change here
| ) | ||
| } | ||
| }?; | ||
| fn spark_bit_get(args: &[ArrayRef]) -> Result<ArrayRef> { |
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.
This function I made private, and also did a few refactors to make it more compact.
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { |
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.
These tests were duplicated by the SLTs so removed them
| }?; | ||
| fn spark_bit_get(args: &[ArrayRef]) -> Result<ArrayRef> { | ||
| let [value, position] = take_function_args("bit_get", args)?; | ||
| let pos_arg = position.as_primitive::<Int32Type>(); |
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.
Is this safe to be done ?
From the other PR few days ago we know that position could be Null here.
| let pos_arg = position.as_primitive::<Int32Type>(); | |
| let pos_arg = position.as_primitive_opt::<Int32Type>() | |
| + .ok_or_else(|| internal_err!("Expected Int32 for position argument"))?; |
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.
It's safe, since we use Coercion::new_implicit then null types are casted to the target type (Int8). Also have an SLT test to verify this behaviour.
bit_get() signature away from user definedbit_get() signature away from user defined
alamb
left a comment
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.
| fn spark_bit_get(args: &[ArrayRef]) -> Result<ArrayRef> { | ||
| let [value, position] = take_function_args("bit_get", args)?; | ||
| let pos_arg = position.as_primitive::<Int32Type>(); | ||
| let ret = downcast_integer_array!( |
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.
that is certainly nicer
…8836) ## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> Part of apache#12725 ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> Prefer to avoid user_defined for consistency in function definitions. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> Refactor signature of bit_get away from user_defined. Various other refactors. ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Existing tests. ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> There's a public function I made private but I don't think it was ever intended to be public.
Which issue does this PR close?
Part of #12725
Rationale for this change
Prefer to avoid user_defined for consistency in function definitions.
What changes are included in this PR?
Refactor signature of bit_get away from user_defined.
Various other refactors.
Are these changes tested?
Existing tests.
Are there any user-facing changes?
There's a public function I made private but I don't think it was ever intended to be public.