Skip to content

Commit a455ed6

Browse files
committed
Fix based on comments
1 parent 354ccc8 commit a455ed6

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/parser/mod.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9988,6 +9988,18 @@ impl<'a> Parser<'a> {
99889988
})
99899989
}
99909990

9991+
/// Parse Redshift `ALTER SORTKEY (column_list)`.
9992+
///
9993+
/// See <https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html>
9994+
fn parse_alter_sort_key(&mut self) -> Result<AlterTableOperation, ParserError> {
9995+
self.expect_keyword_is(Keyword::ALTER)?;
9996+
self.expect_keyword_is(Keyword::SORTKEY)?;
9997+
self.expect_token(&Token::LParen)?;
9998+
let columns = self.parse_comma_separated(|p| p.parse_expr())?;
9999+
self.expect_token(&Token::RParen)?;
10000+
Ok(AlterTableOperation::AlterSortKey { columns })
10001+
}
10002+
999110003
/// Parse a single `ALTER TABLE` operation and return an `AlterTableOperation`.
999210004
pub fn parse_alter_table_operation(&mut self) -> Result<AlterTableOperation, ParserError> {
999310005
let operation = if self.parse_keyword(Keyword::ADD) {
@@ -10266,12 +10278,9 @@ impl<'a> Parser<'a> {
1026610278
column_position,
1026710279
}
1026810280
} else if self.parse_keyword(Keyword::ALTER) {
10269-
// Redshift: ALTER SORTKEY (column_list)
10270-
if self.parse_keyword(Keyword::SORTKEY) {
10271-
self.expect_token(&Token::LParen)?;
10272-
let columns = self.parse_comma_separated(|p| p.parse_expr())?;
10273-
self.expect_token(&Token::RParen)?;
10274-
return Ok(AlterTableOperation::AlterSortKey { columns });
10281+
if self.peek_keyword(Keyword::SORTKEY) {
10282+
self.prev_token();
10283+
return self.parse_alter_sort_key();
1027510284
}
1027610285

1027710286
let _ = self.parse_keyword(Keyword::COLUMN); // [ COLUMN ]

0 commit comments

Comments
 (0)