diff --git a/src/datatypes/src/json/value.rs b/src/datatypes/src/json/value.rs index 2767f455f3..8718d399fd 100644 --- a/src/datatypes/src/json/value.rs +++ b/src/datatypes/src/json/value.rs @@ -26,7 +26,7 @@ use snafu::{OptionExt, ResultExt, ensure}; use crate::Result; use crate::data_type::ConcreteDataType; use crate::error::{AlignJsonValueSnafu, SerializeSnafu}; -use crate::types::json_type::{JsonNativeType, JsonNumberType}; +use crate::types::json_type::{JsonNativeType, JsonNumberType, is_include}; use crate::types::{StructField, StructType}; use crate::value::{ListValue, StructValue, Value}; @@ -433,7 +433,7 @@ impl JsonValue { /// Returns an error if the value cannot be aligned without losing existing object fields or /// when a scalar type conversion is incompatible. pub(crate) fn try_align(&mut self, expected: &JsonNativeType) -> Result<()> { - if self.json_type() == expected { + if is_include(expected, self.json_type()) { return Ok(()); } @@ -887,14 +887,12 @@ mod tests { "items".to_string(), JsonVariant::Array(vec![JsonVariant::Object(BTreeMap::from([ ("id".to_string(), JsonVariant::from(1_u64)), - ("note".to_string(), JsonVariant::Null), ( "payload".to_string(), JsonVariant::Variant(br#"{"k":"v"}"#.to_vec()), ), ]))]), ), - ("name".to_string(), JsonVariant::Null), ]))) ); diff --git a/tests/cases/standalone/common/types/json/json2.result b/tests/cases/standalone/common/types/json/json2.result index d397966c21..3258089a89 100644 --- a/tests/cases/standalone/common/types/json/json2.result +++ b/tests/cases/standalone/common/types/json/json2.result @@ -146,7 +146,7 @@ select j.a, j.a.x from json2_table order by ts; | {"b":-2} | | | {"b":3} | | | {"b":-4} | | -| | | +| {"b":null} | | | | | | {"b":"s7"} | | | {"b":8} | |