You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tsql: support Azure Synapse OPENROWSET WITH schema clause #8151
The tsql dialect cannot parse an Azure Synapse OPENROWSET table source when it is followed by the documented WITH (...) schema definition. This prevents SQLMesh from parsing valid Synapse views and caused a QESD Synapse lineage build to fail.
OPENROWSET appears to be partially supported: SQLGlot can parse the table-valued function and its BULK options, but the WITH (...) AS alias schema clause is rejected.
The parse error is reported at the WITH schema clause. The same construct failed in SQLGlot 30.8.0, which was the version installed by SQLMesh 0.236.1 in the CI job.
For comparison, removing the WITH (...) clause allows the corresponding table source to parse:
SELECT*FROM OPENROWSET(
BULK ('file.csv'),
DATA_SOURCE ='datasource_gbrwlake',
FORMAT ='csv'
) AS source_table
Expected behavior
The T-SQL parser should represent the OPENROWSET source, its options, the WITH column definitions, and the table alias in the AST, and should round-trip the statement for the tsql dialect. A focused parser and generator test for Azure Synapse OPENROWSET ... WITH (...) syntax would be useful.
Related issues and compatibility context
SQLGlot #7428 reports Azure Synapse-specific T-SQL syntax that is unsupported. The maintainer response says Azure Synapse is not officially supported and considers the issue out of scope.
SQLGlot #5142 documents additional Azure SQL/T-SQL syntax gaps and describes this support as low priority, while welcoming a well-tested PR.
SQLMesh #5948 records that SQLMesh 0.236.1 pins SQLGlot to ~=30.8.0 and that independently overriding SQLGlot to >=30.14.0 exposed import incompatibilities. SQLGlot 30.17.0 still produces the OPENROWSET ... WITH (...) parse error, so upgrading SQLGlot alone does not resolve this syntax gap.
If Azure Synapse-specific syntax is intentionally out of scope for the core tsql dialect, please advise whether this should be implemented as a separate dialect or whether a narrowly scoped, well-tested OPENROWSET contribution would be considered.
Yeah, the T-SQL dialect implements SQL Server syntax. Implementing a separate dialect that subclasses TSQL under Python-sqlglot (sqlglot[c] doesn't allow interpreted subclasses) and overriding according to your project's needs is the way to go. Supporting Azure syntax is out of scope for SQLGlot at the moment.
Hi @georgesittas I do understand that it would be a bit of work, but I've given it a go, would you consider having a look at my PR? #8160 Hopefully not too much left in there to fix.
Likewise I also fixed SQLMesh/sqlmesh#5952 to allow for Synapse on SQLMesh when put together.
Activity
georgesittas commentedon Aug 13, 2026
Yeah, the T-SQL dialect implements SQL Server syntax. Implementing a separate dialect that subclasses
TSQLunder Python-sqlglot (sqlglot[c]doesn't allow interpreted subclasses) and overriding according to your project's needs is the way to go. Supporting Azure syntax is out of scope for SQLGlot at the moment.dvasdekis commentedon Aug 13, 2026
Hi @georgesittas I do understand that it would be a bit of work, but I've given it a go, would you consider having a look at my PR? #8160 Hopefully not too much left in there to fix.
Likewise I also fixed SQLMesh/sqlmesh#5952 to allow for Synapse on SQLMesh when put together.
Efcharisto poli!
georgesittas commentedon Aug 13, 2026
Replied: #8160 (comment).