Skip to content

Commit 6df27fe

Browse files
test(model): cover dotted column_descriptions keys
The join-by-parts path had no test. A BigQuery nested path normalizes the same as before the fix, since joining the parts and re-parsing produced a quoted identifier that BigQuery lowercases anyway. On Snowflake an unquoted path now normalizes per part, which is what an unquoted name should do there, and a quoted one keeps its case. Signed-off-by: ReguiguiMohamed <mohamedreguigui2004@gmail.com>
1 parent 02c0c69 commit 6df27fe

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tests/core/test_model.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,49 @@ def test_column_descriptions_quoted_identifier():
10261026
assert set(model.column_descriptions) <= set(model.columns_to_types)
10271027

10281028

1029+
def test_column_descriptions_dotted_identifier():
1030+
# A nested field is looked up by its dotted path, so every part normalizes on its own.
1031+
expressions = d.parse(
1032+
"""
1033+
MODEL (
1034+
name db.table,
1035+
kind FULL,
1036+
dialect bigquery,
1037+
column_descriptions (
1038+
record.`myField` = 'a nested field'
1039+
)
1040+
);
1041+
1042+
SELECT STRUCT(1 AS `myField`) AS record
1043+
"""
1044+
)
1045+
model = load_sql_based_model(expressions, dialect="bigquery")
1046+
1047+
assert model.column_descriptions == {"record.myfield": "a nested field"}
1048+
1049+
expressions = d.parse(
1050+
"""
1051+
MODEL (
1052+
name db.table,
1053+
kind FULL,
1054+
dialect snowflake,
1055+
column_descriptions (
1056+
nested.field = 'an unquoted path',
1057+
"MyStruct"."myField" = 'a quoted path'
1058+
)
1059+
);
1060+
1061+
SELECT 1 AS c
1062+
"""
1063+
)
1064+
model = load_sql_based_model(expressions, dialect="snowflake")
1065+
1066+
assert model.column_descriptions == {
1067+
"NESTED.FIELD": "an unquoted path",
1068+
"MyStruct.myField": "a quoted path",
1069+
}
1070+
1071+
10291072
def test_model_jinja_macro_reference_extraction():
10301073
@macro()
10311074
def test_macro(**kwargs) -> None:

0 commit comments

Comments
 (0)