From f03fb1cafa70f1b02c5395343100b79da385d542 Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Thu, 10 Mar 2022 20:24:59 +0530 Subject: [PATCH] Fixed issue-3325 Data Quality - columnValuesMissingCountToBeEqual UI, 3338: Add Ingestion Modal are missing Snowflake (#3351) * added support to accept multiple value for missingValueMatch in columnValuesMissingCountToBeEqual test --- .../Forms/ColumnTestForm.tsx | 137 +++++++++++------- .../Forms/TableTestForm.tsx | 7 +- .../DataQualityTab/DataQualityTab.tsx | 3 + .../DatasetDetails.component.tsx | 2 + .../DatasetDetails.interface.ts | 1 + .../DatasetDetails/DatasetDetails.test.tsx | 1 + .../Ingestion/Ingestion.component.tsx | 2 + .../IngestionModal.component.tsx | 44 ++++++ .../IngestionModal.interface.ts | 1 + .../IngestionModal/IngestionModal.test.tsx | 3 + .../entity/services/databaseService.ts | 1 + .../ui/src/interface/dataQuality.interface.ts | 2 +- .../DatasetDetailsPage.component.tsx | 6 + .../pages/tour-page/TourPage.component.tsx | 1 + .../resources/ui/src/utils/ServiceUtils.ts | 83 ++--------- 15 files changed, 167 insertions(+), 127 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/Forms/ColumnTestForm.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/Forms/ColumnTestForm.tsx index 88261db6cd8..c2305bc0f34 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/Forms/ColumnTestForm.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/Forms/ColumnTestForm.tsx @@ -95,8 +95,8 @@ const ColumnTestForm = ({ }); const [columnName, setColumnName] = useState(data?.columnName); - const [missingValueMatch, setMissingValueMatch] = useState( - data?.testCase?.config?.missingValueMatch || '' + const [missingValueMatch, setMissingValueMatch] = useState( + data?.testCase?.config?.missingValueMatch || [''] ); const [missingCountValue, setMissingCountValue] = useState< number | undefined @@ -123,6 +123,22 @@ const ColumnTestForm = ({ setIsShowError({ ...isShowError, values: false }); }; + const addMatchFields = () => { + setMissingValueMatch([...missingValueMatch, '']); + }; + + const removeMatchFields = (i: number) => { + const newFormValues = [...missingValueMatch]; + newFormValues.splice(i, 1); + setMissingValueMatch(newFormValues); + }; + + const handlMatchFieldsChange = (i: number, value: string) => { + const newFormValues = [...missingValueMatch]; + newFormValues[i] = value; + setMissingValueMatch(newFormValues); + }; + const setAllTestOption = (datatype: string) => { const newTest = filteredColumnTestOption(datatype); setTestTypeOptions(newTest); @@ -225,14 +241,18 @@ const ColumnTestForm = ({ maxValue: !isEmpty(maxValue) ? maxValue : undefined, }; - case ColumnTestType.columnValuesMissingCountToBeEqual: + case ColumnTestType.columnValuesMissingCountToBeEqual: { + const filterMatchValue = missingValueMatch.filter( + (value) => !isEmpty(value) + ); + return { missingCountValue: missingCountValue, - missingValueMatch: !isEmpty(missingValueMatch) + missingValueMatch: filterMatchValue.length ? missingValueMatch : undefined, }; - + } case ColumnTestType.columnValuesToBeNotInSet: return { forbiddenValues: forbiddenValues.filter((v) => !isEmpty(v)), @@ -344,11 +364,6 @@ const ColumnTestForm = ({ break; } - case 'missingValueMatch': - setMissingValueMatch(value); - - break; - case 'missingCountValue': setMissingCountValue(value as unknown as number); errorMsg.missingCountValue = false; @@ -413,42 +428,67 @@ const ColumnTestForm = ({ const getMissingCountToBeEqualFields = () => { return ( -
-
- - - {isShowError.missingCountValue && - errorMsg('Count value is required.')} -
-
- - + + + + {isShowError.missingCountValue && + errorMsg('Count value is required.')} + + +
+
+

Match:

+