Skip to content

Commit 5bf0f14

Browse files
refactor: make json value use json type
Signed-off-by: luofucong <[email protected]>
1 parent ee35ec0 commit 5bf0f14

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
@@ -406,7 +406,9 @@ impl TryFrom<ConcreteDataType> for ColumnDataTypeWrapper {
406406
type_ext: Some(TypeExt::JsonType(JsonTypeExtension::JsonBinary.into())),
407407
}),
408408
JsonFormat::Native(inner) => {
409-
let inner_type = ColumnDataTypeWrapper::try_from(*inner.clone())?;
409+
let inner_type = ColumnDataTypeWrapper::try_from(
410+
ConcreteDataType::from(inner.as_ref()),
411+
)?;
410412
Some(ColumnDataTypeExtension {
411413
type_ext: Some(TypeExt::JsonNativeType(Box::new(
412414
JsonNativeTypeExtension {
@@ -1627,33 +1629,33 @@ mod tests {
16271629
type_ext: Some(TypeExt::StructType(StructTypeExtension {
16281630
fields: vec![
16291631
v1::StructField {
1630-
name: "id".to_string(),
1631-
datatype: ColumnDataTypeWrapper::int64_datatype()
1632+
name: "address".to_string(),
1633+
datatype: ColumnDataTypeWrapper::string_datatype()
16321634
.datatype()
16331635
.into(),
16341636
datatype_extension: None
16351637
},
16361638
v1::StructField {
1637-
name: "name".to_string(),
1638-
datatype: ColumnDataTypeWrapper::string_datatype()
1639+
name: "age".to_string(),
1640+
datatype: ColumnDataTypeWrapper::int64_datatype()
16391641
.datatype()
16401642
.into(),
16411643
datatype_extension: None
16421644
},
16431645
v1::StructField {
1644-
name: "age".to_string(),
1645-
datatype: ColumnDataTypeWrapper::int32_datatype()
1646+
name: "id".to_string(),
1647+
datatype: ColumnDataTypeWrapper::int64_datatype()
16461648
.datatype()
16471649
.into(),
16481650
datatype_extension: None
16491651
},
16501652
v1::StructField {
1651-
name: "address".to_string(),
1653+
name: "name".to_string(),
16521654
datatype: ColumnDataTypeWrapper::string_datatype()
16531655
.datatype()
16541656
.into(),
16551657
datatype_extension: None
1656-
}
1658+
},
16571659
]
16581660
}))
16591661
}))

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)