From 00c65ca2289670d737b5e52f022178ab1084f81f Mon Sep 17 00:00:00 2001 From: evenyag Date: Thu, 14 Sep 2023 19:10:20 +0800 Subject: [PATCH 1/4] fix: procedure panic on renaming table --- src/common/meta/src/ddl/alter_table.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/common/meta/src/ddl/alter_table.rs b/src/common/meta/src/ddl/alter_table.rs index 542f731576e1..95892e6967c1 100644 --- a/src/common/meta/src/ddl/alter_table.rs +++ b/src/common/meta/src/ddl/alter_table.rs @@ -54,8 +54,8 @@ use crate::table_name::TableName; pub struct AlterTableProcedure { context: DdlContext, data: AlterTableData, - /// proto alter Kind. - kind: alter_request::Kind, + /// proto alter Kind for adding/dropping columns. + kind: Option, } impl AlterTableProcedure { @@ -171,7 +171,7 @@ impl AlterTableProcedure { Ok(AlterRequest { region_id: region_id.as_u64(), schema_version: table_info.ident.version, - kind: Some(self.kind.clone()), + kind: self.kind.clone(), }) } @@ -461,7 +461,7 @@ impl AlterTableData { pub fn create_proto_alter_kind( table_info: &RawTableInfo, alter_kind: &Kind, -) -> Result<(alter_request::Kind, Option)> { +) -> Result<(Option, Option)> { match alter_kind { Kind::AddColumns(x) => { let mut next_column_id = table_info.meta.next_column_id; @@ -494,7 +494,7 @@ pub fn create_proto_alter_kind( .collect::>>()?; Ok(( - alter_request::Kind::AddColumns(AddColumns { add_columns }), + Some(alter_request::Kind::AddColumns(AddColumns { add_columns })), Some(next_column_id), )) } @@ -508,10 +508,12 @@ pub fn create_proto_alter_kind( .collect::>(); Ok(( - alter_request::Kind::DropColumns(DropColumns { drop_columns }), + Some(alter_request::Kind::DropColumns(DropColumns { + drop_columns, + })), None, )) } - Kind::RenameTable(_) => unreachable!(), + Kind::RenameTable(_) => Ok((None, None)), } } From 5f558cb8bf730ed42c314ff44bac320d846b1a97 Mon Sep 17 00:00:00 2001 From: evenyag Date: Thu, 14 Sep 2023 19:22:11 +0800 Subject: [PATCH 2/4] test: fix test_insert_and_select invalid arguments --- tests-integration/tests/grpc.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests-integration/tests/grpc.rs b/tests-integration/tests/grpc.rs index 48d7289a5bb8..d5a0c815e14f 100644 --- a/tests-integration/tests/grpc.rs +++ b/tests-integration/tests/grpc.rs @@ -191,7 +191,7 @@ fn expect_data() -> (Column, Column, Column, Column) { .collect(), ..Default::default() }), - semantic_type: SemanticType::Field as i32, + semantic_type: SemanticType::Tag as i32, datatype: ColumnDataType::String as i32, ..Default::default() }; @@ -363,14 +363,14 @@ fn testing_create_expr() -> CreateTableExpr { ColumnDef { name: "ts".to_string(), data_type: ColumnDataType::TimestampMillisecond as i32, // timestamp - is_nullable: true, + is_nullable: false, default_constraint: vec![], semantic_type: SemanticType::Timestamp as i32, }, ]; CreateTableExpr { - catalog_name: "".to_string(), - schema_name: "".to_string(), + catalog_name: "greptime".to_string(), + schema_name: "public".to_string(), table_name: "demo".to_string(), desc: "blabla little magic fairy".to_string(), column_defs, From 4b83c4dad1be8a5909b7111e30b743151b161ef7 Mon Sep 17 00:00:00 2001 From: evenyag Date: Thu, 14 Sep 2023 19:30:01 +0800 Subject: [PATCH 3/4] test: fix test_standalone_insert_and_query using wrong semantic type --- tests-integration/src/grpc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests-integration/src/grpc.rs b/tests-integration/src/grpc.rs index 85940f3a366c..a85df13c5ac4 100644 --- a/tests-integration/src/grpc.rs +++ b/tests-integration/src/grpc.rs @@ -334,7 +334,7 @@ CREATE TABLE {table_name} ( ..Default::default() }), null_mask: vec![32, 0], - semantic_type: SemanticType::Field as i32, + semantic_type: SemanticType::Tag as i32, datatype: ColumnDataType::Int32 as i32, }, Column { @@ -412,7 +412,7 @@ CREATE TABLE {table_name} ( key_columns: vec![ Column { column_name: "a".to_string(), - semantic_type: SemanticType::Field as i32, + semantic_type: SemanticType::Tag as i32, values: Some(Values { i32_values: a, ..Default::default() From bf5e45e7e5671d4248ee2f88493ca7da0d8cd037 Mon Sep 17 00:00:00 2001 From: evenyag Date: Thu, 14 Sep 2023 19:31:03 +0800 Subject: [PATCH 4/4] test: fix test_distributed_insert_delete_and_query semantic type --- tests-integration/src/grpc.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests-integration/src/grpc.rs b/tests-integration/src/grpc.rs index a85df13c5ac4..0a15b79b412f 100644 --- a/tests-integration/src/grpc.rs +++ b/tests-integration/src/grpc.rs @@ -195,9 +195,10 @@ mod test { r" CREATE TABLE {table_name} ( a INT, - b STRING PRIMARY KEY, + b STRING, ts TIMESTAMP, - TIME INDEX (ts) + TIME INDEX (ts), + PRIMARY KEY (a, b) ) PARTITION BY RANGE COLUMNS(a) ( PARTITION r0 VALUES LESS THAN (10), PARTITION r1 VALUES LESS THAN (20),