From afd12cff049165de7273acb57ff545d50b0dd8af Mon Sep 17 00:00:00 2001 From: Teddy Date: Tue, 23 Aug 2022 18:32:15 +0200 Subject: [PATCH] added testResultValue to testCaseResult (#6881) --- .../resources/json/schema/tests/basic.json | 21 + .../sample_data/tests/testCaseResults.json | 448 ++++++++++++++++-- .../ingestion/source/database/sample_data.py | 6 +- 3 files changed, 423 insertions(+), 52 deletions(-) diff --git a/catalog-rest-service/src/main/resources/json/schema/tests/basic.json b/catalog-rest-service/src/main/resources/json/schema/tests/basic.json index 3709634e128..a3d929f315e 100644 --- a/catalog-rest-service/src/main/resources/json/schema/tests/basic.json +++ b/catalog-rest-service/src/main/resources/json/schema/tests/basic.json @@ -4,6 +4,21 @@ "title": "Basic", "description": "This schema defines basic types that are used by other test schemas.", "definitions": { + "testResultValue": { + "description": "Schema to capture test case result values.", + "javaType": "org.openmetadata.catalog.tests.type.TestResultValue", + "type": "object", + "properties": { + "name": { + "description": "name of the value", + "type": "string" + }, + "value": { + "description": "test result value", + "type": "string" + } + } + }, "testCaseResult": { "description": "Schema to capture test case result.", "javaType": "org.openmetadata.catalog.tests.type.TestCaseResult", @@ -37,6 +52,12 @@ "sampleData": { "description": "sample data to capture rows/columns that didn't match the expressed testcase.", "type": "string" + }, + "testResultValue": { + "type": "array", + "items": { + "$ref": "#/definitions/testResultValue" + } } }, "additionalProperties": false diff --git a/ingestion/examples/sample_data/tests/testCaseResults.json b/ingestion/examples/sample_data/tests/testCaseResults.json index f1f759185a5..9b3f08dd36b 100644 --- a/ingestion/examples/sample_data/tests/testCaseResults.json +++ b/ingestion/examples/sample_data/tests/testCaseResults.json @@ -5,47 +5,113 @@ "results": [ { "result": "Found 10 columns vs. the expected 10", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "10" + } + ] }, { "result": "Found 10 columns vs. the expected 10", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "10" + } + ] }, { "result": "Found 10 columns vs. the expected 10", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "10" + } + ] }, { "result": "Found 10 columns vs. the expected 10", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "10" + } + ] }, { "result": "Found 10 columns vs. the expected 10", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "10" + } + ] }, { "result": "Found 8 columns vs. the expected 10", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "columnCount", + "value": "8" + } + ] }, { "result": "Found 8 columns vs. the expected 10", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "columnCount", + "value": "8" + } + ] }, { "result": "columnCount should not be None for TableColumnCountToEqual", - "testCaseStatus": "Aborted" + "testCaseStatus": "Aborted", + "testResultValues": [ + { + "name": "columnCount", + "value": "None" + } + ] }, { "result": "Found 10 columns vs. the expected 10", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "10" + } + ] }, { "result": "Found 10 columns vs. the expected 10", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "10" + } + ] }, { "result": "Found 10 columns vs. the expected 10", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "10" + } + ] } ] }, @@ -54,43 +120,103 @@ "results": [ { "result": "Found 9 column vs. the expected range [1, 10].", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "9" + } + ] }, { "result": "Found 9 column vs. the expected range [1, 10].", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "9" + } + ] }, { "result": "Found 9 column vs. the expected range [1, 10].", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "9" + } + ] }, { "result": "columnCount should not be None for TableColumnCountToBeBetween", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "9" + } + ] }, { "result": "Found 9 column vs. the expected range [1, 10].", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "9" + } + ] }, { "result": "Found 8 column vs. the expected range [1, 10].", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "8" + } + ] }, { "result": "Found 8 column vs. the expected range [1, 10].", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "8" + } + ] }, { "result": "Found 14 column vs. the expected range [1, 10].", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "columnCount", + "value": "14" + } + ] }, { "result": "Found 8 column vs. the expected range [1, 10].", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "8" + } + ] }, { "result": "Found 8 column vs. the expected range [1, 10].", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "columnCount", + "value": "8" + } + ] } ] }, @@ -99,43 +225,103 @@ "results": [ { "result": "Found max=65 vs. the expected min=50, max=100.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "max", + "value": "65" + } + ] }, { "result": "Found max=25 vs. the expected min=50, max=100.", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "max", + "value": "25" + } + ] }, { "result": "Found max=56 vs. the expected min=50, max=100.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "max", + "value": "56" + } + ] }, { "result": "Found max=99 vs. the expected min=50, max=100.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "max", + "value": "99" + } + ] }, { "result": "Found max=190 vs. the expected min=50, max=100.", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "max", + "value": "190" + } + ] }, { "result": "Found max=66 vs. the expected min=50, max=100.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "max", + "value": "66" + } + ] }, { "result": "Found max=76 vs. the expected min=50, max=100.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "max", + "value": "76" + } + ] }, { "result": "Found max=46 vs. the expected min=50, max=100.", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "max", + "value": "46" + } + ] }, { "result": "Found max=100 vs. the expected min=50, max=100.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "max", + "value": "100" + } + ] }, { "result": "We expect `max` to be informed on the profiler for ColumnValueMaxToBeBetween max=None.", - "testCaseStatus": "Aborted" + "testCaseStatus": "Aborted", + "testResultValues": [ + { + "name": "max", + "value": "None" + } + ] } ] }, @@ -144,44 +330,104 @@ "results": [ { "result": "Found 99 value(s) matching regex pattern vs 99 value(s) in the column.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "likeCount", + "value": "65" + } + ] }, { "result": "Found 0 value(s) matching regex pattern vs 99 value(s) in the column.", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "likeCount", + "value": "0" + } + ] }, { "result": "Cannot find the configured column last_name for ColumnValuesToBeNotInSet", - "testCaseStatus": "Aborted" + "testCaseStatus": "Aborted", + "testResultValues": [ + { + "name": "likeCount", + "value": "None" + } + ] }, { "result": "Found 99 value(s) matching regex pattern vs 99 value(s) in the column.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "likeCount", + "value": "99" + } + ] }, { "result": "Found 5 value(s) matching regex pattern vs 99 value(s) in the column.", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "likeCount", + "value": "5" + } + ] }, { "result": "Found 2 value(s) matching regex pattern vs 99 value(s) in the column.", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "likeCount", + "value": "2" + } + ] }, { "result": "Found 99 value(s) matching regex pattern vs 99 value(s) in the column.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "likeCount", + "value": "99" + } + ] }, { "result": "Error computing ColumnValuesToMatchRegex for last_name - database error", - "testCaseStatus": "Aborted" + "testCaseStatus": "Aborted", + "testResultValues": [ + { + "name": "likeCount", + "value": "None" + } + ] }, { "result": "Found 99 value(s) matching regex pattern vs 99 value(s) in the column.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "likeCount", + "value": "99" + } + ] }, { "result": "Found 99 value(s) matching regex pattern vs 99 value(s) in the column.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "likeCount", + "value": "99" + } + ] } ] }, @@ -190,44 +436,144 @@ "results": [ { "result": "We expect `min` & `max` to be informed on the profiler for ColumnValuesToBeBetween but got min=None, max=None.", - "testCaseStatus": "Aborted" + "testCaseStatus": "Aborted", + "testResultValues": [ + { + "name": "min", + "value": "None" + }, + { + "name": "max", + "value": "None" + } + ] }, { "result": "Found min=35005, max=92808 vs. the expected min=90001, max=96162.", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "min", + "value": "35005" + }, + { + "name": "max", + "value": "92808" + } + ] }, { "result": "Found min=90006, max=92808 vs. the expected min=90001, max=96162.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "min", + "value": "90006" + }, + { + "name": "max", + "value": "92808" + } + ] }, { "result": "Found min=90002, max=95640 vs. the expected min=90001, max=96162.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "min", + "value": "90002" + }, + { + "name": "max", + "value": "95640" + } + ] }, { "result": "Found min=90004, max=99001 vs. the expected min=90001, max=96162.", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "min", + "value": "90004" + }, + { + "name": "max", + "value": "99001" + } + ] }, { "result": "Found min=1001, max=2789 vs. the expected min=90001, max=96162.", - "testCaseStatus": "Failed" + "testCaseStatus": "Failed", + "testResultValues": [ + { + "name": "min", + "value": "1001" + }, + { + "name": "max", + "value": "2789" + } + ] }, { "result": "Found min=91009, max=92808 vs. the expected min=90001, max=96162.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "min", + "value": "91009" + }, + { + "name": "max", + "value": "92808" + } + ] }, { "result": "Found min=90008, max=92808 vs. the expected min=90001, max=96162.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "min", + "value": "90008" + }, + { + "name": "max", + "value": "92808" + } + ] }, { "result": "Found min=92000, max=92808 vs. the expected min=90001, max=96162.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "min", + "value": "92000" + }, + { + "name": "max", + "value": "92808" + } + ] }, { "result": "Found min=90001, max=96612 vs. the expected min=90001, max=96162.", - "testCaseStatus": "Success" + "testCaseStatus": "Success", + "testResultValues": [ + { + "name": "min", + "value": "90001" + }, + { + "name": "max", + "value": "96612" + } + ] } ] } diff --git a/ingestion/src/metadata/ingestion/source/database/sample_data.py b/ingestion/src/metadata/ingestion/source/database/sample_data.py index c51fc4c2f12..73b67ef50fd 100644 --- a/ingestion/src/metadata/ingestion/source/database/sample_data.py +++ b/ingestion/src/metadata/ingestion/source/database/sample_data.py @@ -75,7 +75,7 @@ from metadata.generated.schema.entity.teams.user import User from metadata.generated.schema.metadataIngestion.workflow import ( Source as WorkflowSource, ) -from metadata.generated.schema.tests.basic import TestCaseResult +from metadata.generated.schema.tests.basic import TestCaseResult, TestResultValue from metadata.generated.schema.tests.columnTest import ColumnTestCase from metadata.generated.schema.tests.tableTest import TableTestCase from metadata.generated.schema.tests.testCase import TestCase, TestCaseParameterValue @@ -914,6 +914,10 @@ class SampleDataSource(Source[Entity]): timestamp=(datetime.now() - timedelta(days=i)).timestamp(), testCaseStatus=result["testCaseStatus"], result=result["result"], + testResultValue=[ + TestResultValue.parse_obj(res_value) + for res_value in result["testResultValues"] + ], ), test_case_name=case.fullyQualifiedName.__root__, )