Why isn't this working (attempting to pass in a model to a source with a different schema)

I feel like I’m missing something obvious, but I am trying to compare the same table in two different schemas (basically, if row count between previous load and current load has more than 10% variance).

my test basically just takes model and is called from the schema:
(% test table_length(model %)

It uses {{ model }} in the from query in one CTE

Then I try and use hardcoded schema and model.name in the other cte, ie:

FROM {{ source(“other_schema”, model.name }}

That doesn’t work. It doesn’t error, it literally just skips the test but says nothing (which is what dbt normally does it can resolve the source to the one in the schema).

But source does exist in my schema, and if I hardcode a table name, it works fine:
FROM {{ source(“other_schema”, “Member” }}

I’ve used {{log (~model.name) }} and it’s identical to what I’m hardcoding.

I’ve tried setting to a variable and converting it to a string, ie:

{% set comparison_table = model.name|string %} (and several variations of)

and then FROM {{ source(“other_schema”, comparison_table}}

Doesn’t work.

If I hardcode the table name in the variable, ie:

{% set comparison_table = “Member” %}

Works fine. What am I missing? Why can’t I use model.name even though it’s identical based on logging?

I’ve tried splitting it into a separate macros, with the outer one passing in the model, and comparison schema and model, but not luck.

When you compile your code what value of table it generates
dbt compile --select model_name

It doesn’t even find the test in the compile. dbt will skip a test if it doesn’t think the source exists in the schema. So it skips the test, even though it exists.