Skip to content

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

@albertosuman-1k5

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

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

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.

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