-
Notifications
You must be signed in to change notification settings - Fork 159
feat: add pivot row limit #8492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I have created a proper Notion PRD here: |
|
When navigating from Pivot -> Explore -> Pivot we lose the limit setting |
|
several issues with expanded rows and limits:
|
|
It seems export is broken, it does no longer sort on the measure |
|
totals are not respecting limits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shared Constants for Row Limit Options
The allowed row limit values are defined in two places:
PivotToolbar.svelte(UI options):[5, 10, 25, 50, 100, "all"]convertURLToExplorePreset.ts(URL validation):[5, 10, 25, 50, 100]
If these drift out of sync, users could set a limit via the UI that gets rejected when loaded from a URL. Consider extracting these to a shared constant, perhaps in types.ts or a new pivot-constants.ts file.
Extract Limit Calculation Logic
The new limit calculation in pivot-data-store.ts:298-315 is correct, but it's added to an already deeply nested section of createPivotDataStore. This makes the code harder to follow. Consider extracting this into a helper function, along these lines:
function calculateEffectiveRowLimit(
rowLimit: number | undefined,
rowOffset: number,
pageSize: number,
): string {
if (rowLimit === undefined) {
return pageSize.toString();
}
const remainingRows = rowLimit - rowOffset;
if (remainingRows <= 0) {
return "0";
}
return Math.min(remainingRows, pageSize).toString();
}This will make the intent clearer and keep the main function from growing further. More broadly, createPivotDataStore has become difficult to maintain due to its size and nesting depth. We should revisit this in the future to improve readability.
Expanded Row Limit Behavior
In pivot-expansion.ts:284-287:
const expandLimitToApply =
config.pivot.rowLimit !== undefined
? config.pivot.rowLimit.toString()
: "100";When "All" is selected, expanded sections still cap at 100 rows. This might surprise users who expect "All" to mean unlimited everywhere. If this is intentional, it would be worth documenting. If not, consider whether expanded rows should also be unlimited when rowLimit is undefined.
Test Coverage Required
Before merging, please add test coverage for:
- URL round-trip: setting a limit produces the correct
row_limitparam, and loading that URL restores the correct state - Edge cases in
convertURLToExplorePreset.ts: invalid values, out-of-range numbers, non-numeric strings
Developed in collaboration with Claude Code
|
@AdityaHegde, I've tagged you as a reviewer as well– can you please review the state management code? |
AdityaHegde
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intention to limit the top level dimension as well? Currently even that is limited (based on the query sent)
web-common/src/features/dashboards/url-state/convert-partial-explore-state-to-url-params.ts
Outdated
Show resolved
Hide resolved
| const expandLimitToApply = | ||
| config.pivot.rowLimit !== undefined | ||
| ? config.pivot.rowLimit.toString() | ||
| : "100"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this limit should stay along with PIVOT_ROW_LIMIT_OPTIONS.
Also the hardcoded limit of 100 is already in PIVOT_ROW_LIMIT_OPTIONS. Since all and 100 are the same we should get rid of 100 option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a See more button based on product's recommendation. The max limit is still capped to 100.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, though see below for a few observations on complexity
|
A few observations on complexity for future reference (not blocking): Magic Number
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels weird to look at top level dimensions with limit applying to them as well. Do we need "Load more" button there as well? Also lets update the PRD to make sure everyone is on the same page (it still states the limit is only for nested dimensions). cc @nishantmonu51 @mindspank
Also Increase limit to <new limit> on <dimension> feels a bit too verbose. How about just load more or load more for <dimension>?
* Initial implementation for pivot row limit * Fix pivit config key to include row limit * review fixes * remove limit on col dimensions * fix pagination * remove limit on derived table cell data * update key copy * remove redundant limit from measure totals query * adjust row limit label padding * collapse all when limit is changed * review * add increase limit option under nested dimensions * use common props for pivot cells * show more copy update * review updates * gray out show more row --------- Co-authored-by: Dhiraj Kumar <[email protected]>
Notion PRD here. The Notion PRD should serve as the source of truth for this feature.
https://www.notion.so/rilldata/Pivot-row-limit-for-nested-dimensions-2c7ba33c8f5780ff8ddfdd9fd94cfeda?source=copy_link
Add row limit control to pivot tables
This PR adds a configurable row limit feature to pivot tables, allowing users to control how many child rows are displayed under each dimension.
Changes
UI Components:
State Management:
rowLimit?: numberfield toPivotState(undefined = unlimited)setPivotRowLimitreducer that resets pagination, expanded state, and active cell when limit changesrow_limitparameterData Queries:
Checklist: