Detect and warn when regular model name also in external models
A project has a model named example.model. Someone accidentally adds example.model to the external models config file.
Currently, this generates unclear output - sqlmesh should detect and warn so users can resolve.
@treysp what output is generated today?
So given this entry in external_models.yaml of the example project:
- name: sqlmesh_example.full_model
start: 1 week ago
columns:
customer_id: int
zip: text
The resulting error is:
sqlmesh.utils.errors.TestError: Model '"db"."sqlmesh_example"."full_model"' is an unsupported model type for testing at /<path>/playground/tests/test_full_model.yaml
I believe this happens because we're using update in this section: https://github.com/TobikoData/sqlmesh/blob/cc0653c351232d917c103212aa497d094b9a0001/sqlmesh/core/loader.py#L387-L389
So the SQL kind is overwritten by the external kind, which can't be unit-tested, hence that cryptic error message. Is the usage of update in the linked section intentional? I'd assume that we want to enforce the unique name constraint for models across all kinds.
Recently, I encountered an issue similar to this, so I created a PR for that https://github.com/TobikoData/sqlmesh/pull/3945 to handle. appreciate your feedback.
@tobymao - PR is merged, think it can be closed now :)
Appreciate your working on this @lafirm!