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


##########
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:
   @alamb That's a great catch! Thank you for calling that out.
   
   I just pushed up the fixes for this which also include a new unit test 
covering this behavior. Additionally, there's an extremely small and 
internal-facing micro-optimization which removes the `.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