Description
See conversation here: https://tobiko-data.slack.com/archives/C044BRE5W4S/p1751631197964989
Long story short: I was a bad boy when creating a new model, where I omitted the schema from a table reference. This caused the "same level of nesting" error to come out and play, but the error text wasn't very helpful in understanding the source of the problem.
Steps (using MSSQL):
- Create a model where a "legit" table reference is used:
SELECT * FROM dbo.some_table
- Run
sqlmesh create_external_models
to populate theyaml
file - Create another model where schema is omitted:
SELECT a,b,c from some_table
- Again run
sqlmesh create_external_models
, this adds another entry forsome_table
in the yaml file (without db/schema). - Now when trying to do
sqlmesh plan
, the error shows up - I fix the table reference in the second model, adding schema
- The error persists, even though the only place
some_table
is referenced sans schema is in theexternal_models.yaml
file
In my project with many table references, it seemed to pick a table reference "at random" to throw the error, which made the debugging feel quite hopeless, especially after there was no longer any sql files in the project that had table references without a schema attached!
The error persisted until I deleted and remade the yaml file after fixing all the table references.
Perhaps the create_external_models
should automatically fail if it notices different nesting of model references - this would prevent this issue from happening in the first place.