Skip to content

Commit

Permalink
🐛 Fixed exposure schema validity test err messages (#628)
Browse files Browse the repository at this point in the history
* fixed error message for mismatched datatypes in exposure schema validity test

* added test
  • Loading branch information
pushrbx authored May 28, 2024
1 parent c2f9c21 commit a14a6e1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions integration_tests/tests/test_exposure_schema_validity.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,37 @@ def test_exposure_schema_validity_correct_columns_and_invalid_type(
assert test_result["status"] == "fail"


@pytest.mark.skip_targets(["spark"])
def test_exposure_schema_validity_invalid_type_name_present_in_error(
test_id: str, dbt_project: DbtProject
):
DBT_TEST_ARGS = {
"node": "models.exposures_test",
"columns": [{"name": "order_id", "dtype": "numeric", "data_type": "numeric"}],
"exposures": {
"ZOMG": {
"meta": {
"referenced_columns": [
{"column_name": "order_id", "data_type": "string"}
]
},
"url": "http://bla.com",
"name": "ZOMG",
"depends_on": {"nodes": ["models.exposures_test"]},
}
},
}
test_result = dbt_project.test(
test_id, DBT_TEST_NAME, DBT_TEST_ARGS, columns=[dict(name="bla")], as_model=True
)

assert (
"different data type for the column order_id string vs numeric"
in test_result["test_results_query"]
)
assert test_result["status"] == "fail"


@pytest.mark.skip_targets(["spark"])
def test_exposure_schema_validity_correct_columns_and_missing_type(
test_id: str, dbt_project: DbtProject
Expand Down
2 changes: 1 addition & 1 deletion macros/edr/tests/test_exposure_schema_validity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
{%- do invalid_exposures.append({
'exposure': exposure['name'],
'url': exposure['url'],
'error': 'different data type for the column ' ~ exposure_column['column_name'] ~ ' ' ~ exposure_column['data_type'] ~ ' vs ' ~ columns_dict[exposure_column['name'] | upper]
'error': 'different data type for the column ' ~ exposure_column['column_name'] ~ ' ' ~ exposure_column['data_type'] ~ ' vs ' ~ columns_dict[exposure_column['column_name'] | upper]
})
-%}
{%- endif -%}
Expand Down

0 comments on commit a14a6e1

Please sign in to comment.