From e68da0e0394401156ef90db71d3abe1888cdd5aa Mon Sep 17 00:00:00 2001 From: Matt Fitzgerald Date: Thu, 19 Nov 2026 08:36:59 +1100 Subject: [PATCH 1/3] fix(pivot-table): hide all-null metric columns by default --- docs/sip/pivot-table-aggregation-parity.md | 13 ++ .../src/PivotTableChart.tsx | 2 + .../src/plugin/controlPanel.tsx | 14 ++ .../src/plugin/transformProps.ts | 2 + .../src/react-pivottable/utilities.ts | 28 ++- .../plugin-chart-pivot-table/src/types.ts | 1 + .../test/PivotTableChart.test.tsx | 58 ++++++ .../test/plugin/transformProps.test.ts | 14 ++ .../test/react-pivottable/utilities.test.ts | 193 ++++++++++++++++++ 9 files changed, 324 insertions(+), 1 deletion(-) diff --git a/docs/sip/pivot-table-aggregation-parity.md b/docs/sip/pivot-table-aggregation-parity.md index aac9de3a6126..6dd8be39efda 100644 --- a/docs/sip/pivot-table-aggregation-parity.md +++ b/docs/sip/pivot-table-aggregation-parity.md @@ -110,3 +110,16 @@ dict silently in the first place). 3. Resolve the open question above, then decide the actual migration shape for orphaned Median/StdDev/Variance/CountUnique `aggregateFunction` values — likely the "flagged for review" approach #42895's SIP proposed (exact surfacing mechanism — Tag vs. report vs. in-product banner — still Evan's call, not yet decided). 4. Revisit apache/superset#44625 (reports/exports re-aggregation bug) once shelved time is up. 5. Out of scope for now: Table / Table v2 parity (confirmed not affected the same way — no pivot-style global aggregate control there) and AG Grid Interactive Pivot (separate viz, tracked as sc-118999 internally). + +## Empty metric columns + +Pivot Table hides columns whose metric values are all NULL by default. This +also applies to saved charts that do not have a `hideEmptyColumns` setting, so +users do not need to edit their charts after an upgrade. Clear **Hide empty +columns** to display these columns. + +Zero is a value and keeps a column visible. Non-empty summaries and the parent +headers of populated columns also remain visible. The option only changes +column visibility. It retains the records and aggregators used for database +totals, result aggregations, and percentage denominators. A zero numerator +keeps its column even if a zero denominator makes its percentage undefined. diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx index 33ca56f02a19..8608a23384f1 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx @@ -251,6 +251,7 @@ export default function PivotTableChart(props: PivotTableProps) { currencyFormats, metricsLayout, showValuesAs, + hideEmptyColumns = true, aggregateFunction, metricColorFormatters, dateFormatters, @@ -760,6 +761,7 @@ export default function PivotTableChart(props: PivotTableProps) { onContextMenu={handleContextMenu} allowRenderHtml={allowRenderHtml} showValuesAs={showValuesAs} + hideEmptyColumns={hideEmptyColumns} aggregateFunction={aggregateFunction} /> diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx index 5d48935f3aa5..5a8b76f55e47 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx @@ -186,6 +186,20 @@ const config: ControlPanelConfig = { expanded: true, tabOverride: 'data', controlSetRows: [ + [ + { + name: 'hideEmptyColumns', + config: { + type: 'CheckboxControl', + label: t('Hide empty columns'), + default: true, + renderTrigger: true, + description: t( + 'Hide columns with only null metric values. Keep columns with zeros or non-empty summaries. This does not change totals or percentages.', + ), + }, + }, + ], [ { name: 'rowTotals', diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts index b5e3128af987..3588b2263008 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts @@ -208,6 +208,7 @@ export default function transformProps(chartProps: ChartProps) { rowTotals, rowSubTotals, collapseRows, + hideEmptyColumns = true, valueFormat, dateFormat, metricsLayout, @@ -288,6 +289,7 @@ export default function transformProps(chartProps: ChartProps) { rowTotals, rowSubTotals, collapseRows: Boolean(collapseRows), + hideEmptyColumns, valueFormat, currencyFormat, currencyCodeColumn, diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/utilities.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/utilities.ts index 3003fec754b0..2b0798921114 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/utilities.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/utilities.ts @@ -1685,7 +1685,33 @@ class PivotData { getColKeys(): string[][] { this.sortKeys(); - return this.colKeys; + if (!this.props.hideEmptyColumns) return this.colKeys; + + // Filter display keys only. Keep every aggregator and record available to + // totals, fraction denominators and drill filters. A zero is not empty. + const populated = new Set(); + const collect = (cells: Record) => { + Object.entries(cells).forEach(([key, aggregator]) => { + // Test the underlying metric before percentage formatting. A zero + // numerator must keep its column even when its denominator is zero. + const metric = (aggregator as FractionDenominator).inner ?? aggregator; + if (metric.value() != null) populated.add(key); + }); + }; + Object.values(this.tree).forEach(collect); + collect(this.colTotals); + + // Retain a parent header when a child has a value, even if the parent's + // own aggregate is null (for example an undefined ratio). + const visible = new Set(); + this.colKeys.forEach(key => { + if (populated.has(flatKey(key))) { + for (let depth = 1; depth <= key.length; depth += 1) { + visible.add(flatKey(key.slice(0, depth))); + } + } + }); + return this.colKeys.filter(key => visible.has(flatKey(key))); } getRowKeys(): string[][] { diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/types.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/types.ts index 3a303288792a..ceb46221be83 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/types.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/types.ts @@ -105,6 +105,7 @@ interface PivotTableCustomizeProps { * Viewers can still expand each group with its arrow. */ collapseRows?: boolean; + hideEmptyColumns?: boolean; valueFormat: string; currencyFormat: Currency; currencyCodeColumn?: string; diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/test/PivotTableChart.test.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/test/PivotTableChart.test.tsx index 8715e3fd946f..c1709b5e35b5 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/test/PivotTableChart.test.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/test/PivotTableChart.test.tsx @@ -502,3 +502,61 @@ test.each([ expect(screen.getAllByText('m1').length).toBeGreaterThan(0); }, ); + +test.each( + [undefined, true, false].flatMap(hideEmptyColumns => + [false, true].map(combineMetric => ({ hideEmptyColumns, combineMetric })), + ), +)( + 'all-null metric columns use the compatibility default ($hideEmptyColumns, combine=$combineMetric)', + ({ hideEmptyColumns, combineMetric }) => { + const props = createProps({ + groupbyRows: ['year'], + groupbyColumns: ['product'], + metrics: ['limited', 'all'], + aggregateFunction: 'Sum', + combineMetric, + ...(hideEmptyColumns === undefined ? {} : { hideEmptyColumns }), + data: toQueryData( + [ + { year: '2024', product: 'A', limited: 10, all: 20 }, + { year: '2024', product: 'B', limited: null, all: 30 }, + { year: '2025', product: 'A', limited: 15, all: 25 }, + { year: '2025', product: 'B', limited: null, all: 35 }, + ], + { rows: ['year'], columns: ['product'] }, + ), + }); + const { container } = renderWithTheme(); + const productHeaders = Array.from( + container.querySelectorAll('th.pvtColLabel'), + ).map(node => node.textContent); + expect(productHeaders.filter(label => label === 'A')).toHaveLength( + combineMetric ? 1 : 2, + ); + expect(productHeaders.filter(label => label === 'B')).toHaveLength( + combineMetric || hideEmptyColumns !== false ? 1 : 2, + ); + expect(container.querySelectorAll('td.pvtVal')).toHaveLength( + hideEmptyColumns === false ? 8 : 6, + ); + }, +); + +test('zero-valued metric columns remain visible with the compatibility default', () => { + const props = createProps({ + groupbyRows: ['year'], + groupbyColumns: ['product'], + metrics: ['limited', 'all'], + data: toQueryData([{ year: '2024', product: 'B', limited: 0, all: 30 }], { + rows: ['year'], + columns: ['product'], + }), + }); + const { container } = renderWithTheme(); + const labels = Array.from(container.querySelectorAll('th.pvtColLabel')).map( + node => node.textContent, + ); + expect(labels.filter(label => label === 'B')).toHaveLength(2); + expect(screen.getByText('$ 0')).toBeInTheDocument(); +}); diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/transformProps.test.ts index 3ff87bd34d59..078e6e2e43a1 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/transformProps.test.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/transformProps.test.ts @@ -681,3 +681,17 @@ test('result aggregation wins over the additive fast path for an additive metric expect(result.data).toHaveLength(1); expect(result.data[0].data).toEqual(additiveResultProps.queriesData[0].data); }); + +test.each([undefined, true, false])( + 'hideEmptyColumns defaults on for saved charts (%s)', + value => { + const props = new ChartProps({ + ...chartProps, + formData: { + ...formData, + ...(value === undefined ? {} : { hideEmptyColumns: value }), + }, + }); + expect(transformProps(props).hideEmptyColumns).toBe(value !== false); + }, +); diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/test/react-pivottable/utilities.test.ts b/superset-frontend/plugins/plugin-chart-pivot-table/test/react-pivottable/utilities.test.ts index 65d29447deb7..b15642d131ea 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/test/react-pivottable/utilities.test.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/test/react-pivottable/utilities.test.ts @@ -1132,3 +1132,196 @@ test('Sum and Average stay blank (null) when every input in the scope is NULL', expect(run('Sum', [null, 4])).toBe(4); expect(run('Average', [null, 4])).toBe(4); }); + +test.each([undefined, 'Sum', 'Average'])( + 'hide empty metric columns without changing %s aggregates', + aggregateFunction => { + const data = ['2024', '2025'].flatMap(year => + ['A', 'B'].flatMap(product => [ + { + year, + product, + Metric: 'limited', + value: product === 'A' ? 10 : null, + __metricKey: 'Metric', + }, + { year, product, Metric: 'all', value: 20, __metricKey: 'Metric' }, + ]), + ); + const input = { + data, + rows: ['year'], + cols: ['Metric', 'product'], + vals: ['value'], + aggregateFunction, + }; + const shown = new PivotData(input); + const hidden = new PivotData({ ...input, hideEmptyColumns: true }); + expect(shown.getColKeys()).toHaveLength(4); + expect(hidden.getColKeys()).toEqual([ + ['all', 'A'], + ['all', 'B'], + ['limited', 'A'], + ]); + // Visibility must not remove records or mutate aggregators used by totals. + for (const row of [[], ...shown.getRowKeys()]) { + for (const column of [[], ...shown.getColKeys()]) { + expect(hidden.getAggregator(row, column).value()).toEqual( + shown.getAggregator(row, column).value(), + ); + } + } + expect(hidden.getAggregator(['2024'], ['limited', 'A']).value()).toBe(10); + }, +); + +test.each([0, -3, 5])('keep a column with the non-null value %s', value => { + const pivot = new PivotData({ + hideEmptyColumns: true, + rows: ['year'], + cols: ['product'], + vals: ['value'], + data: [ + { year: '2024', product: 'A', value: null }, + { year: '2025', product: 'A', value }, + ], + }); + expect(pivot.getColKeys()).toEqual([['A']]); +}); + +test('keep non-null database summaries and parents of populated columns', () => { + const pivot = new PivotData( + { + hideEmptyColumns: true, + rows: ['year'], + cols: ['Metric', 'product'], + vals: ['value'], + data: [ + { year: '2024', Metric: 'ratio', product: 'A', value: 0.5 }, + { + year: '2024', + Metric: 'ratio', + value: null, + __rows: ['year'], + __columns: ['Metric'], + }, + { year: '2024', Metric: 'ratio', product: 'B', value: null }, + { + Metric: 'ratio', + product: 'B', + value: 0, + __rows: [], + __columns: ['Metric', 'product'], + }, + ], + }, + { colEnabled: true }, + ); + expect(pivot.getColKeys()).toEqual( + expect.arrayContaining([['ratio'], ['ratio', 'A'], ['ratio', 'B']]), + ); + expect(pivot.getAggregator([], ['ratio', 'B']).value()).toBe(0); +}); + +test('hide empty columns when there are no row dimensions', () => { + const pivot = new PivotData({ + hideEmptyColumns: true, + rows: [], + cols: ['product'], + vals: ['value'], + data: [ + { product: 'empty', value: null }, + { product: 'zero', value: 0 }, + ], + }); + expect(pivot.getColKeys()).toEqual([['zero']]); +}); + +test.each(['Metric', 'Sum as Fraction of Total'])( + 'keep zero columns with undefined percentages (%s)', + aggregateFunction => { + const pivot = new PivotData({ + hideEmptyColumns: true, + rows: ['year'], + cols: ['Metric', 'product'], + vals: ['value'], + aggregateFunction, + showValuesAs: ShowValuesAsEnum.PERCENT_OF_TOTAL, + data: [ + { + year: '2024', + Metric: 'sales', + product: 'zero', + value: 0, + __metricKey: 'Metric', + }, + { + year: '2024', + Metric: 'sales', + product: 'empty', + value: null, + __metricKey: 'Metric', + }, + { + Metric: 'sales', + value: 0, + __rows: [], + __columns: ['Metric'], + __metricKey: 'Metric', + }, + ], + }); + expect(pivot.getColKeys()).toContainEqual(['sales', 'zero']); + expect(pivot.getColKeys()).not.toContainEqual(['sales', 'empty']); + expect(pivot.getAggregator(['2024'], ['sales', 'zero']).value()).toBeNull(); + }, +); + +test.each(['Metric', 'Sum as Fraction of Total'])( + 'hiding NULL columns preserves exact percentages (%s)', + aggregateFunction => { + const data = [ + { + year: '2024', + Metric: 'sales', + product: 'A', + value: 51, + __metricKey: 'Metric', + }, + { + year: '2024', + Metric: 'sales', + product: 'empty', + value: null, + __metricKey: 'Metric', + }, + { + year: '2025', + Metric: 'sales', + product: 'A', + value: 949, + __metricKey: 'Metric', + }, + { + Metric: 'sales', + value: 1000, + __rows: [], + __columns: ['Metric'], + __metricKey: 'Metric', + }, + ]; + const pivot = new PivotData({ + hideEmptyColumns: true, + data: aggregateFunction === 'Metric' ? data : data.slice(0, 3), + rows: ['year'], + cols: ['Metric', 'product'], + vals: ['value'], + aggregateFunction, + showValuesAs: ShowValuesAsEnum.PERCENT_OF_TOTAL, + }); + pivot.getColKeys(); + expect(pivot.getAggregator(['2024'], ['sales', 'A']).value()).toBeCloseTo( + 0.051, + ); + }, +); From 483e11527efa5c672cfbe76eb33158bfc3967cf2 Mon Sep 17 00:00:00 2001 From: Matt Fitzgerald Date: Thu, 19 Nov 2026 09:46:19 +1100 Subject: [PATCH 2/3] fix(i18n): add pivot empty-column control to catalogs --- superset/translations/ar/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/ca/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/cs/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/de/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/en/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/es/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/fa/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/fi/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/fr/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/it/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/ja/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/ko/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/lv/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/messages.pot | 8 +++++++- superset/translations/mi/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/nl/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/pl/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/pt/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/pt_BR/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/ro/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/ru/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/sk/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/sl/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/sr/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/sr_Latn/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/ta/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/th/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/tr/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/uk/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/zh/LC_MESSAGES/messages.po | 8 ++++++++ superset/translations/zh_TW/LC_MESSAGES/messages.po | 8 ++++++++ 31 files changed, 247 insertions(+), 1 deletion(-) diff --git a/superset/translations/ar/LC_MESSAGES/messages.po b/superset/translations/ar/LC_MESSAGES/messages.po index 15985c8ac28c..9d102583867f 100644 --- a/superset/translations/ar/LC_MESSAGES/messages.po +++ b/superset/translations/ar/LC_MESSAGES/messages.po @@ -10804,6 +10804,14 @@ msgstr "إخفاء الخط" msgid "Hide chart description" msgstr "إخفاء وصف المخطط" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "إخفاء الطبقة" diff --git a/superset/translations/ca/LC_MESSAGES/messages.po b/superset/translations/ca/LC_MESSAGES/messages.po index 9839a9311671..219c703a3182 100644 --- a/superset/translations/ca/LC_MESSAGES/messages.po +++ b/superset/translations/ca/LC_MESSAGES/messages.po @@ -10496,6 +10496,14 @@ msgstr "Amagar Línia" msgid "Hide chart description" msgstr "Amagar descripció del gràfic" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Amagar capa" diff --git a/superset/translations/cs/LC_MESSAGES/messages.po b/superset/translations/cs/LC_MESSAGES/messages.po index 9dd8a5b8a0c0..d351d7aa7a68 100644 --- a/superset/translations/cs/LC_MESSAGES/messages.po +++ b/superset/translations/cs/LC_MESSAGES/messages.po @@ -10098,6 +10098,14 @@ msgstr "Skrýt čáru" msgid "Hide chart description" msgstr "Skrýt popis grafu" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Skrýt vrstvu" diff --git a/superset/translations/de/LC_MESSAGES/messages.po b/superset/translations/de/LC_MESSAGES/messages.po index 95ebf26907ac..0208b1e25938 100644 --- a/superset/translations/de/LC_MESSAGES/messages.po +++ b/superset/translations/de/LC_MESSAGES/messages.po @@ -9262,6 +9262,14 @@ msgstr "Linie ausblenden" msgid "Hide chart description" msgstr "Diagrammbeschreibung ausblenden" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Ebene verstecken" diff --git a/superset/translations/en/LC_MESSAGES/messages.po b/superset/translations/en/LC_MESSAGES/messages.po index 4793f7901931..a28221698436 100644 --- a/superset/translations/en/LC_MESSAGES/messages.po +++ b/superset/translations/en/LC_MESSAGES/messages.po @@ -8214,6 +8214,14 @@ msgstr "" msgid "Hide chart description" msgstr "" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "" diff --git a/superset/translations/es/LC_MESSAGES/messages.po b/superset/translations/es/LC_MESSAGES/messages.po index b20d8eb4cc04..61e985daa375 100644 --- a/superset/translations/es/LC_MESSAGES/messages.po +++ b/superset/translations/es/LC_MESSAGES/messages.po @@ -10301,6 +10301,14 @@ msgstr "Ocultar línea" msgid "Hide chart description" msgstr "Ocultar descripción del gráfico" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Ocultar capa" diff --git a/superset/translations/fa/LC_MESSAGES/messages.po b/superset/translations/fa/LC_MESSAGES/messages.po index e4164e7db228..63cddf78663a 100644 --- a/superset/translations/fa/LC_MESSAGES/messages.po +++ b/superset/translations/fa/LC_MESSAGES/messages.po @@ -10483,6 +10483,14 @@ msgstr "خط را پنهان کن" msgid "Hide chart description" msgstr "توضیحات نمودار را پنهان کن" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "لایه را مخفی کنید" diff --git a/superset/translations/fi/LC_MESSAGES/messages.po b/superset/translations/fi/LC_MESSAGES/messages.po index e8633866eaf8..ec968d189f65 100644 --- a/superset/translations/fi/LC_MESSAGES/messages.po +++ b/superset/translations/fi/LC_MESSAGES/messages.po @@ -15405,6 +15405,14 @@ msgstr "Piilota viiva" msgid "Hide chart description" msgstr "Piilota kaavion kuvaus" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + # Machine-translated via backfill_po.py (claude-sonnet-4-6) [refs: ar, ca, cs, # de, es, fa, fr, ja, lv, mi, nl, pl, pt_BR, ru, sk, sl, uk, zh, zh_TW] #, fuzzy diff --git a/superset/translations/fr/LC_MESSAGES/messages.po b/superset/translations/fr/LC_MESSAGES/messages.po index 491edf8a30e9..64d25549a758 100644 --- a/superset/translations/fr/LC_MESSAGES/messages.po +++ b/superset/translations/fr/LC_MESSAGES/messages.po @@ -9985,6 +9985,14 @@ msgstr "Masquer la ligne" msgid "Hide chart description" msgstr "Masquer la description du graphique" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Masquer la couche" diff --git a/superset/translations/it/LC_MESSAGES/messages.po b/superset/translations/it/LC_MESSAGES/messages.po index 5c234cb879e7..0b89e93c5de4 100644 --- a/superset/translations/it/LC_MESSAGES/messages.po +++ b/superset/translations/it/LC_MESSAGES/messages.po @@ -11757,6 +11757,14 @@ msgstr "Nascondi linea" msgid "Hide chart description" msgstr "Nascondi la descrizione del grafico" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + # Machine-translated via backfill_po.py (claude-sonnet-4-6) [refs: ar, ca, cs, # de, es, fa, fr, ja, lv, mi, nl, pl, pt_BR, ro, ru, sk, sl, sr, sr_Latn, tr, # uk, zh, zh_TW] diff --git a/superset/translations/ja/LC_MESSAGES/messages.po b/superset/translations/ja/LC_MESSAGES/messages.po index 6a0d561f0f1d..b7313289ff58 100644 --- a/superset/translations/ja/LC_MESSAGES/messages.po +++ b/superset/translations/ja/LC_MESSAGES/messages.po @@ -8938,6 +8938,14 @@ msgstr "線を非表示" msgid "Hide chart description" msgstr "チャートの説明を非表示" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "レイヤーを非表示" diff --git a/superset/translations/ko/LC_MESSAGES/messages.po b/superset/translations/ko/LC_MESSAGES/messages.po index 3f5d93a30995..01ccbd41e1f4 100644 --- a/superset/translations/ko/LC_MESSAGES/messages.po +++ b/superset/translations/ko/LC_MESSAGES/messages.po @@ -13805,6 +13805,14 @@ msgstr "선 숨기기" msgid "Hide chart description" msgstr "설명" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + # Machine-translated via backfill_po.py (claude-sonnet-4-6) [refs: ar, ca, cs, # de, es, fa, fr, ja, lv, mi, nl, pl, pt_BR, ro, ru, sk, sl, sr, sr_Latn, tr, # uk, zh, zh_TW] diff --git a/superset/translations/lv/LC_MESSAGES/messages.po b/superset/translations/lv/LC_MESSAGES/messages.po index 99cecf313ce2..64cae5597156 100644 --- a/superset/translations/lv/LC_MESSAGES/messages.po +++ b/superset/translations/lv/LC_MESSAGES/messages.po @@ -9990,6 +9990,14 @@ msgstr "Slēpt līniju" msgid "Hide chart description" msgstr "Slēpt diagrammas aprakstu" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Slēpt slāni" diff --git a/superset/translations/messages.pot b/superset/translations/messages.pot index 3dbc44108092..c2e759988b21 100644 --- a/superset/translations/messages.pot +++ b/superset/translations/messages.pot @@ -25,7 +25,7 @@ msgid "" msgstr "" "Project-Id-Version: Superset VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2026-11-17 16:13-0700\n" +"POT-Creation-Date: 2026-11-19 09:45+1100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -7760,6 +7760,12 @@ msgstr "" msgid "Hide chart description" msgstr "" +msgid "Hide columns with only null metric values. Keep columns with zeros or non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "" diff --git a/superset/translations/mi/LC_MESSAGES/messages.po b/superset/translations/mi/LC_MESSAGES/messages.po index 47f2413500de..fa91ab7950b2 100644 --- a/superset/translations/mi/LC_MESSAGES/messages.po +++ b/superset/translations/mi/LC_MESSAGES/messages.po @@ -10411,6 +10411,14 @@ msgstr "Huna Rārangi" msgid "Hide chart description" msgstr "Huna whakamārama kauwhata" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Huna papa" diff --git a/superset/translations/nl/LC_MESSAGES/messages.po b/superset/translations/nl/LC_MESSAGES/messages.po index 94a9e3924f03..a9e1916fc397 100644 --- a/superset/translations/nl/LC_MESSAGES/messages.po +++ b/superset/translations/nl/LC_MESSAGES/messages.po @@ -10751,6 +10751,14 @@ msgstr "Lijn verbergen" msgid "Hide chart description" msgstr "Grafiek beschrijving verbergen" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Laag verbergen" diff --git a/superset/translations/pl/LC_MESSAGES/messages.po b/superset/translations/pl/LC_MESSAGES/messages.po index 2d8a5c0aeb46..eec05630ab8f 100644 --- a/superset/translations/pl/LC_MESSAGES/messages.po +++ b/superset/translations/pl/LC_MESSAGES/messages.po @@ -10919,6 +10919,14 @@ msgstr "Ukryj linię" msgid "Hide chart description" msgstr "Ukryj opis wykresu" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Ukryj warstwę" diff --git a/superset/translations/pt/LC_MESSAGES/messages.po b/superset/translations/pt/LC_MESSAGES/messages.po index 5b69cab87b21..e2cf1059be10 100644 --- a/superset/translations/pt/LC_MESSAGES/messages.po +++ b/superset/translations/pt/LC_MESSAGES/messages.po @@ -12174,6 +12174,14 @@ msgstr "Ocultar linha" msgid "Hide chart description" msgstr "Ocultar descrição do gráfico" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Esconder camada" diff --git a/superset/translations/pt_BR/LC_MESSAGES/messages.po b/superset/translations/pt_BR/LC_MESSAGES/messages.po index 11b078b43112..752e57def372 100644 --- a/superset/translations/pt_BR/LC_MESSAGES/messages.po +++ b/superset/translations/pt_BR/LC_MESSAGES/messages.po @@ -10573,6 +10573,14 @@ msgstr "Ocultar linha" msgid "Hide chart description" msgstr "Ocultar descrição do gráfico" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Esconder camada" diff --git a/superset/translations/ro/LC_MESSAGES/messages.po b/superset/translations/ro/LC_MESSAGES/messages.po index 81be8b4eef1a..cef4bc0d4acc 100644 --- a/superset/translations/ro/LC_MESSAGES/messages.po +++ b/superset/translations/ro/LC_MESSAGES/messages.po @@ -10532,6 +10532,14 @@ msgstr "Ascunde Linie" msgid "Hide chart description" msgstr "Ascunde descrierea graficului" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Ascunde strat" diff --git a/superset/translations/ru/LC_MESSAGES/messages.po b/superset/translations/ru/LC_MESSAGES/messages.po index f5720e5212c0..b36d17fef2a0 100644 --- a/superset/translations/ru/LC_MESSAGES/messages.po +++ b/superset/translations/ru/LC_MESSAGES/messages.po @@ -9802,6 +9802,14 @@ msgstr "Скрыть линию" msgid "Hide chart description" msgstr "Скрыть описание диаграммы" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Скрыть слой" diff --git a/superset/translations/sk/LC_MESSAGES/messages.po b/superset/translations/sk/LC_MESSAGES/messages.po index a0d5aa5d0432..b641cd0e64d0 100644 --- a/superset/translations/sk/LC_MESSAGES/messages.po +++ b/superset/translations/sk/LC_MESSAGES/messages.po @@ -10429,6 +10429,14 @@ msgstr "Skrýt čáru" msgid "Hide chart description" msgstr "Skrýt popis grafu" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Skrýt vrstvu" diff --git a/superset/translations/sl/LC_MESSAGES/messages.po b/superset/translations/sl/LC_MESSAGES/messages.po index ffa69cc52476..9f677c133903 100644 --- a/superset/translations/sl/LC_MESSAGES/messages.po +++ b/superset/translations/sl/LC_MESSAGES/messages.po @@ -9965,6 +9965,14 @@ msgstr "Skrij črto" msgid "Hide chart description" msgstr "Skrij opis grafikona" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Skrij sloj" diff --git a/superset/translations/sr/LC_MESSAGES/messages.po b/superset/translations/sr/LC_MESSAGES/messages.po index 61728ff205e2..ef0324af0c9e 100644 --- a/superset/translations/sr/LC_MESSAGES/messages.po +++ b/superset/translations/sr/LC_MESSAGES/messages.po @@ -11702,6 +11702,14 @@ msgstr "Сакриј линију" msgid "Hide chart description" msgstr "Сакриј опис графикона" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + # de, es, fa, fr, ja, lv, mi, nl, pl, pt_BR, ru, sk, sl, uk, zh, zh_TW] msgid "Hide layer" msgstr "Сакриј слој" diff --git a/superset/translations/sr_Latn/LC_MESSAGES/messages.po b/superset/translations/sr_Latn/LC_MESSAGES/messages.po index 4b97fe0a63e3..8ecf18669b2a 100644 --- a/superset/translations/sr_Latn/LC_MESSAGES/messages.po +++ b/superset/translations/sr_Latn/LC_MESSAGES/messages.po @@ -11714,6 +11714,14 @@ msgstr "Sakrij liniju" msgid "Hide chart description" msgstr "Sakrij opis grafikona" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + # de, es, fa, fr, ja, lv, mi, nl, pl, pt_BR, ru, sk, sl, uk, zh, zh_TW] msgid "Hide layer" msgstr "Sakrij sloj" diff --git a/superset/translations/ta/LC_MESSAGES/messages.po b/superset/translations/ta/LC_MESSAGES/messages.po index 6cd5f4dc0e08..79b8ae250c65 100644 --- a/superset/translations/ta/LC_MESSAGES/messages.po +++ b/superset/translations/ta/LC_MESSAGES/messages.po @@ -10041,6 +10041,14 @@ msgstr "கோட்டை மறை" msgid "Hide chart description" msgstr "சார்ட் விளக்கத்தை மறை" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "அடுக்கை மறை" diff --git a/superset/translations/th/LC_MESSAGES/messages.po b/superset/translations/th/LC_MESSAGES/messages.po index 849292dd44bc..700c082ed03b 100644 --- a/superset/translations/th/LC_MESSAGES/messages.po +++ b/superset/translations/th/LC_MESSAGES/messages.po @@ -15152,6 +15152,14 @@ msgstr "ซ่อนเส้น" msgid "Hide chart description" msgstr "ซ่อนคำอธิบายแผนภูมิ" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + # Machine-translated via backfill_po.py (claude-sonnet-4-6) [refs: ar, ca, cs, # de, es, fa, fr, ja, lv, mi, nl, pl, pt_BR, ru, sk, sl, uk, zh, zh_TW] #, fuzzy diff --git a/superset/translations/tr/LC_MESSAGES/messages.po b/superset/translations/tr/LC_MESSAGES/messages.po index c89d21f14311..14e30127dab3 100644 --- a/superset/translations/tr/LC_MESSAGES/messages.po +++ b/superset/translations/tr/LC_MESSAGES/messages.po @@ -10023,6 +10023,14 @@ msgstr "Hide Line" msgid "Hide chart description" msgstr "Gizle grafik açıklaması" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Gizle katmanı" diff --git a/superset/translations/uk/LC_MESSAGES/messages.po b/superset/translations/uk/LC_MESSAGES/messages.po index b1e39adb3b9f..0b3034f2db25 100644 --- a/superset/translations/uk/LC_MESSAGES/messages.po +++ b/superset/translations/uk/LC_MESSAGES/messages.po @@ -10005,6 +10005,14 @@ msgstr "Приховати лінію" msgid "Hide chart description" msgstr "Приховати опис діаграми" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "Приховати шар" diff --git a/superset/translations/zh/LC_MESSAGES/messages.po b/superset/translations/zh/LC_MESSAGES/messages.po index fb08d3d7d39b..d6133e7faf01 100644 --- a/superset/translations/zh/LC_MESSAGES/messages.po +++ b/superset/translations/zh/LC_MESSAGES/messages.po @@ -9740,6 +9740,14 @@ msgstr "隐藏线" msgid "Hide chart description" msgstr "隐藏图表说明" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "隐藏图层" diff --git a/superset/translations/zh_TW/LC_MESSAGES/messages.po b/superset/translations/zh_TW/LC_MESSAGES/messages.po index 3839038ba4ef..6f8582dabe02 100644 --- a/superset/translations/zh_TW/LC_MESSAGES/messages.po +++ b/superset/translations/zh_TW/LC_MESSAGES/messages.po @@ -10509,6 +10509,14 @@ msgstr "隐藏線" msgid "Hide chart description" msgstr "隐藏圖表說明" +msgid "" +"Hide columns with only null metric values. Keep columns with zeros or " +"non-empty summaries. This does not change totals or percentages." +msgstr "" + +msgid "Hide empty columns" +msgstr "" + msgid "Hide layer" msgstr "隐藏 Layer" From 642e06ea24733c5cb950dbb5d234592b694d3891 Mon Sep 17 00:00:00 2001 From: Matt Fitzgerald Date: Thu, 19 Nov 2026 09:49:20 +1100 Subject: [PATCH 3/3] fix(pivot-table): reset sorting when column visibility changes --- .../src/react-pivottable/TableRenderers.tsx | 2 + .../react-pivottable/tableRenders.test.tsx | 53 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx index b1667bfffdc5..de99992c223c 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx @@ -383,6 +383,7 @@ export function TableRenderer(props: TableRendererProps) { namesMapping: namesMappingProp, onContextMenu, allowRenderHtml, + hideEmptyColumns, } = props; const [collapsedRows, setCollapsedRows] = useState>( @@ -834,6 +835,7 @@ export function TableRenderer(props: TableRendererProps) { subtotalOptions, namesMappingProp, allowRenderHtml, + hideEmptyColumns, ]); // Use sorted row keys if available, otherwise use base row keys diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/test/react-pivottable/tableRenders.test.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/test/react-pivottable/tableRenders.test.tsx index e057fefb25ce..3f6ee5f3438e 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/test/react-pivottable/tableRenders.test.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/test/react-pivottable/tableRenders.test.tsx @@ -1742,3 +1742,56 @@ test('TableRenderer keeps each metric aggregation on its own formatter', () => { expect(grandTotalCells.length).toBe(1); expect(grandTotalCells[0]).toHaveTextContent('3.000 r'); }); + +test.each([ + { hideEmptyColumns: false, sortColumn: 'B' }, + { hideEmptyColumns: false, sortColumn: 'C' }, + { hideEmptyColumns: true, sortColumn: 'C' }, +])( + 'reset sorting when empty-column visibility changes ($hideEmptyColumns, $sortColumn)', + ({ hideEmptyColumns, sortColumn }) => { + const props = buildDefaultProps({ + rows: ['row'], + cols: ['column'], + vals: ['value'], + aggregateFunction: 'Sum', + data: ['first', 'second'].flatMap(row => [ + { row, column: 'A', value: 1 }, + { row, column: 'B', value: null }, + { row, column: 'C', value: row === 'first' ? 20 : 10 }, + ]), + }); + const { container, rerender } = renderWithTheme( + , + ); + const sort = (column: string) => { + const header = Array.from( + container.querySelectorAll('th.pvtColLabel'), + ).find(node => node.textContent === column)!; + fireEvent.click(header.querySelector('.anticon')!); + }; + const rowLabels = () => + Array.from(container.querySelectorAll('th.pvtRowLabel')).map( + node => node.textContent, + ); + sort(sortColumn); + expect( + screen.getByRole('button', { name: `Sorted by ${sortColumn} ascending` }), + ).toBeInTheDocument(); + if (sortColumn === 'C') expect(rowLabels()).toEqual(['second', 'first']); + rerender( + + + , + ); + expect( + screen.queryByRole('button', { name: /Sorted by/ }), + ).not.toBeInTheDocument(); + expect(rowLabels()).toEqual(['first', 'second']); + sort('C'); + expect( + screen.getByRole('button', { name: 'Sorted by C ascending' }), + ).toBeInTheDocument(); + expect(rowLabels()).toEqual(['second', 'first']); + }, +);