Signed-off-by: luofucong <luofc@foxmail.com>
This commit is contained in:
luofucong
2026-07-03 18:16:02 +08:00
parent 3f9228ba30
commit 82ca54bd9a
2 changed files with 3 additions and 5 deletions

View File

@@ -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),
])))
);

View File

@@ -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} | |