From b8170e618160ef07c65edc985342a2a64b544967 Mon Sep 17 00:00:00 2001 From: Trey Spiller Date: Mon, 8 Sep 2025 15:53:22 -0500 Subject: [PATCH] Warn instead of error when col description provided for non-existent col --- sqlmesh/core/model/meta.py | 4 +++- tests/core/test_model.py | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sqlmesh/core/model/meta.py b/sqlmesh/core/model/meta.py index 11e384b813..e5da531743 100644 --- a/sqlmesh/core/model/meta.py +++ b/sqlmesh/core/model/meta.py @@ -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." ) diff --git a/tests/core/test_model.py b/tests/core/test_model.py index a3159c8f0a..abe5bdc1a8 100644 --- a/tests/core/test_model.py +++ b/tests/core/test_model.py @@ -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"}, @@ -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: