mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-02 21:53:30 +00:00
Fix: issue-3277: filtering column test option depending on datatype (#3306)
This commit is contained in:
parent
40e7d37244
commit
be9a1e8d1b
@ -27,7 +27,10 @@ import {
|
|||||||
getCurrentUserId,
|
getCurrentUserId,
|
||||||
requiredField,
|
requiredField,
|
||||||
} from '../../../utils/CommonUtils';
|
} from '../../../utils/CommonUtils';
|
||||||
import { isSupportedTest } from '../../../utils/EntityUtils';
|
import {
|
||||||
|
filteredColumnTestOption,
|
||||||
|
isSupportedTest,
|
||||||
|
} from '../../../utils/EntityUtils';
|
||||||
import SVGIcons from '../../../utils/SvgUtils';
|
import SVGIcons from '../../../utils/SvgUtils';
|
||||||
import { getDataTypeString } from '../../../utils/TableUtils';
|
import { getDataTypeString } from '../../../utils/TableUtils';
|
||||||
import { Button } from '../../buttons/Button/Button';
|
import { Button } from '../../buttons/Button/Button';
|
||||||
@ -120,10 +123,10 @@ const ColumnTestForm = ({
|
|||||||
setIsShowError({ ...isShowError, values: false });
|
setIsShowError({ ...isShowError, values: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
const setAllTestOption = (defaultSelected: boolean) => {
|
const setAllTestOption = (datatype: string) => {
|
||||||
const newTest = Object.values(ColumnTestType);
|
const newTest = filteredColumnTestOption(datatype);
|
||||||
setTestTypeOptions(newTest);
|
setTestTypeOptions(newTest);
|
||||||
setColumnTest(defaultSelected ? newTest[0] : ('' as ColumnTestType));
|
setColumnTest('' as ColumnTestType);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTestTypeOptionChange = (name: string) => {
|
const handleTestTypeOptionChange = (name: string) => {
|
||||||
@ -134,16 +137,16 @@ const ColumnTestForm = ({
|
|||||||
(d: ColumnTest) => d.testCase.columnTestType
|
(d: ColumnTest) => d.testCase.columnTestType
|
||||||
) || [];
|
) || [];
|
||||||
if (existingTests.length) {
|
if (existingTests.length) {
|
||||||
const newTest = Object.values(ColumnTestType).filter(
|
const newTest = filteredColumnTestOption(
|
||||||
(d) => !existingTests.includes(d)
|
selectedColumn?.dataType || ''
|
||||||
);
|
).filter((d) => !existingTests.includes(d));
|
||||||
setTestTypeOptions(newTest);
|
setTestTypeOptions(newTest);
|
||||||
setColumnTest(newTest[0]);
|
setColumnTest(newTest[0]);
|
||||||
} else {
|
} else {
|
||||||
setAllTestOption(true);
|
setAllTestOption(selectedColumn?.dataType || '');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setAllTestOption(false);
|
setAllTestOption('');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,7 +156,7 @@ const ColumnTestForm = ({
|
|||||||
const selectedData = column.find((d) => d.name === selectedColumn);
|
const selectedData = column.find((d) => d.name === selectedColumn);
|
||||||
const allTestAdded =
|
const allTestAdded =
|
||||||
selectedData?.columnTests?.length ===
|
selectedData?.columnTests?.length ===
|
||||||
Object.values(ColumnTestType).length;
|
filteredColumnTestOption(selectedData?.dataType || '').length;
|
||||||
const isSupported = isSupportedTest(selectedData?.dataType || '');
|
const isSupported = isSupportedTest(selectedData?.dataType || '');
|
||||||
setIsShowError({
|
setIsShowError({
|
||||||
...isShowError,
|
...isShowError,
|
||||||
@ -333,7 +336,7 @@ const ColumnTestForm = ({
|
|||||||
handleTestTypeOptionChange(value);
|
handleTestTypeOptionChange(value);
|
||||||
errorMsg.allTestAdded =
|
errorMsg.allTestAdded =
|
||||||
selectedColumn?.columnTests?.length ===
|
selectedColumn?.columnTests?.length ===
|
||||||
Object.values(ColumnTestType).length;
|
filteredColumnTestOption(selectedColumn?.dataType || '').length;
|
||||||
errorMsg.columnName = false;
|
errorMsg.columnName = false;
|
||||||
errorMsg.testName = false;
|
errorMsg.testName = false;
|
||||||
errorMsg.notSupported = isSupportedTest(selectedColumn?.dataType || '');
|
errorMsg.notSupported = isSupportedTest(selectedColumn?.dataType || '');
|
||||||
|
@ -22,6 +22,7 @@ import {
|
|||||||
getServiceDetailsPath,
|
getServiceDetailsPath,
|
||||||
getTeamDetailsPath,
|
getTeamDetailsPath,
|
||||||
} from '../constants/constants';
|
} from '../constants/constants';
|
||||||
|
import { ColumnTestType } from '../enums/columnTest.enum';
|
||||||
import { EntityType } from '../enums/entity.enum';
|
import { EntityType } from '../enums/entity.enum';
|
||||||
import { ServiceCategory } from '../enums/service.enum';
|
import { ServiceCategory } from '../enums/service.enum';
|
||||||
import { Dashboard } from '../generated/entity/data/dashboard';
|
import { Dashboard } from '../generated/entity/data/dashboard';
|
||||||
@ -34,6 +35,7 @@ import { TagLabel } from '../generated/type/tagLabel';
|
|||||||
import { getPartialNameFromFQN } from './CommonUtils';
|
import { getPartialNameFromFQN } from './CommonUtils';
|
||||||
import SVGIcons from './SvgUtils';
|
import SVGIcons from './SvgUtils';
|
||||||
import {
|
import {
|
||||||
|
getDataTypeString,
|
||||||
getOwnerFromId,
|
getOwnerFromId,
|
||||||
getTierFromTableTags,
|
getTierFromTableTags,
|
||||||
getUsagePercentile,
|
getUsagePercentile,
|
||||||
@ -482,3 +484,41 @@ export const getEntityFeedLink: Function = (
|
|||||||
export const isSupportedTest = (dataType: string) => {
|
export const isSupportedTest = (dataType: string) => {
|
||||||
return dataType === 'ARRAY' || dataType === 'STRUCT';
|
return dataType === 'ARRAY' || dataType === 'STRUCT';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const filteredColumnTestOption = (dataType: string) => {
|
||||||
|
switch (getDataTypeString(dataType)) {
|
||||||
|
case 'numeric':
|
||||||
|
return Object.values(ColumnTestType).filter(
|
||||||
|
(test) => test !== ColumnTestType.columnValueLengthsToBeBetween
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'varchar':
|
||||||
|
return Object.values(ColumnTestType).filter(
|
||||||
|
(test) => test !== ColumnTestType.columnValuesToBeBetween
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'timestamp': {
|
||||||
|
const excluded = [
|
||||||
|
ColumnTestType.columnValuesToBeNotInSet,
|
||||||
|
ColumnTestType.columnValueLengthsToBeBetween,
|
||||||
|
];
|
||||||
|
|
||||||
|
return Object.values(ColumnTestType).filter(
|
||||||
|
(test) => !excluded.includes(test)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
case 'boolean': {
|
||||||
|
const excluded = [
|
||||||
|
ColumnTestType.columnValuesToBeNotInSet,
|
||||||
|
ColumnTestType.columnValueLengthsToBeBetween,
|
||||||
|
ColumnTestType.columnValuesToBeBetween,
|
||||||
|
];
|
||||||
|
|
||||||
|
return Object.values(ColumnTestType).filter(
|
||||||
|
(test) => !excluded.includes(test)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return Object.values(ColumnTestType);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user