Skip to content

Commit cf9ae16

Browse files
committed
Fixed stage name parsing for snowflake
1 parent 6691f31 commit cf9ae16

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/dialect/snowflake.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,8 @@ pub fn parse_stage_name_identifier(parser: &mut Parser) -> Result<Ident, ParserE
12471247
Token::Div => ident.push('/'),
12481248
Token::Plus => ident.push('+'),
12491249
Token::Minus => ident.push('-'),
1250+
Token::Eq => ident.push('='),
1251+
Token::Colon => ident.push(':'),
12501252
Token::Number(n, _) => ident.push_str(n),
12511253
Token::Word(w) => ident.push_str(&w.to_string()),
12521254
_ => return parser.expected_ref("stage name identifier", parser.peek_token_ref()),

tests/sqlparser_snowflake.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,6 +2640,29 @@ fn test_snowflake_copy_into_stage_name_ends_with_parens() {
26402640
}
26412641
}
26422642

2643+
#[test]
2644+
fn test_snowflake_stage_name_with_special_chars() {
2645+
// Stage path with '=' (Hive-style partitioning)
2646+
let sql = "SELECT * FROM @stage/day=18/23.parquet";
2647+
let stmt = snowflake().parse_sql_statements(sql).unwrap();
2648+
assert_eq!(1, stmt.len());
2649+
2650+
// Stage path with ':' (time-based partitioning)
2651+
let sql = "SELECT * FROM @stage/0:18:23/23.parquet";
2652+
let stmt = snowflake().parse_sql_statements(sql).unwrap();
2653+
assert_eq!(1, stmt.len());
2654+
2655+
// COPY INTO with '=' in stage path
2656+
snowflake().parse_sql_statements(
2657+
"COPY INTO my_table FROM @stage/day=18/file.parquet",
2658+
).unwrap();
2659+
2660+
// COPY INTO with ':' in stage path
2661+
snowflake().parse_sql_statements(
2662+
"COPY INTO my_table FROM @stage/0:18:23/file.parquet",
2663+
).unwrap();
2664+
}
2665+
26432666
#[test]
26442667
fn test_snowflake_trim() {
26452668
let real_sql = r#"SELECT customer_id, TRIM(sub_items.value:item_price_id, '"', "a") AS item_price_id FROM models_staging.subscriptions"#;

0 commit comments

Comments
 (0)