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)), } } diff --git a/tests-integration/src/grpc.rs b/tests-integration/src/grpc.rs index 85940f3a366c..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), @@ -334,7 +335,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 +413,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() 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,