asubiotto commented on code in PR #7517:
URL: https://github.com/apache/arrow-rs/pull/7517#discussion_r2099716748
##########
arrow-select/src/concat.rs:
##########
@@ -231,6 +231,45 @@ fn concat_bytes<T: ByteArrayType>(arrays: &[&dyn Array])
-> Result<ArrayRef, Arr
Ok(Arc::new(builder.finish()))
}
+fn concat_structs(arrays: &[&dyn Array], fields: &Fields) -> Result<ArrayRef,
ArrowError> {
+ let mut len = 0;
+ let mut has_nulls = false;
+ let structs = arrays
+ .iter()
+ .map(|a| {
+ len += a.len();
+ has_nulls |= a.null_count() > 0;
+ a.as_struct()
+ })
+ .collect::<Vec<_>>();
+
+ let nulls = has_nulls.then(|| {
+ let mut b = BooleanBufferBuilder::new(len);
+ for s in &structs {
+ match s.nulls() {
+ Some(n) => b.append_buffer(n.inner()),
+ None => b.append_n(s.len(), true),
+ }
+ }
+ NullBuffer::new(b.finish())
+ });
+
+ let mut column_concat_result = Vec::with_capacity(fields.len());
Review Comment:
Done.
##########
arrow-select/src/concat.rs:
##########
@@ -231,6 +231,45 @@ fn concat_bytes<T: ByteArrayType>(arrays: &[&dyn Array])
-> Result<ArrayRef, Arr
Ok(Arc::new(builder.finish()))
}
+fn concat_structs(arrays: &[&dyn Array], fields: &Fields) -> Result<ArrayRef,
ArrowError> {
+ let mut len = 0;
+ let mut has_nulls = false;
+ let structs = arrays
+ .iter()
+ .map(|a| {
+ len += a.len();
+ has_nulls |= a.null_count() > 0;
+ a.as_struct()
+ })
+ .collect::<Vec<_>>();
Review Comment:
We need to have these as StructArrays to call `column(i)` below so we might
as well downcast here I think. Happy to change this if I'm missing something.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]