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

Python models not referencing to unittest data fixtures #3891

Open
bjones325 opened this issue Feb 25, 2025 · 2 comments
Open

Python models not referencing to unittest data fixtures #3891

bjones325 opened this issue Feb 25, 2025 · 2 comments
Assignees
Labels
Bug Something isn't working

Comments

@bjones325
Copy link

Python Models use context.resolve_table(model_name) to find the physical table name to query.

When unittesting a python model with data fixtures mocking upstream tables, resolve_table does not resolve to the mocked fixture, IF the upstream table is not a SQLMesh model.

For example, with a model such as:


def execute(...):
      not_a_sqlmesh_model = "catalog.schema.upstream_table_not_a_model"
      table_ref = context.resolve_table(not_a_sqlmesh_model)
      fetchdf(f"SELECT * FROM {table_ref}")

and a unittest yml of:

my_test:
  model: my_model
  inputs:
    catalog.schema.upstream_table_not_a_model:
      rows:
           - col_a: value_a

the table_ref field will resolve to "catalog.schema.upstream_table_not_a_model", and NOT the table generated by the unittest yml.

This makes unittesting Python models dependent on upstream tables, which are NOT sqlmesh models, impossible.
Either, context.resolve_table should resolve to the table created by the data fixture, or fetchdf should parse and replace the table reference to point to the data fixture.

@izeigerman izeigerman added the Bug Something isn't working label Mar 11, 2025
@izeigerman
Copy link
Member

@themisvaltinos can you please have a look at this

@themisvaltinos
Copy link
Contributor

sure I will look into this @izeigerman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants