Skip to content

Fix duplicate external model generation from directory files#5897

Open
reachsrinivaschennupati-tech wants to merge 2 commits into
SQLMesh:mainfrom
reachsrinivaschennupati-tech:fix/external-models-directory-duplicates
Open

Fix duplicate external model generation from directory files#5897
reachsrinivaschennupati-tech wants to merge 2 commits into
SQLMesh:mainfrom
reachsrinivaschennupati-tech:fix/external-models-directory-duplicates

Conversation

@reachsrinivaschennupati-tech

@reachsrinivaschennupati-tech reachsrinivaschennupati-tech commented Jul 10, 2026

Copy link
Copy Markdown

Summary

Fixes duplicate external model generation when external models are already defined in the external_models directory.

Problem

create_external_models_file considered every external model in the loaded model set, including models that originated from the configured external models directory. That could cause SQLMesh to regenerate an external model entry that was already explicitly defined by the project.

Solution

  • Only include external models whose source path matches the generated external models file path.
  • Preserve externally defined models from the external_models directory without writing duplicate generated entries.
  • Add regression coverage for a project that contains both a SQL model dependency and an existing external model YAML definition.

Validation

  • Local tests passed.

Fixes #5880

@reachsrinivaschennupati-tech

Copy link
Copy Markdown
Author

Hi maintainers, this PR is ready for review when you have a chance.

I kept the change focused on preventing generated external model entries from duplicating models that are already explicitly defined under the external models directory. The PR includes regression coverage for the mixed case where a project has both a SQL model dependency and an existing external model YAML definition.

Validation noted in the PR:

  • Local tests passed.

Happy to make any adjustments if you prefer a different boundary for the generated-vs-explicit external model handling.

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.

Bug: create_external_models causes duplicate model ConfigError when using external_models/ directory

1 participant