aharpervc commented on code in PR #1809: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1809#discussion_r2042359100
########## src/parser/mod.rs: ########## @@ -475,6 +475,12 @@ impl<'a> Parser<'a> { if expecting_statement_delimiter && word.keyword == Keyword::END { break; } + // Treat batch delimiter as an end of statement + if expecting_statement_delimiter && dialect_of!(self is MsSqlDialect) { + if let Some(Statement::Go { count: _ }) = stmts.last() { + expecting_statement_delimiter = false; + } + } Review Comment: I tried to explain this in the commit message & the "multiple_gos" example in the test. Basically, we want this to parse as 4 statements: ```mssql SELECT 1; GO SELECT 2; GO ``` The second `GO` is terminated by EOF, so no problem. But the first `GO` _cannot_ end with a semi colon (This overlaps with the ongoing "no semi-colons for statements" discussion but from a different angle). So we need to figure out how to parse it all out without the existing conventional semi-colon logic. What I came up with is to basically just look for a GO and have that signal that we _aren't_ then also looking for statement delimiter (eg, semi-colon). This also makes sense semantically because statements can't extend between batches, so any batch delimiter also functions as a statement delimiter. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org