Repository navigation
fix(pivot-table): hide all-null metric columns by default - #46340
Conversation
| } | ||
| } | ||
| }); | ||
| return this.colKeys.filter(key => visible.has(flatKey(key))); |
There was a problem hiding this comment.
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
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
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rebenitez1802
left a comment
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
🟡 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,
]);
rebenitez1802
left a comment
There was a problem hiding this comment.
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.
| 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 "" | ||
|
|
There was a problem hiding this comment.
🟢 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.
| 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 "" |
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:
ResizePayloadimport errors in core MetadataBar and VirtualTable. No pivot errors were reported. Full type-check success is not claimed.Manual checks:
ADDITIONAL INFORMATION