You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2025/08/19 18:01:41 UTC

(superset) branch fix-33335-explore-color-consistency created (now 1c6d5bc207)

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

rusackas pushed a change to branch fix-33335-explore-color-consistency
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 1c6d5bc207 fix(charts): Handle virtual dataset names without schema prefix correctly

This branch includes the following new commits:

     new 1c6d5bc207 fix(charts): Handle virtual dataset names without schema prefix correctly

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: fix(charts): Handle virtual dataset names without schema prefix correctly

Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch fix-33335-explore-color-consistency
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 1c6d5bc2079b16ae3659e653e32e3f2daee322d5
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Tue Aug 19 11:01:11 2025 -0700

    fix(charts): Handle virtual dataset names without schema prefix correctly
    
    Fixes #33335
    
    Virtual datasets with names that don't contain a period (no schema prefix) were not displaying correctly in the chart list. The issue was caused by PR #29944 which assumed all dataset names would have a schema.name format and split by '.' to extract just the name.
    
    This fix properly handles both formats:
    - schema.name (displays as "name")
    - name without schema (displays as "name")
    - Names containing dots are handled correctly by only removing the first segment (schema)
    
    Added comprehensive tests to verify the fix works for all dataset name formats.
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <no...@anthropic.com>
---
 .../pages/ChartList/ChartList.listview.test.tsx    | 78 ++++++++++++++++++++++
 superset-frontend/src/pages/ChartList/index.tsx    | 23 ++++---
 2 files changed, 93 insertions(+), 8 deletions(-)

diff --git a/superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx b/superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx
index 3ba5a9ab61..12a7fcbb24 100644
--- a/superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx
+++ b/superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx
@@ -93,6 +93,84 @@ describe('ChartList - List View Tests', () => {
     });
   });
 
+  it('correctly displays dataset names with and without schema', async () => {
+    // Create custom mock data with different datasource_name_text formats
+    const customMockCharts = [
+      {
+        ...mockCharts[0],
+        id: 100,
+        slice_name: 'Chart with Schema',
+        datasource_name_text: 'public.test_dataset',
+      },
+      {
+        ...mockCharts[0],
+        id: 101,
+        slice_name: 'Chart without Schema',
+        datasource_name_text: 'Jinja 5', // Virtual dataset without schema
+      },
+      {
+        ...mockCharts[0],
+        id: 102,
+        slice_name: 'Chart with Dots in Name',
+        datasource_name_text: 'schema.table.with.dots', // Name contains dots
+      },
+    ];
+
+    // Setup mock with custom charts
+    fetchMock.reset();
+    setupMocks();
+    fetchMock.get(
+      'glob:*/api/v1/chart/?*',
+      {
+        result: customMockCharts,
+        chart_count: customMockCharts.length,
+      },
+      { overwriteRoutes: true },
+    );
+
+    renderChartList(mockUser);
+
+    // Wait for table to be rendered
+    await waitFor(() => {
+      expect(screen.getByTestId('listview-table')).toBeInTheDocument();
+    });
+
+    // Wait for data to load
+    await waitFor(() => {
+      expect(screen.getByText('Chart with Schema')).toBeInTheDocument();
+    });
+
+    // Find the specific dataset links by their parent row context
+    const schemaRow = screen.getByText('Chart with Schema').closest('tr');
+    const noSchemaRow = screen.getByText('Chart without Schema').closest('tr');
+    const dotsRow = screen.getByText('Chart with Dots in Name').closest('tr');
+
+    // Check dataset name displays correctly for each case
+    // For chart with schema (public.test_dataset)
+    expect(schemaRow).toBeInTheDocument();
+    const schemaLink = within(schemaRow!).getByRole('link', {
+      name: /test_dataset/i,
+    });
+    expect(schemaLink).toBeInTheDocument();
+    expect(schemaLink).toHaveTextContent('test_dataset');
+
+    // For chart without schema (Jinja 5)
+    expect(noSchemaRow).toBeInTheDocument();
+    const noSchemaLink = within(noSchemaRow!).getByRole('link', {
+      name: /Jinja 5/i,
+    });
+    expect(noSchemaLink).toBeInTheDocument();
+    expect(noSchemaLink).toHaveTextContent('Jinja 5');
+
+    // For chart with dots in name (schema.table.with.dots)
+    expect(dotsRow).toBeInTheDocument();
+    const dotsLink = within(dotsRow!).getByRole('link', {
+      name: /table\.with\.dots/i,
+    });
+    expect(dotsLink).toBeInTheDocument();
+    expect(dotsLink).toHaveTextContent('table.with.dots');
+  });
+
   it('switches from list view to card view', async () => {
     renderChartList(mockUser);
 
diff --git a/superset-frontend/src/pages/ChartList/index.tsx b/superset-frontend/src/pages/ChartList/index.tsx
index ebb59def08..38d58de8c2 100644
--- a/superset-frontend/src/pages/ChartList/index.tsx
+++ b/superset-frontend/src/pages/ChartList/index.tsx
@@ -387,14 +387,21 @@ function ChartList(props: ChartListProps) {
               datasource_url: dsUrl,
             },
           },
-        }: any) => (
-          <Tooltip title={dsNameTxt} placement="top">
-            {/* dsNameTxt can be undefined, schema.name or just name */}
-            <GenericLink to={dsUrl}>
-              {dsNameTxt ? dsNameTxt.split('.')[1] || dsNameTxt : ''}
-            </GenericLink>
-          </Tooltip>
-        ),
+        }: any) => {
+          // Extract dataset name from datasource_name_text
+          // Format can be "schema.name" or just "name"
+          const displayName = dsNameTxt
+            ? dsNameTxt.includes('.')
+              ? dsNameTxt.split('.').slice(1).join('.') // Handle names with dots
+              : dsNameTxt // No schema, use the full name
+            : '';
+
+          return (
+            <Tooltip title={dsNameTxt} placement="top">
+              <GenericLink to={dsUrl}>{displayName}</GenericLink>
+            </Tooltip>
+          );
+        },
         Header: t('Dataset'),
         accessor: 'datasource_id',
         disableSortBy: true,