You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2025/09/02 20:41:51 UTC
(superset) branch 6.0 updated: fix(charts): Handle virtual dataset names without schema prefix correctly (#34760)
This is an automated email from the ASF dual-hosted git repository.
jli pushed a commit to branch 6.0
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/6.0 by this push:
new 38b456bc8a fix(charts): Handle virtual dataset names without schema prefix correctly (#34760)
38b456bc8a is described below
commit 38b456bc8ab798def01eaad6c8335d8a50175b77
Author: Evan Rusackas <ev...@preset.io>
AuthorDate: Tue Sep 2 12:16:51 2025 -0700
fix(charts): Handle virtual dataset names without schema prefix correctly (#34760)
Co-authored-by: Claude <no...@anthropic.com>
(cherry picked from commit b5ae402c12caa807359b5369596f492a73e8d268)
---
.../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 ce1e5b1709..6f2bfa29af 100644
--- a/superset-frontend/src/pages/ChartList/index.tsx
+++ b/superset-frontend/src/pages/ChartList/index.tsx
@@ -385,14 +385,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,