@@ -8221,39 +8221,16 @@ impl<'a> Parser<'a> {
82218221 Keyword::ROLE,
82228222 Keyword::POLICY,
82238223 Keyword::CONNECTOR,
8224+ Keyword::ICEBERG,
82248225 ])?;
82258226 match object_type {
82268227 Keyword::VIEW => self.parse_alter_view(),
82278228 Keyword::TYPE => self.parse_alter_type(),
8228- Keyword::TABLE => {
8229- let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
8230- let only = self.parse_keyword(Keyword::ONLY); // [ ONLY ]
8231- let table_name = self.parse_object_name(false)?;
8232- let on_cluster = self.parse_optional_on_cluster()?;
8233- let operations = self.parse_comma_separated(Parser::parse_alter_table_operation)?;
8234-
8235- let mut location = None;
8236- if self.parse_keyword(Keyword::LOCATION) {
8237- location = Some(HiveSetLocation {
8238- has_set: false,
8239- location: self.parse_identifier()?,
8240- });
8241- } else if self.parse_keywords(&[Keyword::SET, Keyword::LOCATION]) {
8242- location = Some(HiveSetLocation {
8243- has_set: true,
8244- location: self.parse_identifier()?,
8245- });
8246- }
8247-
8248- Ok(Statement::AlterTable {
8249- name: table_name,
8250- if_exists,
8251- only,
8252- operations,
8253- location,
8254- on_cluster,
8255- })
8229+ Keyword::ICEBERG => {
8230+ self.expect_keyword(Keyword::TABLE)?;
8231+ self.parse_alter_table(true)
82568232 }
8233+ Keyword::TABLE => self.parse_alter_table(false),
82578234 Keyword::INDEX => {
82588235 let index_name = self.parse_object_name(false)?;
82598236 let operation = if self.parse_keyword(Keyword::RENAME) {
@@ -8346,6 +8323,38 @@ impl<'a> Parser<'a> {
83468323 }
83478324 }
83488325
8326+ /// Parse a [Statement::AlterTable]
8327+ pub fn parse_alter_table(&mut self, iceberg: bool) -> Result<Statement, ParserError> {
8328+ let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
8329+ let only = self.parse_keyword(Keyword::ONLY); // [ ONLY ]
8330+ let table_name = self.parse_object_name(false)?;
8331+ let on_cluster = self.parse_optional_on_cluster()?;
8332+ let operations = self.parse_comma_separated(Parser::parse_alter_table_operation)?;
8333+
8334+ let mut location = None;
8335+ if self.parse_keyword(Keyword::LOCATION) {
8336+ location = Some(HiveSetLocation {
8337+ has_set: false,
8338+ location: self.parse_identifier()?,
8339+ });
8340+ } else if self.parse_keywords(&[Keyword::SET, Keyword::LOCATION]) {
8341+ location = Some(HiveSetLocation {
8342+ has_set: true,
8343+ location: self.parse_identifier()?,
8344+ });
8345+ }
8346+
8347+ Ok(Statement::AlterTable {
8348+ name: table_name,
8349+ if_exists,
8350+ only,
8351+ operations,
8352+ location,
8353+ on_cluster,
8354+ iceberg,
8355+ })
8356+ }
8357+
83498358 /// Parse a `CALL procedure_name(arg1, arg2, ...)`
83508359 /// or `CALL procedure_name` statement
83518360 pub fn parse_call(&mut self) -> Result<Statement, ParserError> {
0 commit comments