Skip to content
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

try_binary should not panic on unequaled array length. #2715

Closed
HaoYang670 opened this issue Sep 13, 2022 · 1 comment · Fixed by #2717
Closed

try_binary should not panic on unequaled array length. #2715

HaoYang670 opened this issue Sep 13, 2022 · 1 comment · Fixed by #2717
Assignees
Labels
arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog

Comments

@HaoYang670
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
The function try_binary currently panic on a.len() != b.len():

pub fn try_binary<A, B, F, O>(
    a: &PrimitiveArray<A>,
    b: &PrimitiveArray<B>,
    op: F,
) -> Result<PrimitiveArray<O>>
where
    A: ArrowPrimitiveType,
    B: ArrowPrimitiveType,
    O: ArrowPrimitiveType,
    F: Fn(A::Native, B::Native) -> Result<O::Native>,
{
    assert_eq!(a.len(), b.len());
    ...

It is better to let the function return an error in such case because:

  1. The return type of the function is a Result;
  2. a.length() != b.length() is a recoverable error

Describe the solution you'd like

  1. Replace panic with Err
  2. Update the docs

Describe alternatives you've considered
We could not do this

Additional context

@HaoYang670 HaoYang670 added the enhancement Any new improvement worthy of a entry in the changelog label Sep 13, 2022
@HaoYang670 HaoYang670 self-assigned this Sep 13, 2022
@alamb
Copy link
Contributor

alamb commented Sep 16, 2022

label_issue.py automatically added labels {'arrow'} from #2717

@alamb alamb added the arrow Changes to the arrow crate label Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants