alamb commented on code in PR #8935:
URL: https://github.com/apache/arrow-rs/pull/8935#discussion_r2604592546


##########
arrow-avro/src/writer/encoder.rs:
##########
@@ -629,29 +615,21 @@ impl<'a> FieldEncoder<'a> {
             }
         };
         // Compute the effective null state from writer-declared nullability 
and data nulls.
-        let null_state = match (nullability, array.null_count() > 0) {
-            (None, false) => NullState::NonNullable,
-            (None, true) => {
-                return Err(ArrowError::InvalidArgumentError(format!(
-                    "Avro site '{}' is non-nullable, but array contains nulls",
-                    field.name()
-                )));
-            }
-            (Some(order), false) => {
-                // Optimization: drop any bitmap; emit a constant "value" 
branch byte.
-                NullState::NullableNoNulls {
-                    union_value_byte: union_value_branch_byte(order, false),
+        let null_state = match nullability {
+            None => NullState::NonNullable,
+            Some(order) => {
+                if let Some(nulls) = array.nulls().cloned() {

Review Comment:
   the prior code actually checked if there were zero nulls via 
`array.null_count()` there can be a null buffer that has no nulls in it.
   
   I think it is worth checking here still. Something like
   
   ```rust
                   if array.null_count() > 0 && let Some(nulls) = 
array.nulls().cloned() {
   ```
   



-- 
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]

Reply via email to