This is an automated email from the ASF dual-hosted git repository.

aminghadersohi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new fcfa730a865 fix(dashboard): deduplicate native filter column options 
(#46218)
fcfa730a865 is described below

commit fcfa730a865a5e15cb3ac1c6d074b980891446c4
Author: Mike Bridge <[email protected]>
AuthorDate: Mon Nov 16 12:15:45 2026 -0600

    fix(dashboard): deduplicate native filter column options (#46218)
---
 .../using-superset/semantic-member-selections.mdx  |   7 ++
 .../ColumnSelect.semanticGrains.test.tsx           | 103 +++++++++++++++++++++
 .../FiltersConfigForm/ColumnSelect.tsx             |  26 ++++--
 3 files changed, 126 insertions(+), 10 deletions(-)

diff --git a/docs/docs/using-superset/semantic-member-selections.mdx 
b/docs/docs/using-superset/semantic-member-selections.mdx
index 456ba7613af..51aca6455ed 100644
--- a/docs/docs/using-superset/semantic-member-selections.mdx
+++ b/docs/docs/using-superset/semantic-member-selections.mdx
@@ -82,6 +82,13 @@ a usability aid for compatible selections, not a guarantee 
about each filter's
 provenance. The marker is not an authorization check; access to the datasource 
is
 verified separately.
 
+## Native filter columns
+
+The native-filter column picker lists each semantic member name once, even when
+the provider exposes several time-grain variants of that member. This matches
+Explore's column list: choosing a filter column selects the member, not a grain
+variant. Distinct member names remain separate choices.
+
 ## NULL filter values
 
 For semantic views, a selected NULL value means a missing value, rather than 
SQL's
diff --git 
a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.semanticGrains.test.tsx
 
b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.semanticGrains.test.tsx
new file mode 100644
index 00000000000..7390cb82e80
--- /dev/null
+++ 
b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.semanticGrains.test.tsx
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+import { DatasourceType } from '@superset-ui/core';
+import { Form } from '@superset-ui/core/components';
+import fetchMock from 'fetch-mock';
+import {
+  render,
+  screen,
+  userEvent,
+  waitFor,
+} from 'spec/helpers/testing-library';
+import { NativeFiltersForm } from '../types';
+import { ColumnSelect } from './ColumnSelect';
+
+const dimensions = [
+  { name: 'C.MARKET_SEGMENT', type: 'string', grain: null },
+  ...['DAY', 'WEEK', 'MONTH', 'QUARTER', 'YEAR'].map(grain => ({
+    name: 'L.SHIP_DATE',
+    type: 'date32[day]',
+    grain,
+  })),
+  { name: 'O.ORDER_DATE__MONTH', type: 'date32[day]', grain: 'MONTH' },
+];
+
+function renderPicker(id: number, mode?: 'multiple') {
+  fetchMock.get(`path:/api/v1/semantic_view/${id}/structure`, {
+    result: { dimensions, metrics: [] },
+  });
+  const onChange = jest.fn();
+  const onColumnsLoaded = jest.fn();
+  function Harness() {
+    const [form] = Form.useForm<NativeFiltersForm>();
+    return (
+      <ColumnSelect
+        form={form}
+        filterId="grain-probe"
+        datasetId={id}
+        datasourceType={DatasourceType.SemanticView}
+        onChange={onChange}
+        onColumnsLoaded={onColumnsLoaded}
+        mode={mode}
+      />
+    );
+  }
+  render(<Harness />, { useRedux: true });
+  return { onChange, onColumnsLoaded };
+}
+
+afterEach(() => fetchMock.clearHistory().removeRoutes());
+
+test.each([undefined, 'multiple'] as const)(
+  'offers each semantic member once with mode %s and preserves its name',
+  async mode => {
+    const { onChange, onColumnsLoaded } = renderPicker(mode ? 802 : 801, mode);
+    await waitFor(() => expect(onColumnsLoaded).toHaveBeenCalled());
+    await userEvent.click(screen.getByRole('combobox'));
+    expect(screen.getAllByTitle('L.SHIP_DATE')).toHaveLength(1);
+    expect(onColumnsLoaded).toHaveBeenLastCalledWith(
+      ['C.MARKET_SEGMENT', 'L.SHIP_DATE', 'O.ORDER_DATE__MONTH'],
+      `${mode ? 802 : 801}__semantic_view`,
+    );
+    await userEvent.click(screen.getByTitle('L.SHIP_DATE'));
+    expect(onChange.mock.calls[0][0]).toEqual(
+      mode ? ['L.SHIP_DATE'] : 'L.SHIP_DATE',
+    );
+  },
+);
+
+test('search removes non-matching grain entries after the full list renders', 
async () => {
+  const { onColumnsLoaded } = renderPicker(803);
+  await waitFor(() => expect(onColumnsLoaded).toHaveBeenCalled());
+  const search = screen.getByRole('combobox');
+  await userEvent.click(search);
+  expect(screen.getByTitle('C.MARKET_SEGMENT')).toBeInTheDocument();
+  await userEvent.type(search, 'MARKET');
+  await waitFor(() =>
+    expect(screen.queryAllByTitle('L.SHIP_DATE')).toHaveLength(0),
+  );
+  expect(screen.queryByTitle('O.ORDER_DATE__MONTH')).not.toBeInTheDocument();
+  expect(screen.getByTitle('C.MARKET_SEGMENT')).toBeInTheDocument();
+  await userEvent.clear(search);
+  await userEvent.type(search, 'SHIP');
+  await waitFor(() =>
+    expect(screen.queryByTitle('C.MARKET_SEGMENT')).not.toBeInTheDocument(),
+  );
+  expect(screen.getAllByTitle('L.SHIP_DATE')).toHaveLength(1);
+});
diff --git 
a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
 
b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
index f10eb8a7cbf..258b50f9c8a 100644
--- 
a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
+++ 
b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
@@ -18,6 +18,7 @@
  */
 import { useCallback, useState, useMemo, useEffect, useRef } from 'react';
 import rison from 'rison';
+import { uniq, uniqBy } from 'lodash-es';
 import { t } from '@apache-superset/core/translation';
 import {
   Column,
@@ -93,25 +94,30 @@ export function ColumnSelect({
     ]);
   }, [form, filterId, formField]);
 
-  // The names backing the rendered options: the loaded columns narrowed by
+  // The unique names backing the rendered options: the loaded columns 
narrowed by
   // `filterValues`, the same narrowing the option list applies, so a default
   // seeded through onColumnsLoaded matches the available options exactly.
   const filterColumnNames = useCallback(
     (cols: Column[]) =>
-      ensureIsArray(cols)
-        .filter(filterValues)
-        .map((col: Column) => col.column_name),
+      uniq(
+        ensureIsArray(cols)
+          .filter(filterValues)
+          .map((col: Column) => col.column_name),
+      ),
     [filterValues],
   );
 
   const options = useMemo(
     () =>
-      ensureIsArray(columns)
-        .filter(filterValues)
-        .map((col: Column) => ({
-          label: (showVerboseNames && col.verbose_name) || col.column_name,
-          value: col.column_name,
-        })),
+      uniqBy(
+        ensureIsArray(columns)
+          .filter(filterValues)
+          .map((col: Column) => ({
+            label: (showVerboseNames && col.verbose_name) || col.column_name,
+            value: col.column_name,
+          })),
+        'value',
+      ),
     [columns, filterValues, showVerboseNames],
   );
 

Reply via email to