-
Notifications
You must be signed in to change notification settings - Fork 810
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
special case concatenating single element array shortcut #492
Conversation
Codecov Report
@@ Coverage Diff @@
## master #492 +/- ##
=======================================
Coverage 82.65% 82.65%
=======================================
Files 165 165
Lines 45524 45536 +12
=======================================
+ Hits 37628 37640 +12
Misses 7896 7896
Continue to review full report at Codecov.
|
@@ -57,6 +57,9 @@ pub fn concat(arrays: &[&Array]) -> Result<ArrayRef> { | |||
return Err(ArrowError::ComputeError( | |||
"concat requires input of at least one array".to_string(), | |||
)); | |||
} else if arrays.len() == 1 { | |||
let array = arrays[0]; | |||
return Ok(array.slice(0, array.len())); |
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.
You might be able to do something like Ok(Array.clone())
instead?
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.
sadly Array
isn't cloneable
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.
if the param were passing in as ArrayRef
then it's possible but it's just pure ref.
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.
fwiw, this is because if it was clonable, it could not be a trait object. .slice(0, array.len())
is fine imo.
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.
LGTM
Which issue does this PR close?
concatenating single element array shortcut
Closes #.
Rationale for this change
no need to any work when the given array is single element
What changes are included in this PR?
Are there any user-facing changes?