diff --git a/Cargo.lock b/Cargo.lock index 65612d90514e..a78cfc6b6c27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4576,7 +4576,7 @@ dependencies = [ [[package]] name = "greptime-proto" version = "0.1.0" -source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=a875e976441188028353f7274a46a7e6e065c5d4#a875e976441188028353f7274a46a7e6e065c5d4" +source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=e77db40c93a46efdd4d0ca39b4de5620c3d650e4#e77db40c93a46efdd4d0ca39b4de5620c3d650e4" dependencies = [ "prost 0.12.6", "serde", diff --git a/Cargo.toml b/Cargo.toml index 2082d873866d..0a5f60199ef3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,7 +122,7 @@ etcd-client = "0.13" fst = "0.4.7" futures = "0.3" futures-util = "0.3" -greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "a875e976441188028353f7274a46a7e6e065c5d4" } +greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "e77db40c93a46efdd4d0ca39b4de5620c3d650e4" } hex = "0.4" humantime = "2.1" humantime-serde = "1.1" diff --git a/src/common/grpc-expr/src/alter.rs b/src/common/grpc-expr/src/alter.rs index 4c4ad0905bb3..3024d97ee19c 100644 --- a/src/common/grpc-expr/src/alter.rs +++ b/src/common/grpc-expr/src/alter.rs @@ -126,6 +126,12 @@ pub fn alter_expr_to_request(table_id: TableId, expr: AlterTableExpr) -> Result< Kind::UnsetColumnFulltext(c) => AlterKind::UnsetColumnFulltext { column_name: c.column_name, }, + Kind::SetColumnInvertedIndex(c) => AlterKind::SetColumnInvertedIndex { + column_name: c.column_name, + }, + Kind::UnsetColumnInvertedIndex(c) => AlterKind::UnsetColumnInvertedIndex { + column_name: c.column_name, + }, }; let request = AlterTableRequest { diff --git a/src/sql/src/parsers/alter_parser.rs b/src/sql/src/parsers/alter_parser.rs index f71a66bd9403..58fea4958ee0 100644 --- a/src/sql/src/parsers/alter_parser.rs +++ b/src/sql/src/parsers/alter_parser.rs @@ -144,6 +144,34 @@ impl ParserContext<'_> { AlterTableOperation::RenameTable { new_table_name } } Keyword::SET => { + match self.parser.next_token() { + TokenWithLocation { + token: Token::Word(w), + .. + } if w.keyword == INVERTED => { + self.parser + .expect_keyword(Keyword::INDEX) + .context(error::SyntaxSnafu)?; + + }, + TokenWithLocation { + token: Token::Word(w), + .. + } if w.keyword == Keyword::FULLTEXT => { + let _ = self.parser.next_token(); + let options = self + .parser + .parse_comma_separated(parse_string_options) + .context(error::SyntaxSnafu)? + .into_iter() + .map(|(key, value)| KeyValueOption { key, value }) + .collect(); + AlterTableOperation::SetTableOptions { options } + }, + _ => { + + } + } let _ = self.parser.next_token(); let options = self .parser diff --git a/src/sql/src/statements/alter.rs b/src/sql/src/statements/alter.rs index 8717a9d5d608..d91ce7344633 100644 --- a/src/sql/src/statements/alter.rs +++ b/src/sql/src/statements/alter.rs @@ -85,24 +85,39 @@ pub enum AlterTableOperation { RenameTable { new_table_name: String, }, + SetIndex { + options: SetIndexOperation + }, + UnsetIndex { + options: UnsetIndexOperation + } + +} + +#[derive(Debug, Clone, PartialEq, Eq, Visit, VisitMut)] +pub enum SetIndexOperation { /// `MODIFY COLUMN SET FULLTEXT [WITH ]` SetColumnFulltext { column_name: Ident, options: FulltextOptions, }, - /// `MODIFY COLUMN UNSET FULLTEXT` - UnsetColumnFulltext { - column_name: Ident, - }, /// `MODIFY COLUMN SET INVERTED INDEX` SetColumnInvertedIndex { column_name: Ident, }, +} + +#[derive(Debug, Clone, PartialEq, Eq, Visit, VisitMut)] +pub enum UnsetIndexOperation { + /// `MODIFY COLUMN UNSET FULLTEXT` + UnsetColumnFulltext { + column_name: Ident, + }, + /// `MODIFY COLUMN UNSET INVERTED INDEX` UnsetColumnInvertedIndex { column_name: Ident, }, - } impl Display for AlterTableOperation {