Skip to content

Commit 9d5a171

Browse files
authored
Fixed stage name parsing for snowflake (#2265)
1 parent 738f12d commit 9d5a171

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/dialect/snowflake.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,8 @@ pub fn parse_stage_name_identifier(parser: &mut Parser) -> Result<Ident, ParserE
12581258
Token::Div => ident.push('/'),
12591259
Token::Plus => ident.push('+'),
12601260
Token::Minus => ident.push('-'),
1261+
Token::Eq => ident.push('='),
1262+
Token::Colon => ident.push(':'),
12611263
Token::Number(n, _) => ident.push_str(n),
12621264
Token::Word(w) => ident.push_str(&w.to_string()),
12631265
_ => return parser.expected_ref("stage name identifier", parser.peek_token_ref()),

tests/sqlparser_snowflake.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,6 +2640,21 @@ 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+
snowflake().verified_stmt("SELECT * FROM @stage/day=18/23.parquet");
2647+
2648+
// Stage path with ':' (time-based partitioning)
2649+
snowflake().verified_stmt("SELECT * FROM @stage/0:18:23/23.parquet");
2650+
2651+
// COPY INTO with '=' in stage path
2652+
snowflake().verified_stmt("COPY INTO my_table FROM @stage/day=18/file.parquet");
2653+
2654+
// COPY INTO with ':' in stage path
2655+
snowflake().verified_stmt("COPY INTO my_table FROM @stage/0:18:23/file.parquet");
2656+
}
2657+
26432658
#[test]
26442659
fn test_snowflake_trim() {
26452660
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)