Skip to content

fix(pivot-table): hide all-null metric columns by default - #46340

Merged
fitzee merged 3 commits into
apache:masterfrom
fitzee:codex/pivot-empty-columns
Nov 18, 2026
Merged

fitzee merged 3 commits into
apache:masterfrom
fitzee:codex/pivot-empty-columns

Conversation

@fitzee

@fitzee fitzee commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

TL;DR

Restore compact Pivot Table displays by hiding all-NULL metric columns by default. Existing saved charts get this behavior without edits. Zeros stay visible, and totals and percentage calculations keep all their input data.

SUMMARY

The unpivot transformation now retains NULL records for database rollups. This also registers empty column keys, so conditional metrics can expand into many blank columns.

Filter display column keys after aggregation instead of removing input records. Keep a column when any cell or column summary has a non-NULL value, including zero. Keep parent headers of populated children. For percentage aggregators, check the underlying metric so a zero numerator does not disappear when its denominator is zero.

Add a Hide empty columns control, enabled by default. Missing saved settings also default to enabled; an explicit disabled setting is preserved. Queries, aggregators, total inputs, and percentage denominators are unchanged.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

No live application screenshots were captured. Rendered DOM regression tests cover both metric header layouts. In the test fixture, a conditional metric with values only for product A now has one column instead of A plus an empty B column. The second metric retains both products.

TESTING INSTRUCTIONS

Automated validation:

  • All 11 pivot suites pass: 228 tests.
  • Removing the display-key fix causes seven regression cases to fail; restoring it makes all tests pass.
  • Full frontend oxlint, changed-file oxfmt, custom rules, stylelint, and other applicable pre-commit checks pass. OXC tools ran from a separate install because the local shared dependencies lacked native bindings.
  • Type-check hook is blocked by missing project declaration outputs (TS6305). A source-based check without project references reports only two existing ResizePayload import errors in core MetadataBar and VirtualTable. No pivot errors were reported. Full type-check success is not claimed.

Manual checks:

  1. Open a saved Pivot Table with row and column dimensions and a conditional metric that returns NULL for some column values. Do not edit or resave it. Confirm all-NULL metric columns are hidden.
  2. Repeat with both metric header layouts. Change the conditional result to zero and confirm the column stays visible.
  3. Enable row/column totals and percentage displays. Confirm values match with Hide empty columns on and off, including database summaries and a zero denominator.
  4. Turn the control off, save, and reopen. Confirm empty columns remain visible.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

@fitzee fitzee self-assigned this Nov 18, 2026
@github-actions github-actions Bot added doc Namespace | Anything related to documentation plugins risk:chart-metadata labels Nov 18, 2026
@fitzee
fitzee marked this pull request as ready for review November 18, 2026 22:18
}
}
});
return this.colKeys.filter(key => visible.has(flatKey(key)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Filtering shifts surviving columns’ indices, but the renderer retains activeSortColumn and its sort direction. Hiding a column can leave the indicator missing or make the next click reset instead of toggle.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Stale reference

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/utilities.ts
**Line:** 1714:1714
**Comment:**
	*Stale Reference: Filtering shifts surviving columns’ indices, but the renderer retains `activeSortColumn` and its sort direction. Hiding a column can leave the indicator missing or make the next click reset instead of toggle.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟡  Medium Risk

  • The PR needs attention before merging.
  • Hiding columns changes their visible indices, but the sort state may retain an old index, leaving the sort indicator or next-click behavior incorrect.

Assessed commit: e68da0e03944

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.54%. Comparing base (4d66f03) to head (642e06e).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #46340       +/-   ##
===========================================
+ Coverage   65.21%   85.54%   +20.33%     
===========================================
  Files        3103     3104        +1     
  Lines      214085   214219      +134     
  Branches    50577    50607       +30     
===========================================
+ Hits       139610   183250    +43640     
+ Misses      71265    27541    -43724     
- Partials     3210     3428      +218     
Flag Coverage Δ
hive 34.00% <ø> (-0.02%) ⬇️
javascript 82.13% <100.00%> (+0.08%) ⬆️
mysql 51.64% <ø> (?)
postgres 51.68% <ø> (?)
presto 35.69% <ø> (-0.02%) ⬇️
python 88.23% <ø> (+36.69%) ⬆️
sqlite 51.35% <ø> (-0.04%) ⬇️
unit 83.44% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: the fix is right. Filtering display keys after aggregation leaves totals, percentages and denominators intact, and default-on brings back how the chart looked in every release through 6.1 (the empty columns came from #41184, which has only shipped in the 7.0 RCs). One thing blocks: Translations / babel-extract is red. Every other workflow on this head is green; the red frontend-tests-required and playwright-tests-required entries come from the cancelled draft run.

Both fixes are in files outside this PR's diff (messages.pot and TableRenderers.tsx), so I've attached them as patches on the nearest changed lines; they can't be one-click suggestions. Worth cherry-picking to 7.0 once merged.

onContextMenu={handleContextMenu}
allowRenderHtml={allowRenderHtml}
showValuesAs={showValuesAs}
hideEmptyColumns={hideEmptyColumns}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Toggling Hide empty columns leaves the sort indicator on the wrong column. activeSortColumn in TableRenderer is an index into the visible columns. The sort-reset useEffect (TableRenderers.tsx ~826-837) doesn't depend on hideEmptyColumns, and this is the only render-trigger control that changes the column set. Repro: columns A, B (all null), C with hiding off. Sort by B ("Sorted by B ascending"), then turn hiding on. The label moves to "Sorted by C ascending" while the rows stay in B's order. It happens the other way round too.

TableRenderers.tsx isn't in the diff, so here is the patch. With it, the repro passes and all pivot tests pass.

@@ TableRenderers.tsx ~383
     onContextMenu,
     allowRenderHtml,
+    hideEmptyColumns,
   } = props;
@@ TableRenderers.tsx ~836
     namesMappingProp,
     allowRenderHtml,
+    hideEmptyColumns,
   ]);

@github-actions github-actions Bot added i18n Namespace | Anything related to localization size/L i18n:spanish Translation related to Spanish language i18n:italian Translation related to Italian language i18n:french Translation related to French language i18n:chinese Translation related to Chinese language i18n:japanese Translation related to Japanese language i18n:german Translation related to German language i18n:russian Translation related to Russian language i18n:korean Translation related to Korean language i18n:dutch and removed size/XL labels Nov 18, 2026

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve: both round-1 findings are fixed. messages.pot now has the two strings and babel-extract passes. The sort reset is in place, and its new test fails without the fix. All 231 pivot tests pass locally. Thanks for the quick turnaround! One optional, non-blocking nit is inline.

Comment on lines +8217 to +8224
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 ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Optional nit, non-blocking: master's convention for new strings is to update only messages.pot, so the 31 .po additions aren't needed; the catalogs get refreshed when translations are synced. They're harmless, though: msgfmt -c reports the same results as on master. If you'd rather drop them, here's the change for this file, and the same applies to the other .po files.

Suggested change
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 ""

@fitzee
fitzee merged commit c13cf9c into apache:master Nov 18, 2026
87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Namespace | Anything related to documentation i18n:arabic i18n:brazilian i18n:catalan i18n:chinese Translation related to Chinese language i18n:czech i18n:dutch i18n:finnish i18n:french Translation related to French language i18n:german Translation related to German language i18n:italian Translation related to Italian language i18n:japanese Translation related to Japanese language i18n:korean Translation related to Korean language i18n:latvian i18n:maori i18n:persian i18n:polish i18n:portuguese i18n:romanian i18n:russian Translation related to Russian language i18n:serbian i18n:serbian-latin i18n:slovak i18n:slovenian i18n:spanish Translation related to Spanish language i18n:tamil i18n:thai i18n:traditional-chinese i18n:turkish i18n:ukrainian i18n Namespace | Anything related to localization plugins risk:chart-metadata size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants