Skip to content

Conversation

@Kamkoz93
Copy link

@Kamkoz93 Kamkoz93 commented Sep 29, 2025

SUMMARY

Cherry-pick of #20588 (follow-up to #20564) to restore correct value-based ordering in Pivot Table v2 when sorting across multiple row/column groups.

Commits included:

5598f02 — normalize value-based ordering for multiple rows/cols

faba485 — lint fix for utilities.js

Created new PR based on old not merged due to some CI issues.
Fixed messed up ordering when sort descending on mertics aplied.

###BEFORE SCREENSHOTS###
image

###AFTER SCREENSHOTS###
image

@dosubot dosubot bot added the viz:charts:pivot Related to the Pivot Table charts label Sep 29, 2025
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Performance Redundant dataFunc calls in nested loops ▹ view 🧠 Incorrect
Design Function has too many responsibilities ▹ view 🧠 Not in standard
Files scanned
File Path Reviewed
superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/utilities.js

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Comment on lines +150 to +163
for (let i = 0; i < keys.length; i += 1) {
const rk = keys[i];
let current = groups;
// we should not visit whole key ignore last key part (only groups)
for (let ki = 0; ki < rk.length - 1; ki += 1) {
const k = rk[ki];
if (!current[k]) {
//
current[k] = { auto_agg_sum: 0 };
}
current[k].auto_agg_sum += dataFunc(rk, []);
current = current[k];
}
}

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks good. But I'd break the groupingValueSort function into smaller functions for better code readability.

Comment on lines +147 to +163
const groupingValueSort = (keys, dataFunc, top, asc) => {
// precalculate subtotal for every group and subgroup
const groups = {};
for (let i = 0; i < keys.length; i += 1) {
const rk = keys[i];
let current = groups;
// we should not visit whole key ignore last key part (only groups)
for (let ki = 0; ki < rk.length - 1; ki += 1) {
const k = rk[ki];
if (!current[k]) {
//
current[k] = { auto_agg_sum: 0 };
}
current[k].auto_agg_sum += dataFunc(rk, []);
current = current[k];
}
}

This comment was marked as resolved.

@walec51
Copy link

walec51 commented Oct 20, 2025

@rusackas @justinpark @kgabryje is anything happening with this?

@mateusz-osko mateusz-osko force-pushed the pr-20588-refresh-pivot-table-sorting-fix2 branch from 1ec7e36 to 9dfbe7f Compare October 22, 2025 09:43
@mateusz-osko mateusz-osko force-pushed the pr-20588-refresh-pivot-table-sorting-fix2 branch from 9dfbe7f to 2cd07b1 Compare November 4, 2025 08:54
@rusackas rusackas requested a review from SBIN2010 November 4, 2025 22:05
@rusackas
Copy link
Member

rusackas commented Nov 4, 2025

Sorry it's been slow... we're all trying to catch up :D Running CI to see how that fares, for the moment, and adding our newest Committer (🎉) for a review.

@SBIN2010 SBIN2010 added the 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR label Nov 5, 2025
@github-actions github-actions bot added 🎪 2cd07b1 🚦 building Environment 2cd07b1 status: building 🎪 2cd07b1 📅 2025-11-05T04-17 Environment 2cd07b1 created at 2025-11-05T04-17 🎪 2cd07b1 ⌛ 48h Environment 2cd07b1 expires after 48h 🎪 2cd07b1 🤡 SBIN2010 Environment 2cd07b1 requested by SBIN2010 and removed 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR labels Nov 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

🎪 Showtime is building environment on GHA for 2cd07b1

@github-actions github-actions bot added 🎪 2cd07b1 🚦 deploying Environment 2cd07b1 status: deploying 🎪 2cd07b1 🚦 running Environment 2cd07b1 status: running 🎪 🎯 2cd07b1 Active environment pointer - 2cd07b1 is receiving traffic 🎪 2cd07b1 🌐 54.213.20.62:8080 Environment 2cd07b1 URL: http://54.213.20.62:8080 (click to visit) and removed 🎪 2cd07b1 🚦 building Environment 2cd07b1 status: building 🎪 2cd07b1 🚦 deploying Environment 2cd07b1 status: deploying 🎪 2cd07b1 🚦 running Environment 2cd07b1 status: running 🎪 🎯 2cd07b1 Active environment pointer - 2cd07b1 is receiving traffic labels Nov 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

🎪 Showtime deployed environment on GHA for 2cd07b1

Environment: http://54.213.20.62:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

@SBIN2010
Copy link
Contributor

SBIN2010 commented Nov 5, 2025

Works great.
I'd break the groupingValueSort function into smaller functions for better code readability and add tests.

@rusackas
Copy link
Member

rusackas commented Nov 6, 2025

@Kamkoz93 let us know if you can help address the above comnents, and we'll get this thing merged 🚀

@github-actions github-actions bot removed 🎪 2cd07b1 📅 2025-11-05T04-17 Environment 2cd07b1 created at 2025-11-05T04-17 🎪 2cd07b1 🚦 running Environment 2cd07b1 status: running 🎪 2cd07b1 🤡 SBIN2010 Environment 2cd07b1 requested by SBIN2010 🎪 2cd07b1 🌐 54.213.20.62:8080 Environment 2cd07b1 URL: http://54.213.20.62:8080 (click to visit) 🎪 2cd07b1 ⌛ 48h Environment 2cd07b1 expires after 48h labels Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugins size/L viz:charts:pivot Related to the Pivot Table charts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants