From 5f69630a1c35c919e568a6666d29414278a7d643 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Sat, 9 Sep 2023 17:01:59 -0700 Subject: [PATCH] fix: entries field is non-nullable --- arrow-array/src/array/map_array.rs | 8 ++++---- .../src/bin/arrow-json-integration-test.rs | 5 ++--- arrow-ipc/src/reader.rs | 4 ++-- arrow-json/src/writer.rs | 2 +- arrow-schema/src/ffi.rs | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/arrow-array/src/array/map_array.rs b/arrow-array/src/array/map_array.rs index fca49cd7836f..77a7b9d4d547 100644 --- a/arrow-array/src/array/map_array.rs +++ b/arrow-array/src/array/map_array.rs @@ -330,7 +330,7 @@ impl MapArray { Arc::new(Field::new( "entries", entry_struct.data_type().clone(), - true, + false, )), false, ); @@ -477,7 +477,7 @@ mod tests { Arc::new(Field::new( "entries", entry_struct.data_type().clone(), - true, + false, )), false, ); @@ -523,7 +523,7 @@ mod tests { Arc::new(Field::new( "entries", entry_struct.data_type().clone(), - true, + false, )), false, ); @@ -645,7 +645,7 @@ mod tests { Arc::new(Field::new( "entries", entry_struct.data_type().clone(), - true, + false, )), false, ); diff --git a/arrow-integration-testing/src/bin/arrow-json-integration-test.rs b/arrow-integration-testing/src/bin/arrow-json-integration-test.rs index 2c36e8d9b8ae..db5df8b58a6f 100644 --- a/arrow-integration-testing/src/bin/arrow-json-integration-test.rs +++ b/arrow-integration-testing/src/bin/arrow-json-integration-test.rs @@ -124,7 +124,7 @@ fn canonicalize_schema(schema: &Schema) -> Schema { let key_field = Arc::new(Field::new( "key", first_field.data_type().clone(), - first_field.is_nullable(), + false, )); let second_field = fields.get(1).unwrap(); let value_field = Arc::new(Field::new( @@ -135,8 +135,7 @@ fn canonicalize_schema(schema: &Schema) -> Schema { let fields = Fields::from([key_field, value_field]); let struct_type = DataType::Struct(fields); - let child_field = - Field::new("entries", struct_type, child_field.is_nullable()); + let child_field = Field::new("entries", struct_type, false); Arc::new(Field::new( field.name().as_str(), diff --git a/arrow-ipc/src/reader.rs b/arrow-ipc/src/reader.rs index 96cb4393ba58..75c91be21dde 100644 --- a/arrow-ipc/src/reader.rs +++ b/arrow-ipc/src/reader.rs @@ -1487,7 +1487,7 @@ mod tests { let keys_field = Arc::new(Field::new_dict( "keys", DataType::Dictionary(Box::new(DataType::Int8), Box::new(DataType::Utf8)), - true, + true, // It is technically not legal for this field to be null. 1, false, )); @@ -1506,7 +1506,7 @@ mod tests { Arc::new(Field::new( "entries", entry_struct.data_type().clone(), - true, + false, )), false, ); diff --git a/arrow-json/src/writer.rs b/arrow-json/src/writer.rs index a918f44b54ff..a5b5a78190b3 100644 --- a/arrow-json/src/writer.rs +++ b/arrow-json/src/writer.rs @@ -1385,7 +1385,7 @@ mod tests { Arc::new(Field::new( "entries", entry_struct.data_type().clone(), - true, + false, )), false, ); diff --git a/arrow-schema/src/ffi.rs b/arrow-schema/src/ffi.rs index cd3c207a56c5..a17dbe769f2e 100644 --- a/arrow-schema/src/ffi.rs +++ b/arrow-schema/src/ffi.rs @@ -833,7 +833,7 @@ mod tests { // Construct a map array from the above two let map_data_type = - DataType::Map(Arc::new(Field::new("entries", entry_struct, true)), true); + DataType::Map(Arc::new(Field::new("entries", entry_struct, false)), true); let arrow_schema = FFI_ArrowSchema::try_from(map_data_type).unwrap(); assert!(arrow_schema.map_keys_sorted());