From 89236c86f1b8e2df58e2d59b800e938a19ce97e6 Mon Sep 17 00:00:00 2001 From: Ruihang Xia Date: Fri, 26 Jan 2024 11:23:30 +0800 Subject: [PATCH 1/2] feat: don't map semantic type in metric engine Signed-off-by: Ruihang Xia --- src/metric-engine/src/data_region.rs | 8 ++++---- src/metric-engine/src/engine/put.rs | 13 ------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/metric-engine/src/data_region.rs b/src/metric-engine/src/data_region.rs index f9ee734ffc56..32f2633ea9c6 100644 --- a/src/metric-engine/src/data_region.rs +++ b/src/metric-engine/src/data_region.rs @@ -46,9 +46,9 @@ impl DataRegion { /// Submit an alter request to underlying physical region. /// - /// This method will change the semantic type of those given columns. - /// [SemanticType::Tag] will become [SemanticType::Field]. The procedure framework - /// ensures there is no concurrent conflict. + /// This method will change the nullability of those given columns. + /// [SemanticType::Tag] will become nullable column as it's shared between + /// logical regions. /// /// Invoker don't need to set up or verify the column id. This method will adjust /// it using underlying schema. @@ -89,7 +89,7 @@ impl DataRegion { .enumerate() .map(|(delta, mut c)| { if c.semantic_type == SemanticType::Tag { - c.semantic_type = SemanticType::Field; + c.column_schema = c.column_schema.with_nullable_set(); if !c.column_schema.data_type.is_string() { return ColumnTypeMismatchSnafu { column_type: c.column_schema.data_type, diff --git a/src/metric-engine/src/engine/put.rs b/src/metric-engine/src/engine/put.rs index 3d4bc1485bfb..f8c12ea78d0c 100644 --- a/src/metric-engine/src/engine/put.rs +++ b/src/metric-engine/src/engine/put.rs @@ -123,7 +123,6 @@ impl MetricEngineInner { } /// Perform metric engine specific logic to incoming rows. - /// - Change the semantic type of tag columns to field /// - Add table_id column /// - Generate tsid fn modify_rows(&self, table_id: TableId, rows: &mut Rows) -> Result<()> { @@ -141,18 +140,6 @@ impl MetricEngineInner { }) .collect::>(); - // generate new schema - rows.schema = rows - .schema - .clone() - .into_iter() - .map(|mut col| { - if col.semantic_type == SemanticType::Tag as i32 { - col.semantic_type = SemanticType::Field as i32; - } - col - }) - .collect::>(); // add table_name column rows.schema.push(ColumnSchema { column_name: DATA_SCHEMA_TABLE_ID_COLUMN_NAME.to_string(), From 0ac984d0813ab677ffcca72732aa36f39f2db3ad Mon Sep 17 00:00:00 2001 From: Ruihang Xia Date: Fri, 26 Jan 2024 11:37:26 +0800 Subject: [PATCH 2/2] remove duplicate set_null Signed-off-by: Ruihang Xia --- src/metric-engine/src/data_region.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/metric-engine/src/data_region.rs b/src/metric-engine/src/data_region.rs index 32f2633ea9c6..5564ef8e7751 100644 --- a/src/metric-engine/src/data_region.rs +++ b/src/metric-engine/src/data_region.rs @@ -89,7 +89,6 @@ impl DataRegion { .enumerate() .map(|(delta, mut c)| { if c.semantic_type == SemanticType::Tag { - c.column_schema = c.column_schema.with_nullable_set(); if !c.column_schema.data_type.is_string() { return ColumnTypeMismatchSnafu { column_type: c.column_schema.data_type,