From b49f12b735723825696db605eac8cd0806b457e5 Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Tue, 8 Mar 2022 14:30:51 +0530 Subject: [PATCH] Fixed: issue- 3226 and 3230 related to data config schema changes. (#3253) --- .../Forms/ColumnTestForm.tsx | 12 +++++-- .../Forms/TableTestForm.tsx | 32 ++++++++++++++----- .../generated/api/tests/createTableTest.ts | 6 ++-- .../column/columnValuesLengthsToBeBetween.ts | 30 +++++++++++++++++ .../tests/column/columnValuesToBeBetween.ts | 30 +++++++++++++++++ .../tests/column/columnValuesToBeNotInSet.ts | 24 ++++++++++++++ .../tests/column/columnValuesToBeNotNull.ts | 20 ++++++++++++ .../tests/column/columnValuesToBeUnique.ts | 20 ++++++++++++ .../tests/column/columnValuesToMatchRegex.ts | 24 ++++++++++++++ .../tests/table/tableColumnCountToEqual.ts | 4 +-- .../ui/src/generated/tests/tableTest.ts | 6 ++-- 11 files changed, 191 insertions(+), 17 deletions(-) create mode 100644 openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesLengthsToBeBetween.ts create mode 100644 openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeBetween.ts create mode 100644 openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeNotInSet.ts create mode 100644 openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeNotNull.ts create mode 100644 openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeUnique.ts create mode 100644 openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToMatchRegex.ts 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 56eeaea76ca..0a99a614019 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 @@ -191,16 +191,22 @@ const ColumnTestForm = ({ const getTestConfi = () => { switch (columnTest) { case ColumnTestType.columnValueLengthsToBeBetween: + return { + minLength: !isEmpty(minValue) ? minValue : undefined, + maxLength: !isEmpty(maxValue) ? maxValue : undefined, + }; case ColumnTestType.columnValuesToBeBetween: return { - minValue: minValue, - maxValue: maxValue, + minValue: !isEmpty(minValue) ? minValue : undefined, + maxValue: !isEmpty(maxValue) ? maxValue : undefined, }; case ColumnTestType.columnValuesMissingCountToBeEqual: return { missingCountValue: missingCountValue, - missingValueMatch: missingValueMatch, + missingValueMatch: !isEmpty(missingValueMatch) + ? missingValueMatch + : undefined, }; case ColumnTestType.columnValuesToBeNotInSet: diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/Forms/TableTestForm.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/Forms/TableTestForm.tsx index f62bfa4b4cc..3f1bd30ab91 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/Forms/TableTestForm.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/Forms/TableTestForm.tsx @@ -115,20 +115,36 @@ const TableTestForm = ({ return !Object.values(errMsg).includes(true); }; - const handleSave = () => { - const isTableRowCountToBeBetweenTest = - tableTest === TableTestType.TableRowCountToBeBetween; + const getConfigValue = () => { + switch (tableTest) { + case TableTestType.TableRowCountToBeBetween: + return { + maxValue: isEmpty(maxValue) ? undefined : maxValue, + minValue: isEmpty(minValue) ? undefined : minValue, + }; + case TableTestType.TableColumnCountToEqual: + return { + columnCount: isEmpty(value) ? undefined : value, + }; + + case TableTestType.TableRowCountToEqual: + return { + value: isEmpty(value) ? undefined : value, + }; + + default: + return {}; + } + }; + + const handleSave = () => { if (validateForm()) { const createTest: CreateTableTest = { description: markdownRef.current?.getEditorContent() || undefined, executionFrequency: frequency, testCase: { - config: { - maxValue: isTableRowCountToBeBetweenTest ? maxValue : undefined, - minValue: isTableRowCountToBeBetweenTest ? minValue : undefined, - value: isTableRowCountToBeBetweenTest ? undefined : value, - }, + config: getConfigValue(), tableTestType: tableTest, }, owner: { diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/api/tests/createTableTest.ts b/openmetadata-ui/src/main/resources/ui/src/generated/api/tests/createTableTest.ts index fc11f5d3a16..9c50cf7b785 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/api/tests/createTableTest.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/api/tests/createTableTest.ts @@ -136,8 +136,6 @@ export interface TableTestCase { export interface TableRowCountToBeBetween { /** * Expected number of rows {value} - * - * Expected number of columns to equal to a {value} */ value?: number; /** @@ -150,6 +148,10 @@ export interface TableRowCountToBeBetween { * included, maxValue is treated as upperBound and there will be no minimum number of rows */ minValue?: number; + /** + * Expected number of columns to equal to a {value} + */ + columnCount?: number; } export enum TableTestType { diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesLengthsToBeBetween.ts b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesLengthsToBeBetween.ts new file mode 100644 index 00000000000..c290f5b129e --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesLengthsToBeBetween.ts @@ -0,0 +1,30 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* + * Copyright 2021 Collate + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This schema defines the test ColumnValueLengthsToBeBetween. Test the value lengths in a + * column to be between minimum and maximum value. + */ +export interface ColumnValuesLengthsToBeBetween { + /** + * The {maxLength} for the column length. if maxLength is not included, minLength is treated + * as lowerBound and there will eb no maximum number of rows + */ + maxLength?: number; + /** + * The {minLength} for the column length. If minLength is not included, maxLength is treated + * as upperBound and there will be no minimum number of rows + */ + minLength?: number; +} diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeBetween.ts b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeBetween.ts new file mode 100644 index 00000000000..5dcf8d2da77 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeBetween.ts @@ -0,0 +1,30 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* + * Copyright 2021 Collate + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This schema defines the test ColumnValuesToBeBetween. Test the values in a column to be + * between minimum and maximum value. + */ +export interface ColumnValuesToBeBetween { + /** + * The {maxValue} value for the column entry. if maxValue is not included, minValue is + * treated as lowerBound and there will eb no maximum number of rows + */ + maxValue?: number; + /** + * The {minValue} value for the column entry. If minValue is not included, maxValue is + * treated as upperBound and there will be no minimum number of rows + */ + minValue?: number; +} diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeNotInSet.ts b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeNotInSet.ts new file mode 100644 index 00000000000..dd3ade84fb3 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeNotInSet.ts @@ -0,0 +1,24 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* + * Copyright 2021 Collate + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This schema defines the test ColumnValuesToBeNotInSet. Test the column values to not be + * in the set. + */ +export interface ColumnValuesToBeNotInSet { + /** + * An Array of values. + */ + forbiddenValues: Array; +} diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeNotNull.ts b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeNotNull.ts new file mode 100644 index 00000000000..216d01ff61b --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeNotNull.ts @@ -0,0 +1,20 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-empty-interface */ +/* + * Copyright 2021 Collate + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This schema defines the test ColumnValuesToBeNotNull. Test the number of values in a + * column are null. Values must be explicitly null. Empty strings don't count as null. + */ +export interface ColumnValuesToBeNotNull {} diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeUnique.ts b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeUnique.ts new file mode 100644 index 00000000000..00bd9346ceb --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToBeUnique.ts @@ -0,0 +1,20 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-empty-interface */ +/* + * Copyright 2021 Collate + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This schema defines the test ColumnValuesToBeUnique. Test the values in a column to be + * unique. + */ +export interface ColumnValuesToBeUnique {} diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToMatchRegex.ts b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToMatchRegex.ts new file mode 100644 index 00000000000..5d929cd0f22 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/generated/tests/column/columnValuesToMatchRegex.ts @@ -0,0 +1,24 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* + * Copyright 2021 Collate + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This schema defines the test ColumnValuesToMatchRegex. Test the values in a column to + * match a given regular expression. + */ +export interface ColumnValuesToMatchRegex { + /** + * The regular expression the column entries should match. + */ + regex: string; +} diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/tests/table/tableColumnCountToEqual.ts b/openmetadata-ui/src/main/resources/ui/src/generated/tests/table/tableColumnCountToEqual.ts index 9b8e104ceb4..89c2c99e686 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/tests/table/tableColumnCountToEqual.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/tests/table/tableColumnCountToEqual.ts @@ -18,7 +18,7 @@ */ export interface TableColumnCountToEqual { /** - * Expected number of columns to equal to a {value} + * Expected number of columns to equal to a {value} */ - value: number; + columnCount: number; } diff --git a/openmetadata-ui/src/main/resources/ui/src/generated/tests/tableTest.ts b/openmetadata-ui/src/main/resources/ui/src/generated/tests/tableTest.ts index b1b84fff430..4ee4bfd3231 100644 --- a/openmetadata-ui/src/main/resources/ui/src/generated/tests/tableTest.ts +++ b/openmetadata-ui/src/main/resources/ui/src/generated/tests/tableTest.ts @@ -147,8 +147,6 @@ export interface TableTestCase { export interface TableRowCountToBeBetween { /** * Expected number of rows {value} - * - * Expected number of columns to equal to a {value} */ value?: number; /** @@ -161,6 +159,10 @@ export interface TableRowCountToBeBetween { * included, maxValue is treated as upperBound and there will be no minimum number of rows */ minValue?: number; + /** + * Expected number of columns to equal to a {value} + */ + columnCount?: number; } export enum TableTestType {