mirror of
https://github.com/apache/superset.git
synced 2026-04-17 23:25:05 +00:00
fix: Do no aggregate results for CSV downloads from AG Grid raw records table (#36247)
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
||||
QueryFormOrderBy,
|
||||
QueryMode,
|
||||
QueryObject,
|
||||
QueryObjectExtras,
|
||||
removeDuplicates,
|
||||
PostProcessingRule,
|
||||
BuildQuery,
|
||||
@@ -322,7 +323,9 @@ const buildQuery: BuildQuery<TableChartFormData> = (
|
||||
};
|
||||
|
||||
orderedColumns = reorderByColumnOrder(columns) as typeof columns;
|
||||
orderedMetrics = reorderByColumnOrder(metrics || []) as typeof metrics;
|
||||
orderedMetrics = metrics
|
||||
? (reorderByColumnOrder(metrics) as typeof metrics)
|
||||
: metrics;
|
||||
}
|
||||
|
||||
let queryObject = {
|
||||
@@ -473,7 +476,7 @@ const buildQuery: BuildQuery<TableChartFormData> = (
|
||||
? `${queryObject.extras.having} AND ${havingClause}`
|
||||
: havingClause,
|
||||
}),
|
||||
};
|
||||
} as QueryObjectExtras;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,4 +475,28 @@ describe('plugin-chart-ag-grid-table', () => {
|
||||
expect(query.columns).toEqual(['state', 'city']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildQuery - metrics handling in different query modes', () => {
|
||||
test('should not include metrics in raw records mode', () => {
|
||||
const query = buildQuery({
|
||||
viz_type: VizType.Table,
|
||||
datasource: '11__table',
|
||||
query_mode: QueryMode.Raw,
|
||||
all_columns: ['state', 'city'],
|
||||
}).queries[0];
|
||||
|
||||
expect(query.metrics).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should set metrics to empty array in aggregate mode when no metrics specified', () => {
|
||||
const query = buildQuery({
|
||||
viz_type: VizType.Table,
|
||||
datasource: '11__table',
|
||||
query_mode: QueryMode.Aggregate,
|
||||
groupby: ['state'],
|
||||
}).queries[0];
|
||||
|
||||
expect(query.metrics).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user