Skip to content

Commit 1ebb6bc

Browse files
localstack-spiral[bot]spiral
andauthored
LAV-3144: accept inferred dynamic-table column comments (#3570)
Parse COMMENT as a column option when a Snowflake column definition omits its type. Capture and replay metadata for inferred and explicitly typed dynamic-table columns. ## Test matrix inferred type + plain comment x create/metadata -> tests/queries/test_dynamic_table_column_comments.py::test_dynamic_table_inferred_column_comments inferred type + escaped apostrophe x create/metadata -> tests/queries/test_dynamic_table_column_comments.py::test_dynamic_table_inferred_column_comments inferred type + no comment x boundary -> tests/queries/test_dynamic_table_column_comments.py::test_dynamic_table_inferred_column_comments explicit type + comment x create/describe -> tests/queries/test_dynamic_table_column_comments.py::test_dynamic_table_typed_column_comments non-string COMMENT value x error -> uncovered: Cloud reports unexpected column name while emulator reports unexpected literal; validation error parity is outside the accepted-form criteria. Co-authored-by: spiral <spiral@localhost>
1 parent cca5ef5 commit 1ebb6bc

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

‎src/parser/mod.rs‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10536,22 +10536,15 @@ impl<'a> Parser<'a> {
1053610536
if let Some(constraint) = self.parse_optional_table_constraint()? {
1053710537
constraints.push(constraint);
1053810538
} else if let Token::Word(_) = &self.peek_token_ref().token {
10539-
// A bare column name with no data type (`CREATE TABLE t(id) AS
10540-
// SELECT ...`) is only accepted when the dialect opts in and the
10541-
// name is immediately followed by a column-list terminator, so a
10542-
// genuinely malformed data type still surfaces its own error.
10539+
// A column without a type is accepted only before a list
10540+
// terminator or COMMENT, so malformed types still surface an error.
1054310541
if self.dialect.supports_create_table_optional_column_type()
10544-
&& matches!(
10542+
&& (matches!(
1054510543
self.peek_nth_token_ref(1).token,
1054610544
Token::Comma | Token::RParen
10547-
)
10545+
) || self.peek_nth_keyword(1, Keyword::COMMENT))
1054810546
{
10549-
let name = self.parse_identifier()?;
10550-
columns.push(ColumnDef {
10551-
name,
10552-
data_type: DataType::Unspecified,
10553-
options: vec![],
10554-
});
10547+
columns.push(self.parse_column_def_inner(true)?);
1055510548
} else {
1055610549
columns.push(self.parse_column_def()?);
1055710550
}
@@ -10635,7 +10628,9 @@ impl<'a> Parser<'a> {
1063510628
optional_data_type: bool,
1063610629
) -> Result<ColumnDef, ParserError> {
1063710630
let col_name = self.parse_identifier()?;
10638-
let data_type = if self.is_column_type_sqlite_unspecified() {
10631+
let data_type = if self.is_column_type_sqlite_unspecified()
10632+
|| (optional_data_type && self.peek_keyword(Keyword::COMMENT))
10633+
{
1063910634
DataType::Unspecified
1064010635
} else if optional_data_type {
1064110636
self.maybe_parse(|parser| parser.parse_data_type())?

0 commit comments

Comments
 (0)