set_tblproperties (#1151)

This commit is contained in:
Jonathan Lehto 2024-03-01 13:42:21 -05:00 committed by GitHub
parent 10cc54e10e
commit a511c47bd0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 52 additions and 4 deletions

View file

@ -5124,6 +5124,20 @@ impl<'a> Parser<'a> {
}
}
pub fn parse_options_with_keywords(
&mut self,
keywords: &[Keyword],
) -> Result<Vec<SqlOption>, ParserError> {
if self.parse_keywords(keywords) {
self.expect_token(&Token::LParen)?;
let options = self.parse_comma_separated(Parser::parse_sql_option)?;
self.expect_token(&Token::RParen)?;
Ok(options)
} else {
Ok(vec![])
}
}
pub fn parse_index_type(&mut self) -> Result<IndexType, ParserError> {
if self.parse_keyword(Keyword::BTREE) {
Ok(IndexType::BTree)
@ -5385,10 +5399,18 @@ impl<'a> Parser<'a> {
let table_name = self.parse_object_name(false)?;
AlterTableOperation::SwapWith { table_name }
} else {
return self.expected(
"ADD, RENAME, PARTITION, SWAP or DROP after ALTER TABLE",
self.peek_token(),
);
let options: Vec<SqlOption> =
self.parse_options_with_keywords(&[Keyword::SET, Keyword::TBLPROPERTIES])?;
if !options.is_empty() {
AlterTableOperation::SetTblProperties {
table_properties: options,
}
} else {
return self.expected(
"ADD, RENAME, PARTITION, SWAP, DROP, or SET TBLPROPERTIES after ALTER TABLE",
self.peek_token(),
);
}
};
Ok(operation)
}