Skip to content

Feat: Add plan option to show rendered model diff - #3691

Merged
VaggelisD merged 4 commits into
mainfrom
vaggelisd/rendered_model_diff
Jan 27, 2025
Merged

VaggelisD merged 4 commits into
mainfrom
vaggelisd/rendered_model_diff

Conversation

@VaggelisD

Copy link
Copy Markdown
Collaborator

Fixes #1254

The default behavior of plan diff is to compare raw models i.e the original queries & statements:

Differences from the `dev` environment:

Models:
└── Directly Modified:
    └── default__dev.test

--- 

+++ 

@@ -4,13 +4,13 @@

 CREATE TABLE IF NOT EXISTS foo AS
 (
   SELECT
-    @OR(FALSE, TRUE)
+    @AND(TRUE, NULL)
 )
 SELECT
-  4 + 2
+  5 + 2
 CREATE TABLE IF NOT EXISTS foo2 AS
 (
   SELECT
-    @AND(TRUE, FALSE)
+    @OR(TRUE, NULL)
 )
-DROP VIEW @this_model
+DROP VIEW IF EXISTS @this_model

This PR introduces the sqlmesh plan --rendered-model-diff which instead compares rendered queries/statements:

@@ -4,13 +4,13 @@

 CREATE TABLE IF NOT EXISTS "foo" AS
 (
   SELECT
-    FALSE OR TRUE
+    TRUE
 )
 SELECT
-  6 AS "_col_0"
+  7 AS "_col_0"
 CREATE TABLE IF NOT EXISTS "foo2" AS
 (
   SELECT
-    TRUE AND FALSE
+    TRUE
 )
-DROP VIEW "test"
+DROP VIEW IF EXISTS "test"

Comment thread docs/reference/notebook.md Resolved
Comment thread sqlmesh/core/audit/definition.py Resolved
Comment thread sqlmesh/core/context_diff.py Resolved
Comment thread sqlmesh/core/context.py Resolved
Comment thread sqlmesh/core/model/definition.py Resolved
Comment thread sqlmesh/core/model/definition.py Resolved
Comment thread sqlmesh/core/model/definition.py Resolved
@VaggelisD
VaggelisD requested a review from a team January 23, 2025 17:55
Comment thread docs/reference/cli.md Resolved
@VaggelisD
VaggelisD force-pushed the vaggelisd/rendered_model_diff branch from 7f7e6ef to 3b99b8f Compare January 27, 2025 09:20
Comment thread sqlmesh/core/model/definition.py Resolved
Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>
@VaggelisD
VaggelisD merged commit c98c35a into main Jan 27, 2025
@VaggelisD
VaggelisD deleted the vaggelisd/rendered_model_diff branch January 27, 2025 16:24
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.

Add an option to sqlmesh plan to use rendered model queries for diffing

3 participants