diff --git a/superset-frontend/src/components/AlteredSliceTag/utils/index.ts b/superset-frontend/src/components/AlteredSliceTag/utils/index.ts index 482a4332621..9fa9830e785 100644 --- a/superset-frontend/src/components/AlteredSliceTag/utils/index.ts +++ b/superset-frontend/src/components/AlteredSliceTag/utils/index.ts @@ -52,7 +52,7 @@ export const formatValueHandler = ( v.comparator && v.comparator.constructor === Array ? `[${v.comparator.join(', ')}]` : v.comparator; - return `${v.subject} ${v.operator} ${filterVal}`; + return filterVal ? `${v.subject} ${v.operator} ${filterVal}` : `${v.subject} ${v.operator}`; }) .join(', '); } diff --git a/superset-frontend/src/components/AlteredSliceTag/utils/utils.test.ts b/superset-frontend/src/components/AlteredSliceTag/utils/utils.test.ts index feddddeb0a1..1ceee92c589 100644 --- a/superset-frontend/src/components/AlteredSliceTag/utils/utils.test.ts +++ b/superset-frontend/src/components/AlteredSliceTag/utils/utils.test.ts @@ -258,6 +258,33 @@ describe('formatValueHandler', () => { expect(result).toEqual(expected); }); + + test('formats unary filter', () => { + const filters = [ + { + expressionType: 'SIMPLE', + operator: 'IS NULL', + subject: 'a', + }, + { + clause: 'WHERE', + comparator: ['hu', 'ho', 'ha'], + expressionType: 'SIMPLE', + operator: 'NOT IN', + subject: 'b', + }, + ]; + const key = 'adhoc_filters'; + + const expected = 'a IS NULL, b NOT IN [hu, ho, ha]'; + const formattedValue: string | number = formatValueHandler( + filters, + key, + controlsMap, + ); + + expect(formattedValue).toEqual(expected); + }); }); // eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks