diff --git a/src/datatypes/src/json/value.rs b/src/datatypes/src/json/value.rs index e1f5e500b3..2767f455f3 100644 --- a/src/datatypes/src/json/value.rs +++ b/src/datatypes/src/json/value.rs @@ -427,8 +427,7 @@ impl JsonValue { /// - `Null` aligns to any type, and any value aligns to `Null` as `Null`. /// - Numbers are converted only within compatible number categories. /// - Arrays align each element recursively to the expected item type. - /// - Objects require `expected` to contain all fields from the current value. Missing expected - /// fields are filled with `Null`. + /// - Objects require `expected` to have all fields from the current value. /// - `Variant` preserves the original JSON payload as serialized bytes. /// /// Returns an error if the value cannot be aligned without losing existing object fields or @@ -467,7 +466,6 @@ impl JsonValue { .collect::>()?, ), - (JsonVariant::Object(kvs), _) if kvs.is_empty() => JsonVariant::Null, (JsonVariant::Object(mut kvs), JsonNativeType::Object(expected)) => { ensure!( expected.keys().len() >= kvs.keys().len() @@ -481,15 +479,12 @@ impl JsonValue { } ); - let mut object = BTreeMap::new(); for (field, field_type) in expected { if let Some((k, v)) = kvs.remove_entry(field) { - object.insert(k, helper(v, field_type)?); - } else { - object.insert(field.clone(), JsonVariant::Null); + kvs.insert(k, helper(v, field_type)?); } } - JsonVariant::Object(object) + JsonVariant::Object(kvs) } (v, JsonNativeType::Variant) => { diff --git a/src/datatypes/src/vectors/json/builder.rs b/src/datatypes/src/vectors/json/builder.rs index c552bc9e52..56527b44ce 100644 --- a/src/datatypes/src/vectors/json/builder.rs +++ b/src/datatypes/src/vectors/json/builder.rs @@ -62,10 +62,6 @@ impl JsonVectorBuilder { continue; } value.try_align(&self.merged_type)?; - if value.is_null() { - builder.push_null(); - continue; - } let value_ref = json_variant_to_struct_value_ref(value.variant(), struct_type.clone())?; builder.push_struct_value_ref(value_ref)?; }