Steps to reproduce
- Create a SQLMesh project with a model referencing an external table:
MODEL (name db.my_model, kind FULL);
SELECT * FROM raw.source_table;
-
Run sqlmesh create_external_models — the external model is written to external_models.yaml.
-
Move the entry into the external_models/ directory as recommended in the docs (e.g., external_models/source_table.yaml), then delete external_models.yaml.
-
Run sqlmesh create_external_models again — the entry is written back into external_models.yaml. The same model now exists in both external_models.yaml and external_models/source_table.yaml.
-
Run sqlmesh plan or any command that loads models — crashes with:
ConfigError: Failed to load model from file external_models/source_table.yaml:
Duplicate external model name: memory.raw.source_table.
Why this happens
create_external_models_file writes all fetched external models into external_models.yaml, regardless of whether they already exist in external_models/*.yaml files. The loader then raises a ConfigError when it finds the same model name in two different files.
Workaround
Delete external_models.yaml and re-run create_external_models, or avoid using the external_models/ directory together with create_external_models.
Steps to reproduce
Run
sqlmesh create_external_models— the external model is written toexternal_models.yaml.Move the entry into the
external_models/directory as recommended in the docs (e.g.,external_models/source_table.yaml), then deleteexternal_models.yaml.Run
sqlmesh create_external_modelsagain — the entry is written back intoexternal_models.yaml. The same model now exists in bothexternal_models.yamlandexternal_models/source_table.yaml.Run
sqlmesh planor any command that loads models — crashes with:Why this happens
create_external_models_filewrites all fetched external models intoexternal_models.yaml, regardless of whether they already exist inexternal_models/*.yamlfiles. The loader then raises aConfigErrorwhen it finds the same model name in two different files.Workaround
Delete
external_models.yamland re-runcreate_external_models, or avoid using theexternal_models/directory together withcreate_external_models.