You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "innovark37 (via GitHub)" <gi...@apache.org> on 2026/06/14 12:46:05 UTC

[PR] fix(table): respect row limit with server pagination [superset]

innovark37 opened a new pull request, #41024:
URL: https://github.com/apache/superset/pull/41024

   ### SUMMARY
   Fixes Table chart server pagination so the main data query respects the configured row limit.
   
   When Table chart server pagination is enabled, Superset runs separate queries for the current page data and for the total row count. The row count query already uses the configured Row limit, but the current page data query used only the Server Page Length.
   
   This could make the table preview show more rows than the configured Row limit allows. The fix makes the current page data query cap its page size by the remaining rows within the Row limit.
   
   For example:
   - `row_limit = 120`, `server_page_length = 50` showed 3 pages, but the last page could request 50 rows instead of the remaining 20.
   - `row_limit = 10`, `server_page_length = 20` could display 20 rows in preview even though the chart row limit was 10.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   1. Create or edit a Table chart.
   2. Enable Server pagination.
   3. Set Server Page Length to `50`.
   4. Manually set Row limit to `120`.
   5. Run the query and verify the table preview shows 3 pages, with the last page containing at most 20 rows.
   6. Set Row limit to `10` and Server Page Length to `20`.
   7. Run the query and verify the table preview shows at most 10 rows.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4701787200

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4775353728

   ### <span aria-hidden="true">โœ…</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">๐Ÿ”จ</span> Latest commit | 67ce748919fafc93f2a9f8d79845034161b34256 |
   |<span aria-hidden="true">๐Ÿ”</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a39fe7f251ebc0007aa1de6 |
   |<span aria-hidden="true">๐Ÿ˜Ž</span> Deploy Preview | [https://deploy-preview-41024--superset-docs-preview.netlify.app](https://deploy-preview-41024--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">๐Ÿ“ฑ</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQxMDI0LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.01qKCkgVO_cHyI-InAIjHOLT3JiW_2jWhGYNxwR3SCg)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">๐Ÿค–</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DctRDoIwDADQu_TbhSERgjfwGB3rtGG0S10AY7y7-3s_7wvFdCsV7gAXCIayvJpZRHe0tUt8dhVDJvcm28lcwScLVlZxpofLvHFtM1LJ-nnEdkcc5kRTut56Cov3fkLsI43w-wM) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-41024--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41024:
URL: https://github.com/apache/superset/pull/41024#discussion_r3409561217


##########
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts:
##########
@@ -229,11 +229,17 @@ const buildQuery: BuildQuery<TableChartFormData> = (
     }
 
     if (!isDownloadQuery && formDataCopy.server_pagination) {
-      const pageSize = ownState.pageSize ?? formDataCopy.server_page_length;
-      const currentPage = ownState.currentPage ?? 0;
-
-      moreProps.row_limit = pageSize;
-      moreProps.row_offset = currentPage * pageSize;
+      const pageSize =
+        Number(ownState.pageSize ?? formDataCopy.server_page_length) || 0;
+      const currentPage = Number(ownState.currentPage) || 0;
+      const rowOffset = currentPage * pageSize;
+      const rowLimit = Number(formDataCopy.row_limit) || 0;
+      const remainingRows =
+        rowLimit > 0 ? Math.max(rowLimit - rowOffset, 0) : pageSize;
+
+      moreProps.row_limit =
+        rowLimit > 0 ? Math.min(pageSize, remainingRows) : pageSize;

Review Comment:
   **Suggestion:** When `rowOffset` exceeds `row_limit`, `remainingRows` becomes `0` and the new logic assigns `moreProps.row_limit = 0`. In Superset query objects, `row_limit: 0` means "no limit", not "return zero rows", so this can accidentally remove the cap and return rows beyond the configured row limit. Clamp the page/offset to a valid range or handle the zero-remaining case without emitting an unlimited `row_limit`. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major โš ๏ธ</summary>
   
   ```mdx
   - โŒ Table server pagination can bypass configured row limit cap.
   - โš ๏ธ Extra rows increase query load and confuse chart users.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction โœ… </b></summary>
   
   ```mdx
   1. Render a Table chart with server pagination enabled so form data includes
   `server_pagination: true` and `server_page_length`, as wired in
   `superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx:383-405`. The chart is
   rendered by `TableChart.tsx` which passes `serverPaginationData` (taken from
   `chartProps.ownState`, see `transformProps.ts:499` and `transformProps.ts:778-790`) into
   the `DataTable` component.
   
   2. Navigate to a later page using the server-side pagination controls. Clicking a page in
   the pagination UI calls `onServerPaginationChange`, which in Table charts is implemented
   by `handleServerPaginationChange` in `TableChart.tsx:1458-1466` to update
   `ownState.currentPage` and `ownState.pageSize` via `updateTableOwnState`. The next query
   run uses this persisted `ownState` as `options.ownState` when `buildQuery` in
   `buildQuery.ts` is invoked.
   
   3. While on a later page, lower the chart Row limit to a value smaller than the current
   offset (e.g. previously `row_limit = 1000`, `server_page_length = 50`, `currentPage = 4`,
   then change `row_limit` to `10` and rerun). There is no code that resets `currentPage` on
   row-limit changes: `cachedBuildQuery` in `buildQuery.ts:267-279` only resets
   `row_offset`/`currentPage` when filters change, and `TableChart.tsx` only resets
   `currentPage` on server page length changes (`useEffect` at `TableChart.tsx:31-38`) or
   search changes (`handleSearch` at `TableChart.tsx:74-80`). Thus
   `options.ownState.currentPage` can remain > new last page when the new query is built.
   
   4. On the next data load, `buildQuery` computes the main page query with the stale
   `currentPage`. In `buildQuery.ts:231-243`, it derives `pageSize` and `rowOffset` from
   `ownState` and server page length, then calculates:
   
      - `rowOffset = currentPage * pageSize`
   
      - `rowLimit = Number(formDataCopy.row_limit) || 0`
   
      - `const remainingRows = rowLimit > 0 ? Math.max(rowLimit - rowOffset, 0) : pageSize;`
      (line 237)
   
      - `moreProps.row_limit = rowLimit > 0 ? Math.min(pageSize, remainingRows) : pageSize;`
      (line 241)
   
      When `rowOffset >= rowLimit` (e.g. `row_limit = 10`, `pageSize = 50`, `currentPage =
      2`, so `rowOffset = 100`), `remainingRows` becomes `0`, and `moreProps.row_limit` is
      set to `0`. In Superset query objects a `row_limit` of `0` is used as "no limit" / "all
      records" (see the same file's extra queries with `row_limit: 0` at
      `buildQuery.ts:113-120` and the test expectation in
      `plugins/plugin-chart-table/test/buildQuery.test.ts:18-26` for
      `percent_metric_calculation: 'all_records'`). Thus this path emits a main data query
      with `row_offset > 0` and `row_limit = 0`, effectively removing the chart row limit cap
      for that request and allowing more than the configured `row_limit` rows to be returned.
   ```
   </details>
   
   [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=98ce334a12f546aa82345bb46b979d7a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=98ce334a12f546aa82345bb46b979d7a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts
   **Line:** 237:241
   **Comment:**
   	*Logic Error: When `rowOffset` exceeds `row_limit`, `remainingRows` becomes `0` and the new logic assigns `moreProps.row_limit = 0`. In Superset query objects, `row_limit: 0` means "no limit", not "return zero rows", so this can accidentally remove the cap and return rows beyond the configured row limit. Clamp the page/offset to a valid range or handle the zero-remaining case without emitting an unlimited `row_limit`.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41024&comment_hash=7a1b81832892b4c59fbecb4d3b758fb0ee6cf70beac1a36d733157f0c4b9a403&reaction=like'>๐Ÿ‘</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41024&comment_hash=7a1b81832892b4c59fbecb4d3b758fb0ee6cf70beac1a36d733157f0c4b9a403&reaction=dislike'>๐Ÿ‘Ž</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41024:
URL: https://github.com/apache/superset/pull/41024#discussion_r3409558463


##########
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts:
##########
@@ -229,11 +229,17 @@ const buildQuery: BuildQuery<TableChartFormData> = (
     }
 
     if (!isDownloadQuery && formDataCopy.server_pagination) {
-      const pageSize = ownState.pageSize ?? formDataCopy.server_page_length;
-      const currentPage = ownState.currentPage ?? 0;
-
-      moreProps.row_limit = pageSize;
-      moreProps.row_offset = currentPage * pageSize;
+      const pageSize =
+        Number(ownState.pageSize ?? formDataCopy.server_page_length) || 0;
+      const currentPage = Number(ownState.currentPage) || 0;
+      const rowOffset = currentPage * pageSize;
+      const rowLimit = Number(formDataCopy.row_limit) || 0;
+      const remainingRows =
+        rowLimit > 0 ? Math.max(rowLimit - rowOffset, 0) : pageSize;
+
+      moreProps.row_limit =

Review Comment:
   **๐ŸŸ  Architect Review โ€” HIGH**
   
   When server pagination is enabled, the filter-change reset block persists the dynamic, last-page-capped `queryObject.row_limit` into `ownState.pageSize`, so if an external filter changes while the user is on the final page, the server pagination page size silently shrinks to the remainder instead of staying at the user-selected/server_page_length value.
   
   **Suggestion:** Decouple "selected page size" from the per-request `row_limit`: on filter-change reset, set `pageSize` back to the configured server page length or the existing `ownState.pageSize`, and only apply the remaining-rows cap to `queryObject.row_limit` when building the query so that `ownState.pageSize` is never overwritten with a remainder-sized value.
   
   
   [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=963e1be5bbfb45079054f37bea91f450&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=963e1be5bbfb45079054f37bea91f450&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings โ€” not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood.
   
   **Path:** superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts
   **Line:** 240:276
   **Comment:**
   	*HIGH: When server pagination is enabled, the filter-change reset block persists the dynamic, last-page-capped `queryObject.row_limit` into `ownState.pageSize`, so if an external filter changes while the user is on the final page, the server pagination page size silently shrinks to the remainder instead of staying at the user-selected/server_page_length value.
   
   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.
   If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix โ€” do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding.
   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
   ```
   </details>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4720605112

   <div>
   <h3>Code Review Agent Run #e0ff53</h3>
   
   <div>
   <details>
   <summary>
   <b>Actionable Suggestions -  0</b>
   </summary>
   
   </details>
   </div>
   
   
   
   
   
   
   
   
   
   
   
   <div>
   <details>
   <summary>
   <b>Review Details</b>
   </summary>
   
   <ul>
   <li>
   <div id="file_reviewed">
   Files reviewed - <b>1</b> ยท Commit Range: <code>f64b1ae..139904f</code>
   <ul>
   <li>superset-frontend/plugins/plugin-chart-table/test/buildQuery.test.ts</li>
   </ul>
   </div>
   </li>
   
   <li>
   <div id="file_skipped">
   Files skipped - <b>0</b>
   <ul>
         
   </ul>
   </div>
   </li>
   
   
   <li>
   <div id="tools">
   Tools
   <ul>
         <li><b>Eslint</b> (Linter) - โœ”๏ธŽ Successful</li><li><b>Whispers</b> (Secret Scanner) - โœ”๏ธŽ Successful</li><li><b>Detect-secrets</b> (Secret Scanner) - โœ”๏ธŽ Successful</li>
   </ul>
   </div>
   </li>
   
   </ul>
   </details>
   </div>
   
   <hr>
   
   
   <details>
   <summary>
   <b>Bito Usage Guide</b>
   </summary>
         
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   </details>
   
   
   
   
   <span><i>AI Code Review powered by</i> <sub><sub><a href="https://bito.ai/" target="_blank"><img src="https://bito.ai/wp-content/uploads/2023/10/Logo-Bito-Black-cropped.svg" alt="Bito Logo" width="50" height="20" /></a></sub></sub></span>
   
   
   </div>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4775793430

   Now that this has my fingerprints all over it, let me know your thoughts, I don't want to just randomly merge my own work. Adding @sadpandajoe for another pair of eyes here. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #41024:
URL: https://github.com/apache/superset/pull/41024


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #41024:
URL: https://github.com/apache/superset/pull/41024#discussion_r3457582839


##########
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts:
##########
@@ -54,7 +54,7 @@ export function getQueryMode(formData: TableChartFormData) {
   return hasRawColumns ? QueryMode.Raw : QueryMode.Aggregate;
 }
 
-const buildQuery: BuildQuery<TableChartFormData> = (
+export const buildQuery: BuildQuery<TableChartFormData> = (

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Large duplicated code block (204 tokens)</b></div>
   <div id="fix">
   
   Code duplication detected: 31 lines of buildQuery implementation are duplicated between plugin-chart-table/src/buildQuery.ts (lines 57-87) and plugin-chart-ag-grid-table/src/buildQuery.ts (lines 61-91). Additional similar duplications exist at lines 182-221, 230-244, and 278-290 in plugin-chart-table and corresponding lines in plugin-chart-ag-grid-table. Consider extracting the common buildQuery logic into a shared utility module.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #f34659</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts:
##########
@@ -217,6 +217,17 @@ const buildQuery: BuildQuery<TableChartFormData> = (
 
     const moreProps: Partial<QueryObject> = {};
     const ownState = options?.ownState ?? {};
+    // Server pagination sizing, shared between the per-page request below and
+    // the filter-change reset further down.
+    const pageSize =
+      Number(ownState.pageSize ?? formDataCopy.server_page_length) || 0;
+    const configuredRowLimit = Number(formDataCopy.row_limit) || 0;
+    // row_limit for the first page, capped by the configured row limit. Used
+    // when a filter change resets pagination back to page 0.
+    const firstPageRowLimit =
+      configuredRowLimit > 0
+        ? Math.min(pageSize, configuredRowLimit)
+        : pageSize;

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Small duplicated code block (72 tokens)</b></div>
   <div id="fix">
   
   Duplicate code identified: 15 lines of ownState handling and isDownloadQuery detection logic duplicated between plugin-chart-table/src/buildQuery.ts (lines 230-244) and plugin-chart-ag-grid-table/src/buildQuery.ts (lines 205-219). This is part of a larger pattern of duplication in these buildQuery implementations.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #f34659</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4776411815

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4701798958

   <!-- Bito Reply -->
   The flagged issue is correct. The current implementation in the diff incorrectly calculates `moreProps.row_limit` using `Math.min(pageSize, remainingRows)`, which effectively overwrites the intended page size with a smaller value when the user is on the final page. To resolve this, you should decouple the `pageSize` used for pagination from the `row_limit` applied to the query. 
   
   Here is the corrected implementation:
   
   ```typescript
         const pageSize = Number(ownState.pageSize ?? formDataCopy.server_page_length) || 0;
         const currentPage = Number(ownState.currentPage) || 0;
         const rowOffset = currentPage * pageSize;
         const rowLimit = Number(formDataCopy.row_limit) || 0;
   
         moreProps.row_limit = rowLimit > 0 ? Math.min(pageSize, Math.max(rowLimit - rowOffset, 0)) : pageSize;
         moreProps.row_offset = rowOffset;
   ```
   
   This ensures `moreProps.row_limit` is capped by the remaining rows without modifying the `pageSize` state itself. There are no other comments on this PR to address.
   
   **superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts**
   ```
   const pageSize = Number(ownState.pageSize ?? formDataCopy.server_page_length) || 0;
         const currentPage = Number(ownState.currentPage) || 0;
         const rowOffset = currentPage * pageSize;
         const rowLimit = Number(formDataCopy.row_limit) || 0;
   
         moreProps.row_limit = rowLimit > 0 ? Math.min(pageSize, Math.max(rowLimit - rowOffset, 0)) : pageSize;
         moreProps.row_offset = rowOffset;
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4775341214

   Thanks @innovark37! Circled back because the codeant bot flagged a couple things, and it was actually right on both this time.
   
   When the requested page sits past the configured row limit, `remainingRows` hits 0 and `row_limit` collapses to 0, which the backend reads as "no limit" (`if row_limit:` in `helpers.py`), so it'd quietly return the whole table instead of capping. And the filter-reset block was persisting that capped per-request limit into `pageSize`, so changing a filter on the last page silently shrank the page size.
   
   I pushed a fix to clamp the page to the last one inside the limit and persist the user-selected page size instead, plus a test for the row_limit:0 case. Left the rest of your logic intact. Should be good once CI's green, but holler if you'd rather take a different tack on the clamp.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4782636473

   @aminghadersohi is OOO right now, so I'll just merge this, and we can fix/revert if anything else needs digging into here. Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4775494960

   Yeah, the bot caught a third real one, same root cause: on a filter reset we zeroed the offset but kept the last page's capped `row_limit`, so the first page after a filter change came back short. Fixed it to restore the full first-page limit.
   
   Rather than keep whacking these one at a time, I exported `buildQuery` and added tests across the whole matrix, user limit under the page size, capped last page, paging past the limit (no more row_limit:0), the first-page restore plus page-size persistence on reset, and the no-row-limit fallback. That should have the row-limit/pagination interactions pinned down now. Green locally, holler if you spot a case I missed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4781726609

   I think the CodeAnt logic comments here are already handled by your last couple commits (the `lastPage` clamp and recomputing `firstPageRowLimit` on reset). The bot also flagged the `buildQuery` duplication with `plugin-chart-ag-grid-table`, which turns out to have the exact same row-limit bug, so I ported your fix over there in #41346. LGTM!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41024:
URL: https://github.com/apache/superset/pull/41024#discussion_r3456854734


##########
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts:
##########
@@ -229,11 +229,26 @@ const buildQuery: BuildQuery<TableChartFormData> = (
     }
 
     if (!isDownloadQuery && formDataCopy.server_pagination) {
-      const pageSize = ownState.pageSize ?? formDataCopy.server_page_length;
-      const currentPage = ownState.currentPage ?? 0;
-
-      moreProps.row_limit = pageSize;
-      moreProps.row_offset = currentPage * pageSize;
+      const pageSize =
+        Number(ownState.pageSize ?? formDataCopy.server_page_length) || 0;
+      const rowLimit = Number(formDataCopy.row_limit) || 0;
+
+      // Never page past the configured row limit. Clamping the page to the last
+      // one that still falls within the limit keeps the request inside the cap
+      // and avoids emitting row_limit: 0, which the backend treats as
+      // "no limit" rather than "no rows" (see helpers.py get_sqla_query).
+      const lastPage =
+        rowLimit > 0 && pageSize > 0
+          ? Math.max(Math.ceil(rowLimit / pageSize) - 1, 0)
+          : Number(ownState.currentPage) || 0;
+      const currentPage = Math.min(Number(ownState.currentPage) || 0, lastPage);
+      const rowOffset = currentPage * pageSize;
+      const remainingRows =
+        rowLimit > 0 ? Math.max(rowLimit - rowOffset, 0) : pageSize;
+
+      moreProps.row_limit =
+        rowLimit > 0 ? Math.min(pageSize, remainingRows) : pageSize;
+      moreProps.row_offset = rowOffset;

Review Comment:
   **Suggestion:** `row_limit` is now page-dependent, but when cached filters change the code only resets `row_offset` to 0 and does not recompute `row_limit`. If the user was on a capped last page (for example `row_limit=120`, `pageSize=50`, page 3 -> `row_limit=20`), the reset query for page 1 will still request only 20 rows instead of 50. Recompute `row_limit` after forcing offset/page reset (or rebuild pagination props using page 0) so first-page fetch size is correct after filter changes. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major โš ๏ธ</summary>
   
   ```mdx
   - โš ๏ธ First page after filter changes returns fewer rows.
   - โš ๏ธ Table chart server pagination inconsistent with configured page size.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction โœ… </b></summary>
   
   ```mdx
   1. Open or create a Table chart that uses the Table plugin (registered in
   `superset-frontend/plugins/plugin-chart-table/src/index.ts:19-61`) and enable server
   pagination in the control panel (`server_pagination` and `server_page_length` controls in
   `src/controlPanel.tsx:383-407`).
   
   2. Configure a `row_limit` that is not a multiple of the server page length, for example
   `row_limit = 120` and `server_page_length = 50`. Load data and navigate to the last server
   page via the table pagination UI, which updates `ownState.currentPage` through
   `handleServerPaginationChange` in `src/TableChart.tsx:24-32` by calling
   `updateTableOwnState` with `currentPage` set to the selected page.
   
   3. With the chart currently on that last page (so the previous request used `row_offset =
   100` and a capped `row_limit = 20` computed in `buildQuery` at
   `src/buildQuery.ts:231-251`), change an external filter (e.g., a dashboard filter or
   cross-filter) so that `queryObject.filters` differs from the cached filters stored via
   `setCachedChanges` (`src/buildQuery.ts:51-54` and the closure in `cachedBuildQuery` at
   `src/buildQuery.ts:124-141`).
   
   4. When the new request is built, `buildQuery` recomputes `moreProps` using the stale
   `ownState.currentPage` (still pointing at the last page) and sets `moreProps.row_limit =
   20` and `moreProps.row_offset = 100` (`src/buildQuery.ts:241-251`). The subsequent
   filter-change block (`src/buildQuery.ts:96-103`) only overrides `row_offset` back to `0`
   and does not recompute `row_limit`, so the first-page query after the filter change is
   sent with `row_limit = 20` instead of the expected full page size `50`, yielding an
   incorrectly short first page.
   ```
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a655ef05d2394d07996ff2040469c414&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=a655ef05d2394d07996ff2040469c414&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts
   **Line:** 246:251
   **Comment:**
   	*Logic Error: `row_limit` is now page-dependent, but when cached filters change the code only resets `row_offset` to 0 and does not recompute `row_limit`. If the user was on a capped last page (for example `row_limit=120`, `pageSize=50`, page 3 -> `row_limit=20`), the reset query for page 1 will still request only 20 rows instead of 50. Recompute `row_limit` after forcing offset/page reset (or rebuild pagination props using page 0) so first-page fetch size is correct after filter changes.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41024&comment_hash=d755a7f95e02d3931c0d812ee6643cc3aa3d11cedb1563560175b8213444565a&reaction=like'>๐Ÿ‘</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41024&comment_hash=d755a7f95e02d3931c0d812ee6643cc3aa3d11cedb1563560175b8213444565a&reaction=dislike'>๐Ÿ‘Ž</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(table): respect row limit with server pagination [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #41024:
URL: https://github.com/apache/superset/pull/41024#issuecomment-4701812802

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/41024?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 64.26%. Comparing base ([`99bdacd`](https://app.codecov.io/gh/apache/superset/commit/99bdacd2e1da3e17ede602941cba0bdcc7bac998?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f64b1ae`](https://app.codecov.io/gh/apache/superset/commit/f64b1ae0e038a96cfc8d145d9e7e79f1b6273c9d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 2 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #41024   +/-   ##
   =======================================
     Coverage   64.26%   64.26%           
   =======================================
     Files        2660     2660           
     Lines      144586   144590    +4     
     Branches    33338    33341    +3     
   =======================================
   + Hits        92922    92926    +4     
     Misses      50026    50026           
     Partials     1638     1638           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/41024/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage ฮ” | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/41024/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `68.30% <100.00%> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/41024?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org