Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lyang24 committed Dec 5, 2024
1 parent 7a59359 commit 84a10a9
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions src/common/grpc-expr/src/alter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
28 changes: 28 additions & 0 deletions src/sql/src/parsers/alter_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 20 additions & 5 deletions src/sql/src/statements/alter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <column_name> SET FULLTEXT [WITH <options>]`
SetColumnFulltext {
column_name: Ident,
options: FulltextOptions,
},
/// `MODIFY COLUMN <column_name> UNSET FULLTEXT`
UnsetColumnFulltext {
column_name: Ident,
},
/// `MODIFY COLUMN <column_name> SET INVERTED INDEX`
SetColumnInvertedIndex {
column_name: Ident,
},
}

#[derive(Debug, Clone, PartialEq, Eq, Visit, VisitMut)]
pub enum UnsetIndexOperation {
/// `MODIFY COLUMN <column_name> UNSET FULLTEXT`
UnsetColumnFulltext {
column_name: Ident,
},

/// `MODIFY COLUMN <column_name> UNSET INVERTED INDEX`
UnsetColumnInvertedIndex {
column_name: Ident,
},

}

impl Display for AlterTableOperation {
Expand Down

0 comments on commit 84a10a9

Please sign in to comment.