Skip to content

Commit ff99bce

Browse files
refactor: make json value use json type (#7248)
Signed-off-by: luofucong <[email protected]>
1 parent 2f447e6 commit ff99bce

File tree

7 files changed

+341
-304
lines changed

7 files changed

+341
-304
lines changed

src/api/src/helper.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,9 @@ impl TryFrom<ConcreteDataType> for ColumnDataTypeWrapper {
442442
type_ext: Some(TypeExt::JsonType(JsonTypeExtension::JsonBinary.into())),
443443
}),
444444
JsonFormat::Native(inner) => {
445-
let inner_type = ColumnDataTypeWrapper::try_from(*inner.clone())?;
445+
let inner_type = ColumnDataTypeWrapper::try_from(
446+
ConcreteDataType::from(inner.as_ref()),
447+
)?;
446448
Some(ColumnDataTypeExtension {
447449
type_ext: Some(TypeExt::JsonNativeType(Box::new(
448450
JsonNativeTypeExtension {
@@ -1711,33 +1713,33 @@ mod tests {
17111713
type_ext: Some(TypeExt::StructType(StructTypeExtension {
17121714
fields: vec![
17131715
v1::StructField {
1714-
name: "id".to_string(),
1715-
datatype: ColumnDataTypeWrapper::int64_datatype()
1716+
name: "address".to_string(),
1717+
datatype: ColumnDataTypeWrapper::string_datatype()
17161718
.datatype()
17171719
.into(),
17181720
datatype_extension: None
17191721
},
17201722
v1::StructField {
1721-
name: "name".to_string(),
1722-
datatype: ColumnDataTypeWrapper::string_datatype()
1723+
name: "age".to_string(),
1724+
datatype: ColumnDataTypeWrapper::int64_datatype()
17231725
.datatype()
17241726
.into(),
17251727
datatype_extension: None
17261728
},
17271729
v1::StructField {
1728-
name: "age".to_string(),
1729-
datatype: ColumnDataTypeWrapper::int32_datatype()
1730+
name: "id".to_string(),
1731+
datatype: ColumnDataTypeWrapper::int64_datatype()
17301732
.datatype()
17311733
.into(),
17321734
datatype_extension: None
17331735
},
17341736
v1::StructField {
1735-
name: "address".to_string(),
1737+
name: "name".to_string(),
17361738
datatype: ColumnDataTypeWrapper::string_datatype()
17371739
.datatype()
17381740
.into(),
17391741
datatype_extension: None
1740-
}
1742+
},
17411743
]
17421744
}))
17431745
}))

src/datatypes/src/data_type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use crate::types::{
3333
BinaryType, BooleanType, DateType, Decimal128Type, DictionaryType, DurationMicrosecondType,
3434
DurationMillisecondType, DurationNanosecondType, DurationSecondType, DurationType, Float32Type,
3535
Float64Type, Int8Type, Int16Type, Int32Type, Int64Type, IntervalDayTimeType,
36-
IntervalMonthDayNanoType, IntervalType, IntervalYearMonthType, JsonFormat, JsonType, ListType,
37-
NullType, StringType, StructType, TimeMillisecondType, TimeType, TimestampMicrosecondType,
36+
IntervalMonthDayNanoType, IntervalType, IntervalYearMonthType, JsonType, ListType, NullType,
37+
StringType, StructType, TimeMillisecondType, TimeType, TimestampMicrosecondType,
3838
TimestampMillisecondType, TimestampNanosecondType, TimestampSecondType, TimestampType,
3939
UInt8Type, UInt16Type, UInt32Type, UInt64Type, VectorType,
4040
};
@@ -677,7 +677,7 @@ impl ConcreteDataType {
677677
}
678678

679679
pub fn json_native_datatype(inner_type: ConcreteDataType) -> ConcreteDataType {
680-
ConcreteDataType::Json(JsonType::new(JsonFormat::Native(Box::new(inner_type))))
680+
ConcreteDataType::Json(JsonType::new_native((&inner_type).into()))
681681
}
682682
}
683683

0 commit comments

Comments
 (0)