Skip to content

Commit a0bc366

Browse files
author
Wojciech Padlo
committed
Snowflake: FILE_FORMAT='<name>' shorthand on CREATE STAGE
1 parent a30928b commit a0bc366

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/dialect/snowflake.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,24 @@ fn parse_stage_properties(parser: &mut Parser) -> Result<StageProperties, Parser
13511351
// [ file_format]
13521352
if parser.parse_keyword(Keyword::FILE_FORMAT) {
13531353
parser.expect_token(&Token::Eq)?;
1354-
file_format = parser.parse_key_value_options(true, &[])?.options;
1354+
if parser.peek_token().token == Token::LParen {
1355+
file_format = parser.parse_key_value_options(true, &[])?.options;
1356+
} else {
1357+
// Shorthand `FILE_FORMAT = '<name>'` / `FILE_FORMAT = <ident>` is
1358+
// sugar for `FILE_FORMAT = (FORMAT_NAME = <name>)` — normalize it.
1359+
let tok = parser.peek_token();
1360+
let value = match tok.token {
1361+
Token::Word(w) => {
1362+
parser.next_token();
1363+
Value::Placeholder(w.value.clone()).with_span(tok.span)
1364+
}
1365+
_ => parser.parse_value()?,
1366+
};
1367+
file_format = vec![KeyValueOption {
1368+
option_name: "FORMAT_NAME".to_string(),
1369+
option_value: KeyValueOptionKind::Single(value),
1370+
}];
1371+
}
13551372
}
13561373

13571374
// [ copy_options ]

0 commit comments

Comments
 (0)