Skip to content

Commit 20599b0

Browse files
author
Wojciech Padlo
committed
Snowflake: FILE_FORMAT='<name>' shorthand on CREATE STAGE
1 parent 46bf5ed commit 20599b0

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
@@ -1302,7 +1302,24 @@ pub fn parse_create_stage(
13021302
// [ file_format]
13031303
if parser.parse_keyword(Keyword::FILE_FORMAT) {
13041304
parser.expect_token(&Token::Eq)?;
1305-
file_format = parser.parse_key_value_options(true, &[])?.options;
1305+
if parser.peek_token().token == Token::LParen {
1306+
file_format = parser.parse_key_value_options(true, &[])?.options;
1307+
} else {
1308+
// Shorthand `FILE_FORMAT = '<name>'` / `FILE_FORMAT = <ident>` is
1309+
// sugar for `FILE_FORMAT = (FORMAT_NAME = <name>)` — normalize it.
1310+
let tok = parser.peek_token();
1311+
let value = match tok.token {
1312+
Token::Word(w) => {
1313+
parser.next_token();
1314+
Value::Placeholder(w.value.clone()).with_span(tok.span)
1315+
}
1316+
_ => parser.parse_value()?,
1317+
};
1318+
file_format = vec![KeyValueOption {
1319+
option_name: "FORMAT_NAME".to_string(),
1320+
option_value: KeyValueOptionKind::Single(value),
1321+
}];
1322+
}
13061323
}
13071324

13081325
// [ copy_options ]

0 commit comments

Comments
 (0)