feat(format): add transpile_meta opt-in for dialect-aware MODEL headers - #5944
Open
albertosuman-1k5 wants to merge 1 commit into
Open
feat(format): add transpile_meta opt-in for dialect-aware MODEL headers#5944albertosuman-1k5 wants to merge 1 commit into
albertosuman-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>
Contributor
|
@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 |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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