Python models not referencing to unittest data fixtures
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.
@themisvaltinos can you please have a look at this
sure I will look into this @izeigerman