Chore: Split migration script implementations into DDL and DML#5307
Merged
izeigerman merged 3 commits intomainfrom Sep 5, 2025
Merged
Chore: Split migration script implementations into DDL and DML#5307izeigerman merged 3 commits intomainfrom
izeigerman merged 3 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR splits migration script implementations into two functions: migrate_ddl for schema changes and migrate_dml for data manipulation. This separation allows the system to skip unnecessary data operations during initial setup when tables are empty, significantly improving initialization performance (from ~1m30s to ~25s in BigQuery).
Key Changes
- Split single
migratefunction intomigrate_ddlandmigrate_dmlfunctions across all migration files - Updated migration execution logic to conditionally run DML operations only when state tables already exist
- Fixed field ordering consistency in environment queries by sorting field names
Reviewed Changes
Copilot reviewed 98 out of 98 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
sqlmesh/core/state_sync/db/migrator.py |
Modified migration execution logic to separate DDL and DML operations |
sqlmesh/core/state_sync/db/environment.py |
Fixed field ordering consistency by sorting Environment field names |
sqlmesh/core/context.py |
Added status message for project initialization |
| 95 migration files | Split migrate function into migrate_ddl and migrate_dml functions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
eakmanrq
reviewed
Sep 5, 2025
| def _environment_summmary_from_row(self, row: t.Tuple[str, ...]) -> EnvironmentSummary: | ||
| return EnvironmentSummary( | ||
| **{field: row[i] for i, field in enumerate(EnvironmentSummary.all_fields())} | ||
| **{field: row[i] for i, field in enumerate(sorted(EnvironmentSummary.all_fields()))} |
Collaborator
Author
There was a problem hiding this comment.
Because all_fields() returns a set
eakmanrq
approved these changes
Sep 5, 2025
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.
The split allows us to skip unnecessary DML operations during the initial state setup, which significantly speeds up initialization when using engines like BigQuery.
In my test the init time went from ~1m30s down to ~25s