Skip to content

Commit eb0da61

Browse files
localstack-spiral[bot]spiralsabir-akhadov-localstackclaude
authored
LAV-2499: Support ALTER DYNAMIC TABLE column comments (#2892)
* LAV-2499: support dynamic table column comments Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud> * LAV-2499: reject identifier column comments Restrict dynamic-table column comments to Snowflake single-quoted and dollar-quoted string literals, with real-Snowflake snapshots for bare and double-quoted identifier errors.\n\n## Deviations\n\n- Reviewer feedback requested that ALTER DYNAMIC TABLE column-comment actions reject ordinary tables. A real-Snowflake snapshot proves this spelling succeeds and updates the ordinary table column comment, so the existing behavior is retained as required by the repository's snapshot precedence rule. Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud> * LAV-2499: snapshot column comment errors Route dynamic-table column-comment failures through the wire-level snapshot fixture and align the missing-object IF EXISTS source position with Snowflake. Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud> --------- Co-authored-by: spiral <spiral@localhost> Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 0a9f5aa commit eb0da61

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

‎src/ast/ddl.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,6 @@ pub enum AlterColumnOperation {
14441444
/// The comment text.
14451445
comment: String,
14461446
},
1447-
14481447
/// `UNSET COMMENT`
14491448
///
14501449
/// Snowflake: clear the column comment.

‎src/dialect/snowflake.rs‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,20 +1607,31 @@ fn parse_alter_dynamic_table_column_comments(
16071607
) -> Result<Vec<AlterTableOperation>, ParserError> {
16081608
let _ = parser.next_token(); // ALTER | MODIFY
16091609
let parenthesized = parser.consume_token(&Token::LParen);
1610-
let operations = parser.parse_comma_separated(|parser| {
1610+
let mut operations = Vec::new();
1611+
loop {
16111612
let _ = parser.parse_keyword(Keyword::COLUMN);
16121613
let column_name = parser.parse_identifier()?;
16131614
let op = if parser.parse_keyword(Keyword::COMMENT) {
1614-
AlterColumnOperation::Comment {
1615-
comment: parser.parse_literal_string()?,
1616-
}
1615+
let token = parser.next_token();
1616+
let comment = match token.token {
1617+
Token::SingleQuotedString(value) => value,
1618+
Token::DollarQuotedString(value) => value.value,
1619+
_ => return parser.expected("string literal", token),
1620+
};
1621+
AlterColumnOperation::Comment { comment }
16171622
} else if parser.parse_keywords(&[Keyword::UNSET, Keyword::COMMENT]) {
16181623
AlterColumnOperation::UnsetComment
16191624
} else {
1620-
return parser.expected_ref("COMMENT or UNSET COMMENT", parser.peek_token_ref());
1625+
return parser.expected_ref(
1626+
"COMMENT or UNSET COMMENT after column name",
1627+
parser.peek_token_ref(),
1628+
);
16211629
};
1622-
Ok(AlterTableOperation::AlterColumn { column_name, op })
1623-
})?;
1630+
operations.push(AlterTableOperation::AlterColumn { column_name, op });
1631+
if !parser.consume_token(&Token::Comma) {
1632+
break;
1633+
}
1634+
}
16241635
if parenthesized {
16251636
parser.expect_token(&Token::RParen)?;
16261637
}

0 commit comments

Comments
 (0)