mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-07-04 04:50:37 +00:00
@@ -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),
|
||||
])))
|
||||
);
|
||||
|
||||
|
||||
@@ -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} | |
|
||||
|
||||
Reference in New Issue
Block a user