Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect and warn when regular model name also in external models #3686

Open
treysp opened this issue Jan 22, 2025 · 2 comments
Open

Detect and warn when regular model name also in external models #3686

treysp opened this issue Jan 22, 2025 · 2 comments
Labels
Improvement Improves existing functionality

Comments

@treysp
Copy link
Contributor

treysp commented Jan 22, 2025

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 treysp added the Improvement Improves existing functionality label Jan 22, 2025
@izeigerman
Copy link
Member

@treysp what output is generated today?

@georgesittas
Copy link
Contributor

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:

models = self._load_sql_models(macros, jinja_macros, audits, signals)
models.update(self._load_external_models(audits, gateway))
models.update(self._load_python_models(macros, jinja_macros, audits, signals))

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Improves existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants