Skip to content
Closed
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
4 changes: 3 additions & 1 deletion sqlmesh/core/model/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ def _column_descriptions_validator(
if columns_to_types:
for column_name in col_descriptions:
if column_name not in columns_to_types:
raise ConfigError(
from sqlmesh.core.console import get_console

get_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."
)

Expand Down
7 changes: 5 additions & 2 deletions tests/core/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2925,7 +2925,8 @@ def a_model(context):

assert py_model.columns_to_types.keys() == py_model.column_descriptions.keys()

# error: `columns` and `column_descriptions` column names are different cases, quoting preserves case
# warning: `columns` and `column_descriptions` column names are quoted and different cases,
# so column not present in model
@model(
"col_descriptions_quoted",
columns={'"col"': "int"},
Expand All @@ -2934,11 +2935,13 @@ 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 mock_logger.call_count == 1
assert "a description is provided for column 'COL'" in mock_logger.call_args[0][0]


def test_python_model_unsupported_kind() -> None:
Expand Down