Skip to content

Commit 60d7744

Browse files
Snowflake: lower COPY FILE_FORMAT=() to the TOK_CONSTANT_LIST format-name error
1 parent c7af4d6 commit 60d7744

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/dialect/snowflake.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,22 @@ pub fn parse_copy_into(parser: &mut Parser) -> Result<Statement, ParserError> {
19251925
if parser.parse_keyword(Keyword::FILE_FORMAT) {
19261926
parser.expect_token(&Token::Eq)?;
19271927
if parser.peek_token().token == Token::LParen {
1928+
let paren_span = parser.peek_token().span;
19281929
file_format = parser.parse_key_value_options(true, &[], false)?.options;
1930+
if file_format.is_empty() {
1931+
// Snowflake parses an empty `FILE_FORMAT = ()` as a reference
1932+
// to its internal empty-constant-list token and then resolves
1933+
// that as a format name, so the clause fails with
1934+
// "File format 'TOK_CONSTANT_LIST' does not exist". Mirror
1935+
// that by lowering `()` to `FORMAT_NAME = TOK_CONSTANT_LIST`.
1936+
file_format = vec![KeyValueOption {
1937+
option_name: "FORMAT_NAME".to_string(),
1938+
option_value: KeyValueOptionKind::Single(
1939+
Value::Placeholder("TOK_CONSTANT_LIST".to_string())
1940+
.with_span(paren_span),
1941+
),
1942+
}];
1943+
}
19291944
} else {
19301945
// Shorthand `FILE_FORMAT = '<name>'` / `FILE_FORMAT = <ident>`
19311946
// is sugar for `FILE_FORMAT = (FORMAT_NAME = <name>)` —

0 commit comments

Comments
 (0)