feat(format): add transpile_meta opt-in for dialect-aware MODEL headers - #5944
feat(format): add transpile_meta opt-in for dialect-aware MODEL headers#5944albertosuman-1k5 wants to merge 1 commit into
Conversation
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>
|
@albertosuman-1k5 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 |
|
@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. |
Summary
format.transpile_metasosqlmesh formatcan renderMODEL/AUDIT/METRICheaders with the model dialect again.TRUE/FALSEinstead of dialect rewrites like T-SQL(1 = 1).format.transpile_meta: trueto preserve those values.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
format_model_expressions(..., transpile_meta=True)(multi-expression and single-meta paths)transpile_metais excluded fromgenerator_options(does not leak into SQLGlotGenerator)Context.format()withFormatConfig(transpile_meta=True)preservesDATETIME2(6)columns/audits/ macros — format with and without the flagMade with Cursor