Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/dialect/snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,8 @@ pub fn parse_stage_name_identifier(parser: &mut Parser) -> Result<Ident, ParserE
Token::Div => ident.push('/'),
Token::Plus => ident.push('+'),
Token::Minus => ident.push('-'),
Token::Eq => ident.push('='),
Token::Colon => ident.push(':'),
Token::Number(n, _) => ident.push_str(n),
Token::Word(w) => ident.push_str(&w.to_string()),
_ => return parser.expected_ref("stage name identifier", parser.peek_token_ref()),
Expand Down
23 changes: 23 additions & 0 deletions tests/sqlparser_snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,29 @@ fn test_snowflake_copy_into_stage_name_ends_with_parens() {
}
}

#[test]
fn test_snowflake_stage_name_with_special_chars() {
// Stage path with '=' (Hive-style partitioning)
let sql = "SELECT * FROM @stage/day=18/23.parquet";
let stmt = snowflake().parse_sql_statements(sql).unwrap();
assert_eq!(1, stmt.len());

// Stage path with ':' (time-based partitioning)
let sql = "SELECT * FROM @stage/0:18:23/23.parquet";
let stmt = snowflake().parse_sql_statements(sql).unwrap();
assert_eq!(1, stmt.len());

// COPY INTO with '=' in stage path
snowflake()
.parse_sql_statements("COPY INTO my_table FROM @stage/day=18/file.parquet")
.unwrap();

// COPY INTO with ':' in stage path
snowflake()
.parse_sql_statements("COPY INTO my_table FROM @stage/0:18:23/file.parquet")
.unwrap();
}

#[test]
fn test_snowflake_trim() {
let real_sql = r#"SELECT customer_id, TRIM(sub_items.value:item_price_id, '"', "a") AS item_price_id FROM models_staging.subscriptions"#;
Expand Down