Skip to content

Commit 6c5ac3f

Browse files
committed
Chore: make column_descriptions validation more lenient
1 parent dc302eb commit 6c5ac3f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

sqlmesh/core/model/meta.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,15 @@ def _column_descriptions_validator(
247247

248248
columns_to_types = info.data.get("columns_to_types_")
249249
if columns_to_types:
250-
for column_name in col_descriptions:
250+
from sqlmesh.core.console import get_console
251+
252+
console = get_console()
253+
for column_name in list(col_descriptions):
251254
if column_name not in columns_to_types:
252-
raise ConfigError(
255+
console.log_warning(
253256
f"In model '{info.data['name']}', a description is provided for column '{column_name}' but it is not a column in the model."
254257
)
258+
del col_descriptions[column_name]
255259

256260
return col_descriptions
257261

tests/core/test_model.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2934,11 +2934,16 @@ def a_model(context):
29342934
def b_model(context):
29352935
pass
29362936

2937-
with pytest.raises(ConfigError, match="a description is provided for column 'COL'"):
2937+
with patch.object(get_console(), "log_warning") as mock_logger:
29382938
py_model = model.get_registry()["col_descriptions_quoted"].model(
29392939
module_path=Path("."),
29402940
path=Path("."),
29412941
)
2942+
assert '"COL"' not in py_model.column_descriptions
2943+
assert (
2944+
mock_logger.mock_calls[0].args[0]
2945+
== "In model 'col_descriptions_quoted', a description is provided for column 'COL' but it is not a column in the model."
2946+
)
29422947

29432948

29442949
def test_python_model_unsupported_kind() -> None:

0 commit comments

Comments
 (0)