fix(partition): normalize ancestor-path array names to leaf values - #43731
Conversation
Code Review Agent Run #6caaccActionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
PartitionViz.nest_values / transformData return `name` as an array of the full ancestor path (e.g. ["a", "a.1", "a.1.1"]) for any node below the first grouping level, but Partition.ts's renderer never accounted for that -- every consumer (the sort comparator, tooltip cell, on-chart label, and categorical color key) treated `name` as a plain string, so JS silently stringified the array via Array.prototype.toString(), rendering the full comma-joined path instead of the node's own value. Normalize `name` to its own leaf value right where it's read from `data`, before any of those consumers run. Also widens the PartitionDataNode type and PropTypes declarations to reflect the real `string | string[]` contract. Fixes apache#43728 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
3854755 to
f2c8434
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #43731 +/- ##
=======================================
Coverage 79.24% 79.24%
=======================================
Files 2888 2888
Lines 166456 166458 +2
Branches 38532 38534 +2
=======================================
+ Hits 131913 131916 +3
+ Misses 32048 32047 -1
Partials 2495 2495
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:
|
Code Review Agent Run #539ca1Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
Fixes #43728.
PartitionViz.nest_values(andtransformData.ts's equivalent frontend re-implementation for the v1 chart data API) returnnameas an array of the full ancestor path (e.g.["a", "a.1", "a.1.1"]) for any node below the first grouping level, instead of a plain leaf string.Partition.ts's renderer was never updated to expect this, so every consumer ofnode.name-- the sort comparator, tooltip cell, on-chart segment label, and categorical color key -- treated it as a plain string. JS silently stringifies an array viaArray.prototype.toString()wherever it's interpolated into a template literal, so a 3rd-level segment rendered as e.g."a,a.1,a.1.1"instead of just"a.1.1".This fix normalizes
nameto its own leaf value right where it's read fromdata, before any of those consumers run -- a single-point fix. It also widens thePartitionDataNodetype and thePropTypesdeclarations to reflect the realstring | string[]contract, instead of leaving them declared (and asserted) asstringwhile actually receiving arrays.Verified against a real 4-dimension Partition chart with 12,907 nodes: 0 arrays remained after the fix, and every node's displayed name matched the correct leaf value from the original payload. See #43728 for the full analysis, screenshots, and repro SQL.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
See #43728 for before/after screenshots from a real Superset instance using the exact repro SQL below.
TESTING INSTRUCTIONS
Minimal repro (from #43728) -- register as a virtual dataset, build a Partition Chart with metric
SUM(val)and Levels =category,subcategory,sub_subcategory:Before this fix, the 3rd-level segments are labeled
A,A1,A1a/A,A1,A1b. After, they readA1a/A1b.ADDITIONAL INFORMATION