FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(format): add transpile_meta opt-in for dialect-aware MODEL headers by albertosuman-1k5 · Pull Request #5944 · SQLMesh/sqlmesh · GitHub

feat(format): add transpile_meta opt-in for dialect-aware MODEL headers - #5944

Open
albertosuman-1k5 wants to merge 1 commit into
SQLMesh:mainfrom
1K5-TECH:feat/format-transpile-meta
Open

feat(format): add transpile_meta opt-in for dialect-aware MODEL headers#5944
albertosuman-1k5 wants to merge 1 commit into
SQLMesh:mainfrom
1K5-TECH:feat/format-transpile-meta

Conversation

Copy link
Copy Markdown
Contributor

Summary

Context

#5864 stopped transpiling meta expressions to avoid corrupting SQLMesh DDL booleans. That also rewrote dialect-specific header values (for example DATETIME2(6) → TIMESTAMP(6)). A surgical per-property approach (see #5926 for columns) would need similar handling for audits, labels, macros, and other header properties; this flag restores the previous whole-header behavior as an explicit opt-in instead.

Trade-off: enabling the flag reopens the T-SQL boolean rewrite from #5773 for SQLMesh properties in the header. Documented in docs/reference/configuration.md.

Test plan

  • Unit tests for format_model_expressions(..., transpile_meta=True) (multi-expression and single-meta paths)
  • Config test that transpile_meta is excluded from generator_options (does not leak into SQLGlot Generator)
  • End-to-end Context.format() with FormatConfig(transpile_meta=True) preserves DATETIME2(6)
  • Manual: project with T-SQL headers containing columns / audits / macros — format with and without the flag

Made with Cursor

Projects that author MODEL/AUDIT/METRIC headers in warehouse dialect lose
dialect-specific values (column types, audits, macros) when format forces
dialect=None. Add an opt-in format.transpile_meta flag to restore the old
header rendering while keeping dialect-agnostic headers as the default.

Signed-off-by: Alberto Suman <alberto.suman@1komma5grad.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

fresioAS commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@albertosuman-1k5
I'm not sure I understand the rationale here? We changed all our T-SQL models over to dialect agnostic headers - the main reason being that (1=1) was not respected and we got into issues with everything from disable_restatement (1=0) to formatting (1=0) etc. In addition we had fields like description being [] instead of ''.

Based on this I don't see who format.transpile_meta: true would be useful for?

On the other side - it is a pain now when the formatter wants to change our columns to something that does not exist - hence the proposed PR #5926

mday-io commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

@albertosuman-1k5 thank you very much for proposing this. I do worry that this all-or-nothing approach will continue to cause people headaches. I believe #5926 by @fresioAS (with a few additions) might get us a quick-fix and set a foundation for a more scaleable solution.

albertosuman-1k5 commented Aug 10, 2026
edited
Loading

Copy link
Copy Markdown
Contributor Author

@mday-io We got headaches because of the sudden change in how headers are parsed, change that was not communicated and without an opt-out flag 😅

Why would an opt-out feature that can be removed once everyone had the chance to prepare their projects (let's say in 6 months) would give everyone headers? We're dealing with 2000+ models, roughly half of them change when using the agnostic formatter. At the moment we don't have the capacity to tackle this but we'd like to upgrade to make use of a feature I contributed to

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL