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 2026/06/01 16:24:54 UTC
(superset) branch master updated: fix(dashboard): preserve user selection when Dynamic Group By overlaps base (#40031)
This is an automated email from the ASF dual-hosted git repository.
rusackas 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 d52e28c564b fix(dashboard): preserve user selection when Dynamic Group By overlaps base (#40031)
d52e28c564b is described below
commit d52e28c564bb1d20aa8ad246ab5244a9275e6278
Author: jesperct <jm...@gmail.com>
AuthorDate: Mon Jun 1 13:24:45 2026 -0300
fix(dashboard): preserve user selection when Dynamic Group By overlaps base (#40031)
---
.../util/charts/getFormDataWithExtraFilters.ts | 4 +-
.../util/getFormDataWithExtraFilters.test.ts | 105 +++++----------------
2 files changed, 24 insertions(+), 85 deletions(-)
diff --git a/superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts b/superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts
index 161e0edddb3..ed383210314 100644
--- a/superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts
+++ b/superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts
@@ -141,9 +141,7 @@ function buildExistingColumnsSet(chart: ChartQueryPayload): Set<string> {
const existingColumns = new Set<string>();
const chartType = chart.form_data?.viz_type;
- const existingGroupBy = ensureIsArray(chart.form_data?.groupby);
- extractColumnNames(existingGroupBy).forEach(col => existingColumns.add(col));
-
+ // Base groupby is excluded: Dynamic Group By REPLACES it with the user's selection.
const xAxisColumn = chart.form_data?.x_axis;
if (xAxisColumn && chartType !== 'heatmap' && chartType !== 'heatmap_v2') {
existingColumns.add(xAxisColumn);
diff --git a/superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts b/superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts
index 61adf3e3ad4..1faad5322fc 100644
--- a/superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts
+++ b/superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts
@@ -433,14 +433,14 @@ test('dataset mismatch: display control for a different dataset does not affect
expectGroupBy(result, ['original_column']);
});
-test('dynamic group by with overlapping selection preserves multi-column base groupby', () => {
+test('dynamic group by replaces base groupby with the user selection (subset case)', () => {
const result = getFormDataWithExtraFilters(
makeGroupByArgs(['status'], ['status', 'category']),
);
- expectGroupBy(result, ['status', 'category']);
+ expectGroupBy(result, ['status']);
});
-test('timeseries chart: overlapping selection preserves multi-column base groupby', () => {
+test('timeseries chart: dynamic group by replaces base groupby with the user selection', () => {
const customizationId = 'CHART_CUSTOMIZATION-groupby-1';
const result = getFormDataWithExtraFilters({
...mockArgs,
@@ -466,17 +466,12 @@ test('timeseries chart: overlapping selection preserves multi-column base groupb
createChartCustomization({ id: customizationId }),
],
});
- expectGroupBy(result, ['series_col', 'breakdown_col']);
+ expectGroupBy(result, ['series_col']);
});
-test('partial overlap: only non-existing columns pass through as customization override', () => {
- const result = getFormDataWithExtraFilters(
- makeGroupByArgs(['status', 'new_col'], ['status', 'category']),
- );
- expectGroupBy(result, ['new_col']);
-});
-
-test('object-typed groupby entries (AdhocColumn) are recognized as existing columns', () => {
+test('regression #39356: an all-conflicting selection keeps the base groupby and never empties it', () => {
+ // Selecting only the x_axis (already in use) contributes no new dimension, so the
+ // base groupby survives unchanged rather than the chart losing its dimensions.
const customizationId = 'CHART_CUSTOMIZATION-groupby-1';
const result = getFormDataWithExtraFilters({
...mockArgs,
@@ -484,16 +479,17 @@ test('object-typed groupby entries (AdhocColumn) are recognized as existing colu
...mockChart,
form_data: {
...mockChart.form_data,
- viz_type: 'table',
+ viz_type: 'echarts_timeseries_line',
datasource: '3__table',
- groupby: [{ column_name: 'status' }, 'category'],
+ groupby: ['series_col', 'breakdown_col'],
+ x_axis: 'time_col',
},
},
dataMask: {
[customizationId]: {
id: customizationId,
extraFormData: {},
- filterState: { value: ['status', 'new_col'] },
+ filterState: { value: ['time_col'] },
ownState: {},
},
},
@@ -501,77 +497,22 @@ test('object-typed groupby entries (AdhocColumn) are recognized as existing colu
createChartCustomization({ id: customizationId }),
],
});
- // 'status' is already in groupby (as an object with column_name), so only 'new_col' passes through
- expectGroupBy(result, ['new_col']);
+ expectGroupBy(result, ['series_col', 'breakdown_col']);
});
-test('AdhocColumn with sqlExpression (no column_name) is recognized as existing column', () => {
- const customizationId = 'CHART_CUSTOMIZATION-groupby-1';
- const result = getFormDataWithExtraFilters({
- ...mockArgs,
- chart: {
- ...mockChart,
- form_data: {
- ...mockChart.form_data,
- viz_type: 'table',
- datasource: '3__table',
- groupby: [
- {
- sqlExpression: 'CASE WHEN status = 1 THEN "active" END',
- label: 'status_label',
- expressionType: 'SQL',
- },
- 'category',
- ],
- },
- },
- dataMask: {
- [customizationId]: {
- id: customizationId,
- extraFormData: {},
- filterState: { value: ['status_label', 'new_col'] },
- ownState: {},
- },
- },
- chartCustomizationItems: [
- createChartCustomization({ id: customizationId }),
- ],
- });
- // 'status_label' matches the AdhocColumn's label, so only 'new_col' passes through
- expectGroupBy(result, ['new_col']);
+test('SC-100237: selecting base dimension + new dimension keeps BOTH in groupby', () => {
+ const result = getFormDataWithExtraFilters(
+ makeGroupByArgs(['product_line', 'deal_size'], ['product_line']),
+ );
+ expectGroupBy(result, ['product_line', 'deal_size']);
+ expectGroupByLength(result, 2);
});
-test('AdhocColumn with empty label falls back to sqlExpression for identity', () => {
- const customizationId = 'CHART_CUSTOMIZATION-groupby-1';
- const sqlExpr = 'CASE WHEN status = 1 THEN "active" END';
- const result = getFormDataWithExtraFilters({
- ...mockArgs,
- chart: {
- ...mockChart,
- form_data: {
- ...mockChart.form_data,
- viz_type: 'table',
- datasource: '3__table',
- groupby: [
- { sqlExpression: sqlExpr, label: '', expressionType: 'SQL' },
- 'category',
- ],
- },
- },
- dataMask: {
- [customizationId]: {
- id: customizationId,
- extraFormData: {},
- filterState: { value: [sqlExpr, 'new_col'] },
- ownState: {},
- },
- },
- chartCustomizationItems: [
- createChartCustomization({ id: customizationId }),
- ],
- });
- // Empty label → falls back to sqlExpression; sqlExpr is in existingColumns, only 'new_col' passes
- expectGroupBy(result, ['new_col']);
+test('dynamic group by replaces base with mixed (overlap + new) selection', () => {
+ const result = getFormDataWithExtraFilters(
+ makeGroupByArgs(['status', 'new_col'], ['status', 'category']),
+ );
+ expectGroupBy(result, ['status', 'new_col']);
});
test('Scope boundary: display control with chartsInScope:[] does not affect the chart', () => {