File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,15 @@ def resolve_table(self, model_name: str) -> str:
214214 """
215215 model_name = normalize_model_name (model_name , self .default_catalog , self .default_dialect )
216216
217+ if model_name not in self ._model_tables :
218+ model_name_list = "\n " .join (list (self ._model_tables ))
219+ logger .debug (
220+ f"'{ model_name } ' not found in model to table mapping. Available model names: \n { model_name_list } "
221+ )
222+ raise SQLMeshError (
223+ f"Unable to find a table mapping for model '{ model_name } '. Has it been spelled correctly?"
224+ )
225+
217226 # We generate SQL for the default dialect because the table name may be used in a
218227 # fetchdf call and so the quotes need to be correct (eg. backticks for bigquery)
219228 return parse_one (self ._model_tables [model_name ]).sql (
Original file line number Diff line number Diff line change @@ -3082,4 +3082,7 @@ def execute(
30823082 assert '"GOLD"."SUSHI"."FOO"' in test .context ._model_tables
30833083 assert '"GOLD"."SUSHI"."BAR"' in test .context ._model_tables
30843084
3085+ with pytest .raises (SQLMeshError , match = r"Unable to find a table mapping" ):
3086+ test .context .resolve_table ("silver.sushi.bar" )
3087+
30853088 _check_successful_or_raise (test .run ())
You can’t perform that action at this time.
0 commit comments