From c7147142b9b2d361cc3a7b1cc9c9188610e5858f Mon Sep 17 00:00:00 2001 From: MikaKerman Date: Tue, 1 Apr 2025 12:04:36 +0300 Subject: [PATCH] Enhance test result handling by adding test_description field * Updated TestsAPI to prioritize test_description over meta description. * Modified SQL macros to include test_description in test results. * Updated schema to define test_description in TestResultDBRowSchema. --- elementary/monitor/api/tests/tests.py | 5 ++++- .../macros/base_queries/current_tests_run_results_query.sql | 1 + elementary/monitor/dbt_project/macros/get_test_results.sql | 1 + elementary/monitor/fetchers/tests/schema.py | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/elementary/monitor/api/tests/tests.py b/elementary/monitor/api/tests/tests.py index 9164eba5e..e3f1165c8 100644 --- a/elementary/monitor/api/tests/tests.py +++ b/elementary/monitor/api/tests/tests.py @@ -378,7 +378,10 @@ def _get_test_metadata_from_test_result_db_row( test_query=test_query, test_params=test_result_db_row.test_params, test_created_at=test_result_db_row.test_created_at, - description=test_result_db_row.meta.get("description"), + description=( + test_result_db_row.test_description + or test_result_db_row.meta.get("description") + ), result=result, configuration=configuration, test_tags=test_result_db_row.test_tags, diff --git a/elementary/monitor/dbt_project/macros/base_queries/current_tests_run_results_query.sql b/elementary/monitor/dbt_project/macros/base_queries/current_tests_run_results_query.sql index 1d15c6a58..b10bc8ba6 100644 --- a/elementary/monitor/dbt_project/macros/base_queries/current_tests_run_results_query.sql +++ b/elementary/monitor/dbt_project/macros/base_queries/current_tests_run_results_query.sql @@ -82,6 +82,7 @@ elementary_test_results.result_rows, dbt_tests.original_path, dbt_tests.meta, + dbt_tests.description as test_description, dbt_tests.package_name, dbt_tests.tags as test_tags, dbt_artifacts.meta as model_meta, diff --git a/elementary/monitor/dbt_project/macros/get_test_results.sql b/elementary/monitor/dbt_project/macros/get_test_results.sql index dad6bebee..87e4be2af 100644 --- a/elementary/monitor/dbt_project/macros/get_test_results.sql +++ b/elementary/monitor/dbt_project/macros/get_test_results.sql @@ -30,6 +30,7 @@ test_results.test_type, test_results.test_sub_type, test_results.test_results_description, + test_results.test_description, test_results.original_path, test_results.package_name, test_results.owners, diff --git a/elementary/monitor/fetchers/tests/schema.py b/elementary/monitor/fetchers/tests/schema.py index dc19a0a85..e36ebadf7 100644 --- a/elementary/monitor/fetchers/tests/schema.py +++ b/elementary/monitor/fetchers/tests/schema.py @@ -28,6 +28,7 @@ class TestResultDBRowSchema(ExtendedBaseModel): test_type: str test_sub_type: str test_results_description: Optional[str] + test_description: Optional[str] original_path: str owners: Optional[List[str]] model_owner: Optional[List[str]]