Fix: Snowflake ALTER SESSION cannot be followed by other statements. (#1786)

Co-authored-by: Roman Borschel <roman@cluvio.com>
This commit is contained in:
Roman Borschel 2025-03-31 18:09:58 +02:00 committed by GitHub
parent 25bb871175
commit 45420cedd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 6 deletions

View file

@ -1013,9 +1013,15 @@ fn parse_session_options(
let mut options: Vec<KeyValueOption> = Vec::new();
let empty = String::new;
loop {
match parser.next_token().token {
Token::Comma => continue,
let next_token = parser.peek_token();
match next_token.token {
Token::SemiColon | Token::EOF => break,
Token::Comma => {
parser.advance_token();
continue;
}
Token::Word(key) => {
parser.advance_token();
if set {
let option = parse_option(parser, key)?;
options.push(option);
@ -1028,10 +1034,7 @@ fn parse_session_options(
}
}
_ => {
if parser.peek_token().token == Token::EOF {
break;
}
return parser.expected("another option", parser.peek_token());
return parser.expected("another option or end of statement", next_token);
}
}
}

View file

@ -3505,3 +3505,14 @@ fn test_alter_session() {
);
snowflake().one_statement_parses_to("ALTER SESSION UNSET a\nB", "ALTER SESSION UNSET a, B");
}
#[test]
fn test_alter_session_followed_by_statement() {
let stmts = snowflake()
.parse_sql_statements("ALTER SESSION SET QUERY_TAG='hello'; SELECT 42")
.unwrap();
match stmts[..] {
[Statement::AlterSession { .. }, Statement::Query { .. }] => {}
_ => panic!("Unexpected statements: {:?}", stmts),
}
}