Skip to content

feat(parser)!!: robust parsing for stored procedures#6955

Draft
geooo109 wants to merge 8 commits intomainfrom
geooo109/sp_tsql
Draft

feat(parser)!!: robust parsing for stored procedures#6955
geooo109 wants to merge 8 commits intomainfrom
geooo109/sp_tsql

Conversation

@geooo109
Copy link
Collaborator

@geooo109 geooo109 commented Feb 4, 2026

This PR adds parsing support for TSQL stored procedures.

In order to chunkify the input, we use the semicolon as the delimiter.
Each statement of the procedure is expected to have a semicolon at the end.
If the BEGIN/END is used for the batching of statements, the END must be followed by a semicolon again (if there are statements after it).

The parentheses of IF/WHILE statements aren't kept to the transpiled output.
Moreover, arbitrary nesting is supported for IF/ELSE and WHILE statements.

"tsql": "DROP TABLE IF EXISTS #TempTableName",
"spark": "DROP TABLE IF EXISTS TempTableName",
"tsql": "IF NOT OBJECT_ID('tempdb.dbo.#TempTableName', 'U') IS NULL BEGIN DROP TABLE #TempTableName",
# "spark": "DROP TABLE IF EXISTS TempTableName",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix broken transpilation.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

SQLGlot Integration Test Results

Comparing:

  • this branch (sqlglot:geooo109/sp_tsql, sqlglot version: geooo109/sp_tsql)
  • baseline (main, sqlglot version: 28.9.1.dev21)

⚠️ Limited to dialects: snowflake, bigquery

By Dialect

dialect main sqlglot:geooo109/sp_tsql difference links
bigquery -> bigquery 2592/2624 passed (98.8%) 2592/2624 passed (98.8%) No change full result / delta
bigquery -> duckdb 1848/2623 passed (70.5%) 1847/2623 passed (70.4%) No change full result / delta
snowflake -> duckdb 1519/2403 passed (63.2%) 1522/2403 passed (63.3%) ⬆ improved by 0.1% full result / delta
snowflake -> snowflake 2606/2623 passed (99.4%) 2606/2623 passed (99.4%) No change full result / delta

Overall

main: 10273 total, 8565 passed (pass rate: 83.4%), sqlglot version: 28.9.1.dev21

sqlglot:geooo109/sp_tsql: 10273 total, 8567 passed (pass rate: 83.4%), sqlglot version: geooo109/sp_tsql

Difference: No change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant