Skip to content

fix(format): preserve model column dialect - #5926

Open
fresioAS wants to merge 1 commit into
SQLMesh:mainfrom
fresioAS:fix_columns_dialect
Open

fix(format): preserve model column dialect#5926
fresioAS wants to merge 1 commit into
SQLMesh:mainfrom
fresioAS:fix_columns_dialect

Conversation

@fresioAS

Copy link
Copy Markdown
Contributor

Description

Summary

  • Fixes regression introduced in fix(format): keep MODEL/AUDIT/METRIC header dialect-agnostic (#5773) #5864
  • Keep SQLMesh MODEL metadata dialect-agnostic during formatting.
  • Render the MODEL columns schema using the model's dialect.
  • Preserve dialect-specific column types such as DATETIME2(6) for T-SQL and Fabric.
  • Keep generic metadata values such as descriptions and booleans unchanged.

Context

MODEL headers were recently changed to use SQLGlot's generic generator so that
T-SQL would not rewrite SQLMesh boolean properties such as FALSE into
(1 = 0).

However, the columns property contains dialect-specific data types. Rendering
it with the generic generator changed DATETIME2(6) into TIMESTAMP(6) for
T-SQL and Fabric models.

This change keeps the generic header behavior while rendering only the
columns schema with the model dialect.

Test Plan

  • Added regression coverage for both tsql and fabric.
  • Verified descriptions remain string literals.
  • Verified formatting booleans remain FALSE.
  • Full tests/core/test_dialect.py suite passes: 161 tests.
  • Ruff and mypy pass.

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

Signed-off-by: Andreas Fredhøi <andreas.fredhoi@fresio.no>
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.

1 participant