-
Notifications
You must be signed in to change notification settings - Fork 839
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
Allow creation of String arrays from &Option<&str> iterators #680
Conversation
Codecov Report
@@ Coverage Diff @@
## master #680 +/- ##
=======================================
Coverage 82.44% 82.44%
=======================================
Files 168 168
Lines 47326 47347 +21
=======================================
+ Hits 39016 39034 +18
- Misses 8310 8313 +3
Continue to review full report at Codecov.
|
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.
Thank you very much @koomen this looks awesome. In addition to looking at the code, I also tried out the example from #598 and it works like a charm ❤️
fn main() {
let string_array: ArrayRef = Arc::new([Some("foo"), None, Some("bar")].into_iter().collect::<StringArray>());
println!("My awesome string array: {:?}", string_array);
}
Output
My awesome string array: StringArray
[
"foo",
null,
"bar",
]
@alamb Thank you for taking a look! Noob question: Do I need to do anything else to merge this? I'm assuming that someone with permission will do so at some point, but don't want to leave this dangling if it is in fact gating on me :) |
Nope no worry @koomen -- nothing is waiting on you. I am waiting to see if any of the other maintainers wants to comment and if not I plan to merge it in later today or tomorrow. Also, FWIW I plan to backport this for inclusion in 5.2.0 (eta release early next week) |
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. Thanks for your contribution!
Co-authored-by: Jorge Leitao <jorgecarleitao@gmail.com>
Given I plan to make a 5.2.0 release candidate today I took the liberty of applying @jorgecarleitao 's suggestions to add links to the doc comments to this PR and will merge when it passes CI. cc @koomen Thanks again |
* Allow creation of String arrays from &Option<&str> iterators * Add links in doc comments Co-authored-by: Jorge Leitao <jorgecarleitao@gmail.com> Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org> Co-authored-by: Jorge Leitao <jorgecarleitao@gmail.com>
…686) * Allow creation of String arrays from &Option<&str> iterators * Add links in doc comments Co-authored-by: Jorge Leitao <jorgecarleitao@gmail.com> Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org> Co-authored-by: Jorge Leitao <jorgecarleitao@gmail.com> Co-authored-by: Pete Koomen <koomen@gmail.com> Co-authored-by: Jorge Leitao <jorgecarleitao@gmail.com>
Which issue does this PR close?
Closes #598.
Rationale for this change
What changes are included in this PR?
Added an implementation of
FromIterator<&Option<Ptr>> where Ptr: AsRef<str>
forGenericStringArray<OffsetSize>
. The new implementation converts iterated values into&str
and wraps in an ownedOption
, then uses the existingFromIterator<Option<Ptr>>
implementation tocollect
into aGenericStringArray
.Are there any user-facing changes?
Users can now create string arrays from
&Option<&str>
iterators. No breaking changes.