You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2026/04/13 19:57:56 UTC
(superset) 01/01: fix(table): use column label instead of SQL expression for orderby in downloads
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch sc-102502-interactive-table-download-error
in repository https://gitbox.apache.org/repos/asf/superset.git
commit ccfc7722a325f9bf93094ff0154561881f2daa3a
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Mon Apr 13 17:14:34 2026 +0000
fix(table): use column label instead of SQL expression for orderby in downloads
The AG Grid table's download query builder was sending raw SQL expressions
(e.g. "sales / 100") as orderby column identifiers instead of column labels.
The backend resolves orderby strings by matching against adhoc column labels,
so expressions like "sales / 100" failed with "Unknown column used in orderby".
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
.../plugin-chart-ag-grid-table/src/buildQuery.ts | 6 ------
.../test/buildQuery.test.ts | 21 ++++++++++++++++++++-
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
index 3d04b6c1d1c..97c2a77e26f 100644
--- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
+++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
@@ -238,12 +238,6 @@ const buildQuery: BuildQuery<TableChartFormData> = (
});
if (matchingColumn) {
- if (
- typeof matchingColumn === 'object' &&
- 'sqlExpression' in matchingColumn
- ) {
- return matchingColumn.sqlExpression;
- }
return getColumnLabel(matchingColumn);
}
diff --git a/superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.test.ts b/superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.test.ts
index acec22c6965..ecb00812330 100644
--- a/superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.test.ts
+++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.test.ts
@@ -90,7 +90,7 @@ describe('plugin-chart-ag-grid-table', () => {
},
).queries[0];
- expect(query.orderby).toEqual([['degree_type', true]]);
+ expect(query.orderby).toEqual([['Highest Degree', true]]);
});
test('should map string metric colId to backend identifier', () => {
@@ -267,6 +267,25 @@ describe('plugin-chart-ag-grid-table', () => {
]);
});
+ test('should use label (not sqlExpression) for adhoc column in CSV export sortModel', () => {
+ const adhocColumn = createAdhocColumn('sales / 100', 'Margin');
+
+ const query = buildQuery(
+ {
+ ...basicFormData,
+ groupby: [adhocColumn],
+ result_format: 'csv',
+ },
+ {
+ ownState: {
+ sortModel: [{ colId: 'Margin', sort: 'desc' }],
+ },
+ },
+ ).queries[0];
+
+ expect(query.orderby?.[0]).toEqual(['Margin', false]);
+ });
+
test('should not add tie-breaker for non-download queries with server pagination', () => {
const query = buildQuery(
{