From 88c0ecb5797b72710b819cbc34e11fa8928ddfa7 Mon Sep 17 00:00:00 2001 From: Teddy Date: Wed, 16 Nov 2022 18:10:55 +0100 Subject: [PATCH] Remove count logic in custom sql test as 1) create complex logic and 2) multiple users got confused with expected tests results (#8819) --- .../validations/table/table_custom_sql_query.py | 3 --- .../ingestion/workflows/data-quality/tests.md | 14 +++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ingestion/src/metadata/test_suite/validations/table/table_custom_sql_query.py b/ingestion/src/metadata/test_suite/validations/table/table_custom_sql_query.py index f1f9093521f..f267b819178 100644 --- a/ingestion/src/metadata/test_suite/validations/table/table_custom_sql_query.py +++ b/ingestion/src/metadata/test_suite/validations/table/table_custom_sql_query.py @@ -75,9 +75,6 @@ def table_custom_sql_query( if not rows: status = TestCaseStatus.Success result_value = 0 - elif len(rows) == 1: - status = TestCaseStatus.Success if rows[0].count == 0 else TestCaseStatus.Failed - result_value = rows[0].count else: status = TestCaseStatus.Failed result_value = len(rows) diff --git a/openmetadata-docs/content/connectors/ingestion/workflows/data-quality/tests.md b/openmetadata-docs/content/connectors/ingestion/workflows/data-quality/tests.md index ce911b5c359..aa7e43caa16 100644 --- a/openmetadata-docs/content/connectors/ingestion/workflows/data-quality/tests.md +++ b/openmetadata-docs/content/connectors/ingestion/workflows/data-quality/tests.md @@ -225,9 +225,8 @@ parameterValues: ``` ### Table Custom SQL Test -Write you own SQL test. The test will pass if either of the following condition is met: +Write you own SQL test. The test will pass if the following condition is met: - The query result return 0 row -- The query expression `COUNT()` returns 0 **Properties** @@ -236,15 +235,16 @@ Write you own SQL test. The test will pass if either of the following condition **Example** ```sql SELECT -COUNT(customer_tier) +customer_id FROM DUAL -WHERE customer_tier = 'GOLD' and lifetime_value < 10000; +WHERE lifetime_value < 0; ``` ```sql SELECT customer_id -FROM DUAL +FROM DUAL d +INNER JOIN OTHER o ON d.id = o.id WHERE lifetime_value < 0; ``` @@ -256,7 +256,7 @@ parameterValues: - name: sqlExpression value: > SELECT - COUNT(customer_tier) + customer_tier FROM DUAL WHERE customer_tier = 'GOLD' and lifetime_value < 10000; ``` @@ -269,7 +269,7 @@ parameterValues: "parameterValues": [ { "name": "sqlExpression", - "value": "SELECT COUNT(customer_tier) FROM DUAL WHERE customer_tier = 'GOLD' and lifetime_value < 10000;\n" + "value": "SELECT customer_tier FROM DUAL WHERE customer_tier = 'GOLD' and lifetime_value < 10000;" } ] }