-
Notifications
You must be signed in to change notification settings - Fork 199
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
Unit tests do not respect macro variables #3979
Comments
I can't reproduce what you're seeing against the latest main branch. Variable replacement works fine for a project like this: # test.yaml
test_claim_model:
model: "{{ var('silver') }}.client_x.claim"
inputs:
"bronze.client_x.claim":
- x: 1
"{{ var('silver') }}.client_x.insurance_plan":
- x: 1
outputs:
query:
- x: 1 -- test.sql
MODEL (
name @silver.client_x.claim,
kind FULL
);
SELECT 1 AS x
FROM bronze.client_x.claim AS t1, @silver.client_x.insurance_plan AS t2
WHERE t1.x = 1 AND t2.x = 1 # config.yaml
gateways:
duckdb:
connection:
type: duckdb
database: db.db
default_gateway: duckdb
model_defaults:
dialect: duckdb
start: 2025-03-25
variables:
silver: silver Going to close this as a non-issue, but happy to continue discussing. My guess is there's probably some configuration issue on your side. Otherwise, it may be a dialect-specific issue, but will need more details on that to debug it. |
Have you tested on |
I just tried the same snippet that you sent @georgesittas and didn't work for me ! Version : 0.164.0
test_claim_model:
|
Test runs fine for me in 0.164.0 as well:
Both with duckdb and snowflake as the default dialect:
I think I'll need more details about your setup to see if I can repro this. |
@georgesittas This is our var setup : (The strange thing is, work for models, but not for unit tests)
|
We're on SQLMesh version
0.164.0
, and we have a test of the form:Now,
silver
is a variable that is well defined in ourconfig.py
, and I can verify this because every single model has a database parameterization on a variable such assilver
, andsqlmesh plan
/sqlmesh run
have worked fine.However, running
sqlmesh test
, consistently we get:As you can see, as well, we follow this document and even mix different modalities of using variables.
Am I missing something obvious or do we have a bug here?
The text was updated successfully, but these errors were encountered: