aharpervc opened a new pull request, #1831: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1831
This PR is a followup to https://github.com/apache/datafusion-sqlparser-rs/pull/1821 to address several difficulties I had parsing real world SQL files. There are 3 related enhancements here: 1. Introduce support for parsing `OPEN` statements, eg: `OPEN my_cursor` 2. Expand existing `FETCH` statement parsing support the `FROM` keyword. Eg, `FETCH NEXT FROM my_cursor`. The logic formerly only supported "FETCH NEXT IN" syntax 3. Introduce support for parsing `WHILE` statements, which is commonly used in conjunction with cursors. Eg `WHILE @@fetch_status = 0...`. This is a conditional statement block, much like IF & CASE, so that code has been structured similarly and placed adjacent to those statements. (4th thing -- a test helper introduced in this PR was brought over here, because it simplifies validating a test case. If the other PR merges first that commit can be dropped out of this branch). The effect of these changes is that this cursor example from the [SQL Server FETCH documentation page](https://learn.microsoft.com/en-us/sql/t-sql/language-elements/fetch-transact-sql?view=sql-server-ver16#a-using-fetch-in-a-simple-cursor) now successfully parses: ```mssql DECLARE Employee_Cursor CURSOR FOR SELECT LastName, FirstName FROM AdventureWorks2022.HumanResources.vEmployee WHERE LastName LIKE 'B%'; OPEN Employee_Cursor; FETCH NEXT FROM Employee_Cursor; WHILE @@FETCH_STATUS = 0 BEGIN FETCH NEXT FROM Employee_Cursor; END; CLOSE Employee_Cursor; DEALLOCATE Employee_Cursor ``` -- 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