From c3c6f66de4908206632c4d30f1763a3a931481cc Mon Sep 17 00:00:00 2001 From: Xiangjin Date: Fri, 22 Nov 2024 14:26:17 +0800 Subject: [PATCH 1/2] proto --- proto/data.proto | 4 ++++ src/prost/src/lib.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/proto/data.proto b/proto/data.proto index 9bb15ebcc8d62..cdafd78f2f9a6 100644 --- a/proto/data.proto +++ b/proto/data.proto @@ -69,6 +69,10 @@ message DataType { repeated DataType field_type = 6; // Name of the fields if it is a struct type. For other types it will be empty. repeated string field_names = 7; + // Optional name of custom type. + // Informative-only and populated at best effort. + // NOT to be used for comparison or lookup. + optional string unqualified_name = 8; } message StructArrayData { diff --git a/src/prost/src/lib.rs b/src/prost/src/lib.rs index 0ebd4d5f4a096..617b517103ffc 100644 --- a/src/prost/src/lib.rs +++ b/src/prost/src/lib.rs @@ -410,6 +410,7 @@ impl std::fmt::Debug for data::DataType { type_name, // currently all data types are nullable is_nullable: _, + unqualified_name, } = self; let type_name = data::data_type::TypeName::try_from(*type_name) @@ -417,6 +418,9 @@ impl std::fmt::Debug for data::DataType { .unwrap_or("Unknown"); let mut s = f.debug_struct(type_name); + if let Some(unqualified_name) = unqualified_name { + s.field("unqualified_name", unqualified_name); + } if self.precision != 0 { s.field("precision", precision); } From edfcb38b0e108167328e0ff154a26582267674ff Mon Sep 17 00:00:00 2001 From: Xiangjin Date: Fri, 22 Nov 2024 15:45:51 +0800 Subject: [PATCH 2/2] StructTypeInner::unqualified_name never read --- src/common/src/types/struct_type.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common/src/types/struct_type.rs b/src/common/src/types/struct_type.rs index d649ca665df42..916b23ee4c0e0 100644 --- a/src/common/src/types/struct_type.rs +++ b/src/common/src/types/struct_type.rs @@ -35,7 +35,8 @@ impl Debug for StructType { } } -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, educe::Educe)] +#[educe(PartialEq, Eq, PartialOrd, Ord, Hash)] struct StructTypeInner { /// Details about a struct type. There are 2 cases for a struct: /// 1. `field_names.len() == field_types.len()`: it represents a struct with named fields, @@ -44,6 +45,10 @@ struct StructTypeInner { /// e.g. `ROW(1, 2)`. field_names: Box<[String]>, field_types: Box<[DataType]>, + #[educe(PartialEq(ignore))] + #[educe(Ord(ignore))] + #[educe(Hash(ignore))] + unqualified_name: Option>, } impl StructType { @@ -59,6 +64,7 @@ impl StructType { Self(Arc::new(StructTypeInner { field_types: field_types.into(), field_names: field_names.into(), + unqualified_name: None, })) } @@ -68,6 +74,7 @@ impl StructType { Self(Arc::new(StructTypeInner { field_types: Box::new([]), field_names: Box::new([]), + unqualified_name: None, })) } @@ -76,6 +83,7 @@ impl StructType { Self(Arc::new(StructTypeInner { field_types: fields.into(), field_names: Box::new([]), + unqualified_name: None, })) } @@ -164,6 +172,7 @@ impl FromStr for StructType { Ok(Self(Arc::new(StructTypeInner { field_types: field_types.into(), field_names: field_names.into(), + unqualified_name: None, }))) } }