jecsand838 commented on code in PR #8492:
URL: https://github.com/apache/arrow-rs/pull/8492#discussion_r2389941944
##########
arrow-avro/src/codec.rs:
##########
@@ -208,7 +209,15 @@ impl AvroDataType {
/// Returns an arrow [`Field`] with the given name
pub fn field_with_name(&self, name: &str) -> Field {
- let nullable = self.nullability.is_some();
+ let mut nullable = self.nullability.is_some();
+ if !nullable {
+ if let Codec::Union(children, _, _) = self.codec() {
+ // If any encoded branch is `null`, mark field as nullable
+ if children.iter().any(|c| matches!(c.codec(), Codec::Null)) {
+ nullable = true;
+ }
+ }
+ }
Review Comment:
These changes along with the change on line 772 are related to **Bug 4:
Child nullability fix**
We had cases where a list/map child field didn’t get marked nullable when
the Avro type was a `["null", T]` union. The fix entailed:
* `AvroDataType::field_with_name(..)` now inspects union children and flags
the field as nullable if any branch is null.
* The map path (`Codec::Map`) is updated to use `field_with_name("value")`
rather than recomputing nullability by hand.
* With nullability now centralized in `field_with_name`, list `"item"` (and
other child fields built from `AvroDataType`) inherit the correct nullability
whenever null is part of the union.
* This removes divergent logic and fixes the child‑nullability mismatch
observed in tests.
--
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]