Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sqlmesh/core/model/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,15 @@ def _column_descriptions_validator(

columns_to_types = info.data.get("columns_to_types_")
if columns_to_types:
for column_name in col_descriptions:
from sqlmesh.core.console import get_console

console = get_console()
for column_name in list(col_descriptions):
if column_name not in columns_to_types:
raise ConfigError(
console.log_warning(
f"In model '{info.data['name']}', a description is provided for column '{column_name}' but it is not a column in the model."
)
del col_descriptions[column_name]

return col_descriptions

Expand Down
7 changes: 6 additions & 1 deletion tests/core/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2934,11 +2934,16 @@ def a_model(context):
def b_model(context):
pass

with pytest.raises(ConfigError, match="a description is provided for column 'COL'"):
with patch.object(get_console(), "log_warning") as mock_logger:
py_model = model.get_registry()["col_descriptions_quoted"].model(
module_path=Path("."),
path=Path("."),
)
assert '"COL"' not in py_model.column_descriptions
assert (
mock_logger.mock_calls[0].args[0]
== "In model 'col_descriptions_quoted', a description is provided for column 'COL' but it is not a column in the model."
)


def test_python_model_unsupported_kind() -> None:
Expand Down