You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Jefffrey (via GitHub)" <gi...@apache.org> on 2026/10/06 01:52:07 UTC

Re: [PR] fix: preserve union nullability when introducing nulls [arrow-rs]

Jefffrey commented on code in PR #11288:
URL: https://github.com/apache/arrow-rs/pull/11288#discussion_r4190740402


##########
arrow-data/src/transform/union.rs:
##########
@@ -77,23 +77,27 @@ pub(super) fn extend_nulls_dense(
     let DataType::Union(fields, _) = &mutable.data_type else {
         unreachable!()
     };
-    let first_type_id = fields
+    let null_type_id = fields
         .iter()
-        .next()
-        .expect("union must have at least one field")
+        .find(|(_, field)| field.is_nullable())
+        .expect("cannot extend nulls in a union with no nullable field")

Review Comment:
   can these be errors instead of panics, since the function can already return an error



##########
arrow-data/src/transform/union.rs:
##########
@@ -104,16 +108,16 @@ pub(super) fn extend_nulls_sparse(
     let DataType::Union(fields, _) = &mutable.data_type else {
         unreachable!()
     };
-    let first_type_id = fields
+    let null_type_id = fields
         .iter()
-        .next()
-        .expect("union must have at least one field")
+        .find(|(_, field)| field.is_nullable())
+        .expect("cannot extend nulls in a union with no nullable field")

Review Comment:
   same here



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org