codeant-ai-for-open-source[bot] commented on code in PR #40907:
URL: https://github.com/apache/superset/pull/40907#discussion_r3963636679
##########
superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx:
##########
@@ -74,6 +76,13 @@ export const useResultsPane = ({
const chartRowLimit = Number(queryFormData?.row_limit) || 10000;
const [rowLimit, setRowLimit] = useState(1000);
+ const [orderby, setOrderby] = useState<[string, boolean][]>([]);
+ // Server-side sort is only valid when the displayed columns map directly to
+ // the SQL result. When the query has post-processing (e.g.
pivot/cum/rolling),
+ // `orderby` + `row_limit` are applied to the raw SQL *before*
post-processing,
+ // which changes the rows that feed those operations and corrupts the result.
+ // In that case we fall back to client-side sorting of what the chart
produced.
+ const [hasPostProcessing, setHasPostProcessing] = useState(false);
Review Comment:
**Suggestion:** Sorting is enabled while post-processing detection is still
pending, so an early click can sort raw truncated rows and permanently display
incorrect post-processed results. [logic error]
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1caba90bb6064b7bb569ddd32788c19d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1caba90bb6064b7bb569ddd32788c19d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx
**Line:** 85:85
**Comment:**
*Logic Error: Sorting is enabled while post-processing detection is
still pending, so an early click can sort raw truncated rows and permanently
display incorrect post-processed results.
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%2F40907&comment_hash=c4e1cf6020794fbc4f1095295256af26bd1a3adcb2ba4bd0203f1cfe41786300&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40907&comment_hash=c4e1cf6020794fbc4f1095295256af26bd1a3adcb2ba4bd0203f1cfe41786300&reaction=dislike'>๐</a>
##########
superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx:
##########
@@ -109,6 +124,10 @@ export const useResultsPane = ({
[cappedFormData],
);
+ const handleServerSort = useCallback((nextOrderby: [string, boolean][]) => {
+ setOrderby(nextOrderby);
+ }, []);
Review Comment:
**Suggestion:** Each header click starts another request without ordering or
cancellation, so a slower older response can overwrite the rows for the latest
sort selection. [race condition]
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=86f2e7c5b32a44f6ad5fa43f2256ecd7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=86f2e7c5b32a44f6ad5fa43f2256ecd7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx
**Line:** 127:129
**Comment:**
*Race Condition: Each header click starts another request without
ordering or cancellation, so a slower older response can overwrite the rows for
the latest sort selection.
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%2F40907&comment_hash=618ab3131035f0dfbae8159cc701e6936b25aa1968f12cbbe13c3936f2103f39&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40907&comment_hash=618ab3131035f0dfbae8159cc701e6936b25aa1968f12cbbe13c3936f2103f39&reaction=dislike'>๐</a>
##########
superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx:
##########
@@ -97,8 +106,14 @@ export const useResultsPane = ({
: undefined;
const cappedFormData = useMemo(
- () => ({ ...queryFormData, row_limit: effectiveRowLimit }),
- [queryFormData, effectiveRowLimit],
+ () => ({
+ ...queryFormData,
+ row_limit: effectiveRowLimit,
+ // A new `orderby` produces a new object, missing the cache below and
+ // triggering a server-side re-query in the sorted order.
+ ...(orderby.length > 0 && { orderby }),
Review Comment:
**Suggestion:** When `queriesResponse` contains full v1 results, the reuse
branch returns before the API request, so changing `orderby` never fetches
server-sorted rows. [api mismatch]
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Often`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=165eafccc08846e5bfc9b6347deaac82&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=165eafccc08846e5bfc9b6347deaac82&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx
**Line:** 109:114
**Comment:**
*Api Mismatch: When `queriesResponse` contains full v1 results, the
reuse branch returns before the API request, so changing `orderby` never
fetches server-sorted rows.
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%2F40907&comment_hash=0b65ea7a44a3beada4bf17242e9f79bc3d2cf56749e37f0132acdc759aa954b5&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40907&comment_hash=0b65ea7a44a3beada4bf17242e9f79bc3d2cf56749e37f0132acdc759aa954b5&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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]