You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "justinpark (via GitHub)" <gi...@apache.org> on 2026/04/16 00:09:03 UTC
[PR] fix(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
justinpark opened a new pull request, #39396:
URL: https://github.com/apache/superset/pull/39396
### SUMMARY
Adds three new interactive features to the SQL Lab Table Explore Tree sidebar and improves error handling for table metadata fetching.
---
### New Features
#### ๐ Schema Pin to Top
- Adds a **Pin to top** action in each schema node's hover action menu
- Pinned schemas are sorted to the front of the schema list; unpinned schemas follow in their original order
- A persistent pin indicator (`PushpinFilled`) is shown on pinned schemas when not hovered
- Pin/unpin state is managed locally with a `Set<string>` in `TableExploreTree`
#### ๐ค Column Sort Toggle (per table)
- Adds a sort button (`SortAscendingOutlined`) to each table node's hover actions
- Toggles alphabetical sorting of columns for that specific table; the button highlights in primary color when active
- Sort state is independent per table and applied in `displayTreeData` via `useMemo`, keeping source data intact
#### ๐ Refresh Table Schema
- Adds a refresh button (`SyncOutlined`) to each table node's hover actions
- Clears the cached column data for the table and re-fetches metadata + extended metadata via `Promise.all`
- Shows a danger toast notification on fetch failure
---
### Bug Fix
#### Folder icon not reflecting actual open state
Fixed a mismatch between the folder open/close icon and the actual visual expansion state
of schema nodes after a search โ pin โ unpin sequence.
- `isManuallyOpen` is now derived from `node.isOpen` (the tree's own state) instead of
a separate `manuallyOpenedNodes` tracking map
- Eliminates the stale-state divergence that caused the icon to show the wrong state
---
### Error Handling Improvement
- Added `.unwrap()` to RTK Query lazy query calls in `handleToggle` and `refreshTableSchema`
- Without `.unwrap()`, RTK Query resolves with `{ error }` on failure rather than rejecting,
so `.catch()` was never reached
- Failures now show a localized danger toast:
- `"An error occurred while fetching table metadata for <table>"`
- `"An error occurred while refreshing table metadata for <table>"`
- Added `CLEAR_TABLE_SCHEMA_DATA` reducer action to remove stale cache entries before re-fetching
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
https://github.com/user-attachments/assets/a427ffb4-7407-4feb-8ff2-3a5fd7aa0a92
### TESTING INSTRUCTIONS
Go to Sqll Lab and then pin a couple of schema
### 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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4256496229
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268145859
@justinpark I pushed a commit that makes the following changes:
- Pinned schemas are now stored per database+catalog combination instead of per database only. This means switching between catalogs within the same database correctly restores the pins you previously set for each catalog, rather than sharing one set of pins across all catalogs.
- Switching databases or catalogs no longer corrupts stored pins. Previously, changing the database could overwrite the new database's saved pins with the previous database's pins due to a timing issue. This is now fixed.
- Schema loading errors are now surfaced in the UI. When the table list fails to load after expanding a schema, the error is now shown to the user instead of failing silently.
- Refreshing a table schema no longer causes columns to temporarily disappear. Previously, columns were cleared
immediately when a refresh was triggered, so a failed refresh would leave the table with no columns visible. Now columns remain visible until the refresh succeeds.
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4290572374
CodeAnt AI finished running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268342009
@codeant-ai: review
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4290573751
CodeAnt AI is running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4293405085
CodeAnt AI is running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark merged PR #39396:
URL: https://github.com/apache/superset/pull/39396
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268210747
CodeAnt AI finished running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4263279214
### <span aria-hidden="true">โ
</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">๐จ</span> Latest commit | b44c84a5ddb8f6a773df4124a2c75075776049a9 |
|<span aria-hidden="true">๐</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69e1486e3a58d00008ba02ff |
|<span aria-hidden="true">๐</span> Deploy Preview | [https://deploy-preview-39396--superset-docs-preview.netlify.app](https://deploy-preview-39396--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">๐ฑ</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-39396--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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4293421860
CodeAnt AI finished running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4256510774
### <span aria-hidden="true">โ
</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">๐จ</span> Latest commit | 7f69a65d5505216bd68ea66795055421216b5561 |
|<span aria-hidden="true">๐</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69e0289fde1a83000860289d |
|<span aria-hidden="true">๐</span> Deploy Preview | [https://deploy-preview-39396--superset-docs-preview.netlify.app](https://deploy-preview-39396--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">๐ฑ</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-39396--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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4259762734
@justinpark I'm assuming that pinned state is not persisted through database/schema changes or page refreshes. It's a feature to help users maintain the schemas they are working on at the top. If that's the case, do you think we could automatically move to the top schemas that are loaded (opened) and remove the pin feature entirely?
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [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 #39396:
URL: https://github.com/apache/superset/pull/39396#discussion_r3100648320
##########
superset-frontend/src/SqlLab/components/TableExploreTree/index.tsx:
##########
@@ -199,6 +235,78 @@ const TableExploreTree: React.FC<Props> = ({ queryEditorId }) => {
},
[dispatch, tables, editorId, dbId],
);
+ const [pinnedSchemas, setPinnedSchemas] = useState<Set<string>>(() =>
+ getPinnedSchemasFromStorage(dbId, catalog),
+ );
+
+ const previousDbIdRef = useRef<number | undefined>(dbId);
+ const previousCatalogRef = useRef<string | null | undefined>(catalog);
+
+ // Single effect handles both loading and persisting pinned schemas.
+ // Using refs to detect source changes avoids the race condition where the
+ // persist branch would run with stale pinnedSchemas right after a dbId/catalog
+ // change, corrupting the new source's stored pins.
+ useEffect(() => {
+ const dbChanged = previousDbIdRef.current !== dbId;
+ const catalogChanged = previousCatalogRef.current !== catalog;
+
+ if (dbChanged || catalogChanged) {
+ previousDbIdRef.current = dbId;
+ previousCatalogRef.current = catalog;
+ setPinnedSchemas(getPinnedSchemasFromStorage(dbId, catalog));
+ return;
+ }
+
+ savePinnedSchemasToStorage(dbId, catalog, pinnedSchemas);
+ }, [dbId, catalog, pinnedSchemas]);
+
+ const handlePinSchema = useCallback((schemaName: string) => {
+ setPinnedSchemas(prev => new Set([...prev, schemaName]));
+ }, []);
+
+ const handleUnpinSchema = useCallback((schemaName: string) => {
+ setPinnedSchemas(prev => {
+ const next = new Set(prev);
+ next.delete(schemaName);
+ return next;
+ });
+ }, []);
+
+ const sortedTreeData = useMemo(() => {
+ if (pinnedSchemas.size === 0) return treeData;
+ const pinned = treeData.filter(node => pinnedSchemas.has(node.name));
+ const rest = treeData.filter(node => !pinnedSchemas.has(node.name));
+ return [...pinned, ...rest];
+ }, [treeData, pinnedSchemas]);
+
+ const [sortedTables, setSortedTables] = useState<Record<string, boolean>>({});
+ const toggleSortColumns = useCallback((tableId: string) => {
Review Comment:
**Suggestion:** Column-sort state is keyed only by table id (which excludes catalog) and is never reset when database/catalog changes, so a sort toggle can leak into a different catalog that has the same db/schema/table path. Reset the per-table sort map whenever the data source context changes. [logic error]
<details>
<summary><b>Severity Level:</b> Major โ ๏ธ</summary>
```mdx
- โ ๏ธ Column sort state leaks between catalogs in SQL Lab tree.
- โ ๏ธ Users see unexpected sorted columns switching between catalogs.
```
</details>
```suggestion
useEffect(() => {
setSortedTables({});
}, [dbId, catalog]);
```
<details>
<summary><b>Steps of Reproduction โ
</b></summary>
```mdx
1. Open SQL Lab where the left sidebar is implemented by `SqlEditorLeftBar`
(superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx:5-24), which renders
`<TableExploreTree queryEditorId={activeQEId} />` (line 24) as the schema/table tree.
2. Using the `DatabaseSelector` in that same component (SqlEditorLeftBar/index.tsx:13-21),
select a database with `dbId = X` that supports multiple catalogs and choose `catalog =
cat1` plus a schema (e.g. `public`) that has a table `orders`; these values flow into
`TableExploreTree`, which reads `dbId` and `catalog` from the query editor
(TableExploreTree/index.tsx:172-178) and into `useTreeData` (index.tsx:191-205,
useTreeData.ts:135-140).
3. In the table tree, expand schema `public` so `useTreeData` builds a table node with `id
= "table:X:public:orders"`
(superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts:331-357), then
click the "Sort columns alphabetically" button for that table; this calls
`toggleSortColumns(data.id)` in `TreeNodeRenderer` (TreeNodeRenderer.tsx:340-357), which
in `TableExploreTree` updates `sortedTables["table:X:public:orders"] = true` via the state
defined at index.tsx:282-285.
4. In the same SQL Lab tab, change only the catalog via `DatabaseSelector` to `catalog =
cat2` while keeping the same `dbId = X` (SqlEditorLeftBar/index.tsx:13-21);
`TableExploreTree` now recomputes `treeData` for the new catalog (useTreeData.ts:135-140,
317-379) and again creates a table node with `id = "table:X:public:orders"` for the `cat2`
table, but because `sortedTables` is never cleared or keyed by catalog (index.tsx:282-285,
and the table id format in useTreeData.ts:331-333 omits `catalog`), `displayTreeData`
treats this new node as sorted (index.tsx:287-307) and the sort icon appears active with
columns alphabetically sorted even though the user never toggled sorting for the `cat2`
version of the table.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2Findex.tsx%0A%2A%2ALine%3A%2A%2A%20283%3A283%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20Column-sort%20state%20is%20keyed%20only%20by%20table%20id%20%28which%20excludes%20catalog%29%20and%20is%20never%20reset%20when%20database%2Fcatalog%20changes%2C%20so%20a%20sort%20toggle%20can%20leak%20into%20a%20different%20catalog%20that%20has%20the%20same%20db%2Fschema%2Ftable%20path.%20Reset%20the%20per-table%20sort%20map%20whenever%20the%20data%20source%20context%20changes.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&promp
t=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2Findex.tsx%0A%2A%2ALine%3A%2A%2A%20283%3A283%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20Column-sort%20state%20is%20keyed%20only%20by%20table%20id%20%28which%20excludes%20catalog%29%20and%20is%20never%20reset%20when%20database%2Fcatalog%20changes%2C%20so%20a%20sort%20toggle%20can%20leak%20into%20a%20different%20catalog%20that%20has%20the%20same%20db%2Fschema%2Ftable%20path.%20Reset%20the%20per-table%20sort%20map%20whenever%20the%20data%20source%20context%20changes.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A)
*(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/src/SqlLab/components/TableExploreTree/index.tsx
**Line:** 283:283
**Comment:**
*Logic Error: Column-sort state is keyed only by table id (which excludes catalog) and is never reset when database/catalog changes, so a sort toggle can leak into a different catalog that has the same db/schema/table path. Reset the per-table sort map whenever the data source context 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.
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=cfaa0655263fbdd6f960e335e9327dd54a7e627a161e460c5c69c81addff5d38&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=cfaa0655263fbdd6f960e335e9327dd54a7e627a161e460c5c69c81addff5d38&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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4293091636
CodeAnt AI finished running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [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 #39396:
URL: https://github.com/apache/superset/pull/39396#discussion_r3119303798
##########
superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts:
##########
@@ -289,6 +305,13 @@ const useTreeData = ({
[fetchLazyTables],
);
+ const refreshTableSchema = useCallback(
+ (id: string) => {
+ fetchAndStoreTableSchema(id, false);
Review Comment:
**Suggestion:** The refresh path never clears the existing table schema entry before re-fetching, so the UI keeps showing stale columns/select metadata until the request completes and can stay stale if the refresh fails. Clear the cached table schema state first, then fetch fresh metadata. [logic error]
<details>
<summary><b>Severity Level:</b> Major โ ๏ธ</summary>
```mdx
- โ ๏ธ SQL Lab table tree shows stale columns after failed refresh.
- โ ๏ธ SELECT star copy uses outdated selectStar metadata after failures.
- โ ๏ธ Users may misinterpret stale schema as latest database definition.
```
</details>
```suggestion
const [, databaseId, schema, table] = id.split(':');
const tableKey = `${Number(databaseId)}:${schema}:${table}`;
dispatch({ type: 'CLEAR_TABLE_SCHEMA_DATA', key: tableKey });
```
<details>
<summary><b>Steps of Reproduction โ
</b></summary>
```mdx
1. Open SQL Lab and navigate to the left sidebar, which renders `TableExploreTree` via
`SqlEditorLeftBar` at
`superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx:24`.
2. In the Table Explore tree, expand a schema and then a table so the table node is
opened; this calls `handleToggle('table:dbId:schema:table', true)` in `useTreeData` at
`superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts:207-257`, which
in turn calls `fetchAndStoreTableSchema(id, true)` and populates
`tableSchemaData[tableKey]`.
3. Observe that the table's columns and `selectStar` are rendered from `columnsData =
tableSchemaData[tableKey] ?? pinnedTables[tableKey]` in the `treeData` builder at
`useTreeData.ts:330-336`, and that `selectStarMap` is derived from `tableSchemaData` in
`useTreeData.ts:381-394`.
4. Click the table's "Refresh table schema" icon in the hover actions, wired in
`TreeNodeRenderer` at
`superset-frontend/src/SqlLab/components/TableExploreTree/TreeNodeRenderer.tsx:140-145`,
which calls `refreshTableSchema(data.id)`; this executes `refreshTableSchema` in
`useTreeData.ts:308-313`, which only calls `fetchAndStoreTableSchema(id, false)` without
dispatching `CLEAR_TABLE_SCHEMA_DATA`, so the existing `tableSchemaData[tableKey]` remains
in place while the request is in flight and also if the request fails (the `.catch` in
`fetchAndStoreTableSchema` at `useTreeData.ts:184-193` only shows a danger toast and does
not modify `tableSchemaData`), leaving the UI showing the last cached schema/`selectStar`
even after the user explicitly requested a refresh that failed.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts%0A%2A%2ALine%3A%2A%2A%20310%3A310%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20The%20refresh%20path%20never%20clears%20the%20existing%20table%20schema%20entry%20before%20re-fetching%2C%20so%20the%20UI%20keeps%20showing%20stale%20columns%2Fselect%20metadata%20until%20the%20request%20completes%20and%20can%20stay%20stale%20if%20the%20refresh%20fails.%20Clear%20the%20cached%20table%20schema%20state%20first%2C%20then%20fetch%20fresh%20metadata.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20a
nd%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts%0A%2A%2ALine%3A%2A%2A%20310%3A310%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20The%20refresh%20path%20never%20clears%20the%20existing%20table%20schema%20entry%20before%20re-fetching%2C%20so%20the%20UI%20keeps%20showing%20stale%20columns%2Fselect%20metadata%20until%20the%20request%20completes%20and%20can%20stay%20stale%20if%20the%20refresh%20fails.%20Clear%20the%20cached%20table%20schema%20state%20first%2C%20then%20fetch%20fresh%20metadata.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20i
ssue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(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/src/SqlLab/components/TableExploreTree/useTreeData.ts
**Line:** 310:310
**Comment:**
*Logic Error: The refresh path never clears the existing table schema entry before re-fetching, so the UI keeps showing stale columns/select metadata until the request completes and can stay stale if the refresh fails. Clear the cached table schema state first, then fetch fresh metadata.
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%2F39396&comment_hash=1acb04c4d55fe0d8ef731f40b20ef3c9e4edcc25a987b206b0465e02a1698ab0&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=1acb04c4d55fe0d8ef731f40b20ef3c9e4edcc25a987b206b0465e02a1698ab0&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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4290596308
CodeAnt AI finished running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4256553935
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/39396?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `32.46753%` with `52 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 64.52%. Comparing base ([`84af6c9`](https://app.codecov.io/gh/apache/superset/commit/84af6c9f2976fbe97e122c3201de32f2cb9d75ac?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`b72de62`](https://app.codecov.io/gh/apache/superset/commit/b72de62d2fd1db165f189dcbc70a66b63b70c5b9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/39396?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [.../SqlLab/components/TableExploreTree/useTreeData.ts](https://app.codecov.io/gh/apache/superset/pull/39396?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL1NxbExhYi9jb21wb25lbnRzL1RhYmxlRXhwbG9yZVRyZWUvdXNlVHJlZURhdGEudHM=) | 20.00% | [20 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39396?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...d/src/SqlLab/components/TableExploreTree/index.tsx](https://app.codecov.io/gh/apache/superset/pull/39396?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2Findex.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL1NxbExhYi9jb21wb25lbnRzL1RhYmxlRXhwbG9yZVRyZWUvaW5kZXgudHN4) | 36.66% | [19 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39396?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...b/components/TableExploreTree/TreeNodeRenderer.tsx](https://app.codecov.io/gh/apache/superset/pull/39396?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FTreeNodeRenderer.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL1NxbExhYi9jb21wb25lbnRzL1RhYmxlRXhwbG9yZVRyZWUvVHJlZU5vZGVSZW5kZXJlci50c3g=) | 40.90% | [13 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39396?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
:x: Your project check has failed because the head coverage (99.79%) is below the target coverage (100.00%). You can increase the head coverage or adjust the [target](https://docs.codecov.com/docs/commit-status#target) coverage.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #39396 +/- ##
==========================================
- Coverage 64.54% 64.52% -0.03%
==========================================
Files 2557 2557
Lines 132981 133051 +70
Branches 30888 30908 +20
==========================================
+ Hits 85837 85855 +18
- Misses 45653 45705 +52
Partials 1491 1491
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/39396/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/39396/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.29% <32.46%> (-0.04%)` | :arrow_down: |
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 Sentry](https://app.codecov.io/gh/apache/superset/pull/39396?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
Re: [PR] fix(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4311586813
CodeAnt AI is running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268447405
CodeAnt AI finished running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268409823
@codeant-ai: review
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4261440321
> @justinpark I'm assuming that pinned state is not persisted through database/schema changes or page refreshes. It's a feature to help users maintain the schemas they are working on at the top. If that's the case, do you think we could automatically move to the top schemas that are loaded (opened) and remove the pin feature entirely?
oh you're right. Let me store the value in localStorage to maintain their selection.
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268169169
@codeant-ai: review
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4290539374
CodeAnt AI is running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4293079305
CodeAnt AI is running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4301340038
CodeAnt AI is running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4311633733
CodeAnt AI finished running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [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 #39396:
URL: https://github.com/apache/superset/pull/39396#discussion_r3090092803
##########
superset-frontend/src/SqlLab/components/TableExploreTree/index.tsx:
##########
@@ -199,6 +200,55 @@ const TableExploreTree: React.FC<Props> = ({ queryEditorId }) => {
},
[dispatch, tables, editorId, dbId],
);
+ const [pinnedSchemas, setPinnedSchemas] = useState<Set<string>>(new Set());
+
+ const handlePinSchema = useCallback((schemaName: string) => {
Review Comment:
**Suggestion:** `pinnedSchemas` is kept across database/catalog switches, so schemas pinned in one source remain pinned when viewing a different source with the same schema names. Reset the pinned schema state when `dbId` or `catalog` changes to prevent cross-source state leakage. [logic error]
<details>
<summary><b>Severity Level:</b> Major โ ๏ธ</summary>
```mdx
- โ ๏ธ Schema pinning leaks across databases sharing schema labels.
- โ ๏ธ Users see unexpected schema ordering after switching databases.
```
</details>
```suggestion
useEffect(() => {
setPinnedSchemas(new Set());
}, [dbId, catalog]);
```
<details>
<summary><b>Steps of Reproduction โ
</b></summary>
```mdx
1. Open SQL Lab and a query editor so `SqlEditorLeftBar` renders; this component at
`superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx:5-35` includes both
the `DatabaseSelector` (lines 13-21) and `<TableExploreTree queryEditorId={activeQEId} />`
(line 24).
2. Select a database and catalog using `DatabaseSelector`; `TableExploreTree` then reads
`dbId` and `catalog` for the active query editor via `useQueryEditor` at
`TableExploreTree/index.tsx:137-143`, and `useTreeData` builds schema nodes for that
source at `useTreeData.ts:102-166` (schema IDs `schema:${dbId}:${schema.value}`, schema
names from `schema.label`).
3. In the sidebar tree, hover a schema (e.g. `public`) and click the "Pin to top" action;
this calls `handlePinSchema(schema)` from `TreeNodeRenderer` at
`TreeNodeRenderer.tsx:240-259`, which in `TableExploreTree/index.tsx:205-207` adds the
schema name to the `pinnedSchemas` state: `setPinnedSchemas(prev => new Set([...prev,
schemaName]))`.
4. Change to a different database/catalog using `DatabaseSelector` (its `key` at
`SqlEditorLeftBar/index.tsx:13-16` ensures the selector remounts but does not affect
`TableExploreTree`); `TableExploreTree` receives new `dbId`/`catalog` and recomputes
`treeData` for the new source via `useTreeData`, but the `pinnedSchemas` state defined at
`index.tsx:203-215` has no `useEffect` tied to `dbId` or `catalog`, so it still contains
the previously pinned schema name. When `sortedTreeData` at `index.tsx:217-222` filters
and reorders top-level schema nodes using `pinnedSchemas.has(node.name)`, any schema in
the new source with the same label (e.g. another `public`) is incorrectly treated as
pinned and moved to the front even though the user never pinned it for this database.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2Findex.tsx%0A%2A%2ALine%3A%2A%2A%20205%3A205%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20%60pinnedSchemas%60%20is%20kept%20across%20database%2Fcatalog%20switches%2C%20so%20schemas%20pinned%20in%20one%20source%20remain%20pinned%20when%20viewing%20a%20different%20source%20with%20the%20same%20schema%20names.%20Reset%20the%20pinned%20schema%20state%20when%20%60dbId%60%20or%20%60catalog%60%20changes%20to%20prevent%20cross-source%20state%20leakage.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comme
nt%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2Findex.tsx%0A%2A%2ALine%3A%2A%2A%20205%3A205%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20%60pinnedSchemas%60%20is%20kept%20across%20database%2Fcatalog%20switches%2C%20so%20schemas%20pinned%20in%20one%20source%20remain%20pinned%20when%20viewing%20a%20different%20source%20with%20the%20same%20schema%20names.%20Reset%20the%20pinned%20schema%20state%20when%20%60dbId%60%20or%20%60catalog%60%20changes%20to%20prevent%20cross-source%20state%20leakage.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A)
*(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/src/SqlLab/components/TableExploreTree/index.tsx
**Line:** 205:205
**Comment:**
*Logic Error: `pinnedSchemas` is kept across database/catalog switches, so schemas pinned in one source remain pinned when viewing a different source with the same schema names. Reset the pinned schema state when `dbId` or `catalog` changes to prevent cross-source state leakage.
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.
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=e1a9550c899eb250ef31eec548add78450675e3b7d6456bda4b42b8bbcaaaa30&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=e1a9550c899eb250ef31eec548add78450675e3b7d6456bda4b42b8bbcaaaa30&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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4301348882
CodeAnt AI is running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4301359235
CodeAnt AI finished running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4259730229
@justinpark I think both comments from bots are valid. Could you take a look?
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [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 #39396:
URL: https://github.com/apache/superset/pull/39396#discussion_r3100477497
##########
superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts:
##########
@@ -137,6 +146,56 @@ const useTreeData = ({
const [state, dispatch] = useReducer(treeDataReducer, initialState);
const { tableData, tableSchemaData, loadingNodes, errorPayload } = state;
+ // Shared helper: fetch table metadata + extended metadata and store in state.
+ // preferCacheValue=true on initial open (use cached data if available),
+ // preferCacheValue=false on explicit refresh (bypass cache).
+ const fetchAndStoreTableSchema = useCallback(
+ (id: string, preferCacheValue: boolean) => {
+ const parts = id.split(':');
+ const [, databaseId, schema, table] = parts;
+ const parsedDbId = Number(databaseId);
+ const tableKey = `${parsedDbId}:${schema}:${table}`;
+
+ dispatch({ type: 'SET_LOADING_NODE', nodeId: id, loading: true });
+
+ // .unwrap() causes RTK Query to reject on error so .catch() fires.
+ // Without it RTK Query resolves with { error } instead of rejecting.
+ Promise.all([
+ fetchTableMetadata(
+ { dbId: parsedDbId, catalog, schema, table },
+ preferCacheValue,
+ ).unwrap(),
+ fetchTableExtendedMetadata(
+ { dbId: parsedDbId, catalog, schema, table },
+ preferCacheValue,
+ ).unwrap(),
+ ])
+ .then(([tableMetadata, tableExtendedMetadata]) => {
+ if (tableMetadata) {
+ dispatch({
+ type: 'SET_TABLE_SCHEMA_DATA',
+ key: tableKey,
+ data: { ...tableMetadata, ...tableExtendedMetadata },
+ });
+ }
+ })
+ .catch(() => {
+ reduxDispatch(
+ addDangerToast(
+ t(
+ 'An error occurred while fetching table metadata for %s',
+ table,
+ ),
+ ),
+ );
+ })
+ .finally(() => {
+ dispatch({ type: 'SET_LOADING_NODE', nodeId: id, loading: false });
+ });
+ },
+ [catalog, fetchTableExtendedMetadata, fetchTableMetadata, reduxDispatch],
Review Comment:
**Suggestion:** Multiple rapid refresh/open actions for the same table can start overlapping metadata requests, creating a race where an older response can overwrite a newer one and loading state can flicker incorrectly. Guard duplicate in-flight requests for the same node. [race condition]
<details>
<summary><b>Severity Level:</b> Major โ ๏ธ</summary>
```mdx
- โ ๏ธ Table node spinner can stop while request still running.
- โ ๏ธ Rapid refreshes may rarely re-apply older schema metadata.
- โ ๏ธ Redundant metadata requests increase backend and network load.
```
</details>
```suggestion
if (loadingNodes[id]) return;
const parts = id.split(':');
const [, databaseId, schema, table] = parts;
const parsedDbId = Number(databaseId);
const tableKey = `${parsedDbId}:${schema}:${table}`;
dispatch({ type: 'SET_LOADING_NODE', nodeId: id, loading: true });
// .unwrap() causes RTK Query to reject on error so .catch() fires.
// Without it RTK Query resolves with { error } instead of rejecting.
Promise.all([
fetchTableMetadata(
{ dbId: parsedDbId, catalog, schema, table },
preferCacheValue,
).unwrap(),
fetchTableExtendedMetadata(
{ dbId: parsedDbId, catalog, schema, table },
preferCacheValue,
).unwrap(),
])
.then(([tableMetadata, tableExtendedMetadata]) => {
if (tableMetadata) {
dispatch({
type: 'SET_TABLE_SCHEMA_DATA',
key: tableKey,
data: { ...tableMetadata, ...tableExtendedMetadata },
});
}
})
.catch(() => {
reduxDispatch(
addDangerToast(
t(
'An error occurred while fetching table metadata for %s',
table,
),
),
);
})
.finally(() => {
dispatch({ type: 'SET_LOADING_NODE', nodeId: id, loading: false });
});
},
[
catalog,
fetchTableExtendedMetadata,
fetchTableMetadata,
loadingNodes,
reduxDispatch,
],
```
<details>
<summary><b>Steps of Reproduction โ
</b></summary>
```mdx
1. Open SQL Lab and load the left sidebar tree from
`superset-frontend/src/SqlLab/components/TableExploreTree/index.tsx:164-205`. The tree
uses `renderNode` (`index.tsx:125-145`) to pass `loadingNodes` and `refreshTableSchema`
into `TreeNodeRenderer`, and it wires `onToggle` to `handleToggle` from `useTreeData` at
`index.tsx:231-244`.
2. Expand a table node whose metadata has not yet been loaded. The `onToggle` handler
calls `handleToggle` in `useTreeData.ts:199-259`. For a table node (`identifier ===
'table'` at `useTreeData.ts:240-247`) and missing `tableSchemaData[tableKey]`,
`handleToggle` calls `fetchAndStoreTableSchema(id, true)` (`useTreeData.ts:247`), which
sets `loadingNodes[id] = true` via `SET_LOADING_NODE` (`useTreeData.ts:159-160, 81-88`)
and starts two async RTK Query requests in `Promise.all` (`useTreeData.ts:163-172`).
3. While the first metadata request is still in flight (e.g., slow or high-latency
backend), repeatedly click the "Refresh table schema" action for the same table in the UI.
This action is defined in `TreeNodeRenderer.tsx:100-105` as an `ActionButton` with
`onClick={() => refreshTableSchema(data.id)}`, which calls `refreshTableSchema` from
`useTreeData.ts:300-305` and in turn calls `fetchAndStoreTableSchema(id, false)` each time
it is clicked. Because the current implementation of `fetchAndStoreTableSchema`
(`useTreeData.ts:152-195`) does not guard against in-flight requests, each click starts
another `Promise.all` for the same table id.
4. Observe that multiple `Promise.all` chains share the same `id` and each has a
`.finally` that dispatches `SET_LOADING_NODE` with `loading: false`
(`useTreeData.ts:192-194`). If an earlier request's `.finally` executes while a later
request is still pending, `loadingNodes[id]` becomes `false` even though a fetch is still
in progress, causing `TreeNodeRenderer`'s `isLoading` (`TreeNodeRenderer.tsx:126-128`) to
flip to false and the spinner icon to disappear while a network request is ongoing. In
scenarios where backend schema changes between rapid refreshes and responses complete out
of order, a slower, older `fetchAndStoreTableSchema` `.then` handler
(`useTreeData.ts:173-180`) can also overwrite `tableSchemaData[tableKey]` with stale
metadata. The suggested guard `if (loadingNodes[id]) return;` would prevent starting
overlapping requests for the same node, aligning `loadingNodes` with "any in-flight
request" and removing this concurrency window.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts%0A%2A%2ALine%3A%2A%2A%20154%3A196%0A%2A%2AComment%3A%2A%2A%0A%09%2ARace%20Condition%3A%20Multiple%20rapid%20refresh%2Fopen%20actions%20for%20the%20same%20table%20can%20start%20overlapping%20metadata%20requests%2C%20creating%20a%20race%20where%20an%20older%20response%20can%20overwrite%20a%20newer%20one%20and%20loading%20state%20can%20flicker%20incorrectly.%20Guard%20duplicate%20in-flight%20requests%20for%20the%20same%20node.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%2
0during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts%0A%2A%2ALine%3A%2A%2A%20154%3A196%0A%2A%2AComment%3A%2A%2A%0A%09%2ARace%20Condition%3A%20Multiple%20rapid%20refresh%2Fopen%20actions%20for%20the%20same%20table%20can%20start%20overlapping%20metadata%20requests%2C%20creating%20a%20race%20where%20an%20older%20response%20can%20overwrite%20a%20newer%20one%20and%20loading%20state%20can%20flicker%20incorrectly.%20Guard%20duplicate%20in-flight%20requests%20for%20the%20same%20node.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A)
*(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/src/SqlLab/components/TableExploreTree/useTreeData.ts
**Line:** 154:196
**Comment:**
*Race Condition: Multiple rapid refresh/open actions for the same table can start overlapping metadata requests, creating a race where an older response can overwrite a newer one and loading state can flicker incorrectly. Guard duplicate in-flight requests for the same node.
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.
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=2fe81dbe3db61ead08e8a32a6ca70ed7ce695c8902983128a94dcdd61e270a22&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=2fe81dbe3db61ead08e8a32a6ca70ed7ce695c8902983128a94dcdd61e270a22&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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268375734
CodeAnt AI finished running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268169936
CodeAnt AI is running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268622253
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4301367864
CodeAnt AI finished running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [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 #39396:
URL: https://github.com/apache/superset/pull/39396#discussion_r3121489281
##########
superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts:
##########
@@ -289,6 +305,13 @@ const useTreeData = ({
[fetchLazyTables],
);
+ const refreshTableSchema = useCallback(
+ (id: string) => {
+ fetchAndStoreTableSchema(id, false);
+ },
+ [fetchAndStoreTableSchema],
+ );
Review Comment:
**Suggestion:** The refresh handler does not clear the existing cached schema before re-fetching, so stale columns remain visible if the refresh request fails. Dispatch the cache-clearing action for that table key before starting the fetch so the UI reflects that the old schema is no longer trusted during refresh. [logic error]
<details>
<summary><b>Severity Level:</b> Major โ ๏ธ</summary>
```mdx
- โ ๏ธ SQL Lab tree shows outdated columns after failed schema refresh.
- โ ๏ธ Users may misinterpret stale columns as latest database schema.
```
</details>
<details>
<summary><b>Steps of Reproduction โ
</b></summary>
```mdx
1. Open SQL Lab so that `SqlEditorLeftBar` renders the table sidebar:
`superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx:14` mounts
`<TableExploreTree queryEditorId={activeQEId} />`, which in turn uses `useTreeData` from
`superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts`.
2. In the UI, select a database and schema, then click a table node to expand it. This
triggers `node.toggle()` in `TreeNodeRenderer` at
`superset-frontend/src/SqlLab/components/TableExploreTree/TreeNodeRenderer.tsx:209โ218`,
which calls `handleToggle(id, isOpen)` from `useTreeData` at `useTreeData.ts:208โ257`. For
`identifier === 'table'` with no cached schema, `handleToggle` calls
`fetchAndStoreTableSchema(id, true)` (lines 248โ256), which loads metadata and dispatches
`SET_TABLE_SCHEMA_DATA` at lines 175โ181, populating `tableSchemaData[tableKey]`.
3. Confirm that the table's columns are rendered from this cached schema: in
`useTreeData.ts:330โ335`, `columnsData` is computed as `tableSchemaData[tableKey] ??
pinnedTables[tableKey]`, and the children/columns are built from `columnsData.columns` at
lines 342โ349. This demonstrates that `tableSchemaData` is the source of truth for the
visible column list.
4. Click the "Refresh table schema" side-action for the same table. The button is wired in
`TreeNodeRenderer` at
`superset-frontend/src/SqlLab/components/TableExploreTree/TreeNodeRenderer.tsx:100โ105`
with `onClick={() => refreshTableSchema(data.id)}`. That invokes `refreshTableSchema` in
`useTreeData.ts:308โ313`, which simply calls `fetchAndStoreTableSchema(id, false)` without
clearing `tableSchemaData` first.
5. Induce a backend failure for the table-metadata APIs (for example, stop or misconfigure
the metadata endpoint so that the RTK Query hooks reject). The `Promise.all` in
`fetchAndStoreTableSchema` at `useTreeData.ts:165โ175` will reject, and the `.catch` block
at lines 184โ192 dispatches `addDangerToast` but never dispatches
`CLEAR_TABLE_SCHEMA_DATA`. The reducer case for `CLEAR_TABLE_SCHEMA_DATA` is defined at
lines 77โ80 but is never called. After the failure, `tableSchemaData[tableKey]` still
holds the old metadata, and the tree continues to render the previous columns from that
cache, so the columns remain visible and unchanged despite the failed refresh.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts%0A%2A%2ALine%3A%2A%2A%20308%3A313%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20The%20refresh%20handler%20does%20not%20clear%20the%20existing%20cached%20schema%20before%20re-fetching%2C%20so%20stale%20columns%20remain%20visible%20if%20the%20refresh%20request%20fails.%20Dispatch%20the%20cache-clearing%20action%20for%20that%20table%20key%20before%20starting%20the%20fetch%20so%20the%20UI%20reflects%20that%20the%20old%20schema%20is%20no%20longer%20trusted%20during%20refresh.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comment
s%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts%0A%2A%2ALine%3A%2A%2A%20308%3A313%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20The%20refresh%20handler%20does%20not%20clear%20the%20existing%20cached%20schema%20before%20re-fetching%2C%20so%20stale%20columns%20remain%20visible%20if%20the%20refresh%20request%20fails.%20Dispatch%20the%20cache-clearing%20action%20for%20that%20table%20key%20before%20starting%20the%20fetch%20so%20the%20UI%20reflects%20that%20the%20old%20schema%20is%20no%20longer%20trusted%20during%20refre
sh.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(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/src/SqlLab/components/TableExploreTree/useTreeData.ts
**Line:** 308:313
**Comment:**
*Logic Error: The refresh handler does not clear the existing cached schema before re-fetching, so stale columns remain visible if the refresh request fails. Dispatch the cache-clearing action for that table key before starting the fetch so the UI reflects that the old schema is no longer trusted during refresh.
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%2F39396&comment_hash=d8381e326362cecc7df36c90c4bc60b67aeaf8dfd7229938299372835a9eed5e&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=d8381e326362cecc7df36c90c4bc60b67aeaf8dfd7229938299372835a9eed5e&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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4263574832
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268410773
CodeAnt AI is running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #39396:
URL: https://github.com/apache/superset/pull/39396#discussion_r3090113113
##########
superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts:
##########
@@ -289,6 +309,55 @@ const useTreeData = ({
[fetchLazyTables],
);
+ const refreshTableSchema = useCallback(
+ (id: string) => {
+ const parts = id.split(':');
+ const [, databaseId, schema, table] = parts;
+ const parsedDbId = Number(databaseId);
+ const tableKey = `${parsedDbId}:${schema}:${table}`;
+
+ dispatch({ type: 'CLEAR_TABLE_SCHEMA_DATA', key: tableKey });
+ dispatch({ type: 'SET_LOADING_NODE', nodeId: id, loading: true });
+
+ Promise.all([
+ fetchTableMetadata(
+ { dbId: parsedDbId, catalog, schema, table },
+ false,
+ ).unwrap(),
+ fetchTableExtendedMetadata(
+ { dbId: parsedDbId, catalog, schema, table },
+ false,
+ ).unwrap(),
+ ])
+ .then(([tableMetadata, tableExtendedMetadata]) => {
+ if (tableMetadata) {
+ dispatch({
+ type: 'SET_TABLE_SCHEMA_DATA',
+ key: tableKey,
+ data: {
+ ...tableMetadata,
+ ...tableExtendedMetadata,
+ },
+ });
+ }
+ })
+ .catch(() => {
+ reduxDispatch(
+ addDangerToast(
+ t(
+ 'An error occurred while refreshing table metadata for %s',
+ table,
+ ),
+ ),
+ );
+ })
+ .finally(() => {
+ dispatch({ type: 'SET_LOADING_NODE', nodeId: id, loading: false });
+ });
+ },
+ [catalog, fetchTableExtendedMetadata, fetchTableMetadata, reduxDispatch],
+ );
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Code Duplication</b></div>
<div id="fix">
The logic for fetching tableMetadata and tableExtendedMetadata is duplicated from the handleToggle function. To avoid maintenance issues and divergence risk, consider extracting this into a shared helper function.
</div>
</div>
<small><i>Code Review Run #eb853a</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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [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 #39396:
URL: https://github.com/apache/superset/pull/39396#discussion_r3096247957
##########
superset-frontend/src/SqlLab/components/TableExploreTree/index.tsx:
##########
@@ -199,6 +224,67 @@ const TableExploreTree: React.FC<Props> = ({ queryEditorId }) => {
},
[dispatch, tables, editorId, dbId],
);
+ const [pinnedSchemas, setPinnedSchemas] = useState<Set<string>>(() =>
+ getPinnedSchemasFromStorage(dbId),
+ );
+
+ // Reload pinned schemas from localStorage when the database changes
+ useEffect(() => {
+ setPinnedSchemas(getPinnedSchemasFromStorage(dbId));
+ }, [dbId]);
+
+ // Persist pinned schemas to localStorage keyed by database_id
+ useEffect(() => {
Review Comment:
**Suggestion:** The current load/save effects can persist the previous database's pinned schemas into the newly selected database because both effects run after a `dbId` change while `pinnedSchemas` is still stale. Merge this into a db-change-aware effect so saving is skipped during the transition render and only happens after the new database state is loaded. [logic error]
<details>
<summary><b>Severity Level:</b> Major โ ๏ธ</summary>
```mdx
- โ ๏ธ SQL Lab schema pinning mixes pins across databases.
- โ ๏ธ Existing pinned schemas for a database can be overwritten.
- โ ๏ธ User-specific sidebar customization behaves inconsistently after DB switches.
```
</details>
```suggestion
const previousDbIdRef = useRef<number | undefined>(dbId);
useEffect(() => {
if (previousDbIdRef.current !== dbId) {
previousDbIdRef.current = dbId;
setPinnedSchemas(getPinnedSchemasFromStorage(dbId));
return;
}
```
<details>
<summary><b>Steps of Reproduction โ
</b></summary>
```mdx
1. Open SQL Lab so the React tree renders `AppLayout`
(`superset-frontend/src/SqlLab/components/AppLayout/index.tsx:11-18`), which includes
`SqlEditorLeftBar` (`index.tsx:12-15`), which in turn renders `TableExploreTree`
(`superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx:24`).
2. With database A selected via `DatabaseSelector` (`SqlEditorLeftBar/index.tsx:13-21`,
which controls `queryEditor.dbId`), pin one or more schemas in the table tree. This
updates `pinnedSchemas` state in `TableExploreTree` (`index.tsx:227-251`) and triggers the
persist effect `savePinnedSchemasToStorage(dbId, pinnedSchemas)` (`index.tsx:236-239`),
storing them under key A in localStorage key `sqllab__pinned_schemas`
(`src/utils/localStorageHelpers.ts:54-75`).
3. In the same SQL Lab tab, change the selected database from A to B using the same
`DatabaseSelector`. This updates `queryEditor.dbId` so `TableExploreTree` re-renders with
`dbId = B` (`index.tsx:166-167) while `pinnedSchemas` still contains the previous value
for database A at the moment of that render (`index.tsx:227-235`).
4. After this render commits, React runs both effects at
`TableExploreTree/index.tsx:231-239`: the reload effect (`231-234`) schedules
`setPinnedSchemas(getPinnedSchemasFromStorage(dbId))` for dbId B, and the persist effect
(`236-239`) immediately calls `savePinnedSchemasToStorage(dbId, pinnedSchemas)` with `dbId
= B` and stale `pinnedSchemas` from database A. This overwrites any existing pinned
schemas for database B in `sqllab__pinned_schemas` with A's schemas, and the subsequent
reload then reads back these incorrect values so the UI for database B shows the wrong
pinned schemas.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2Findex.tsx%0A%2A%2ALine%3A%2A%2A%20231%3A237%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20The%20current%20load%2Fsave%20effects%20can%20persist%20the%20previous%20database%27s%20pinned%20schemas%20into%20the%20newly%20selected%20database%20because%20both%20effects%20run%20after%20a%20%60dbId%60%20change%20while%20%60pinnedSchemas%60%20is%20still%20stale.%20Merge%20this%20into%20a%20db-change-aware%20effect%20so%20saving%20is%20skipped%20during%20the%20transition%20render%20and%20only%20happens%20after%20the%20new%20database%20state%20is%20loaded.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A) |
[Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2Findex.tsx%0A%2A%2ALine%3A%2A%2A%20231%3A237%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20The%20current%20load%2Fsave%20effects%20can%20persist%20the%20previous%20database%27s%20pinned%20schemas%20into%20the%20newly%20selected%20database%20because%20both%20effects%20run%20after%20a%20%60dbId%60%20change%20while%20%60pinnedSchemas%60%20is%20still%20stale.%20Merge%20this%20into%20a%20db-change-aware%20effect%20so%20saving%20is%20skipped%20during%20the%20transition%20render%20and%20only%20happens%20after%20the%20new%20database%20state%20is%20loaded.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20c
oncise.%0A)
*(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/src/SqlLab/components/TableExploreTree/index.tsx
**Line:** 231:237
**Comment:**
*Logic Error: The current load/save effects can persist the previous database's pinned schemas into the newly selected database because both effects run after a `dbId` change while `pinnedSchemas` is still stale. Merge this into a db-change-aware effect so saving is skipped during the transition render and only happens after the new database state is loaded.
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.
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=61ac1f645f162be1d526552bd9589df5b3f44af84eed35ab372ff96a141c2ffb&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=61ac1f645f162be1d526552bd9589df5b3f44af84eed35ab372ff96a141c2ffb&reaction=dislike'>๐</a>
##########
superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts:
##########
@@ -150,17 +209,10 @@ const useTreeData = ({
if (identifier === 'schema') {
const schemaKey = `${parsedDbId}:${schema}`;
if (!tableData?.[schemaKey]) {
- // Set loading state
dispatch({ type: 'SET_LOADING_NODE', nodeId: id, loading: true });
- // Fetch tables asynchronously
fetchLazyTables(
- {
- dbId: parsedDbId,
- catalog,
- schema,
- forceRefresh: false,
- },
+ { dbId: parsedDbId, catalog, schema, forceRefresh: false },
true,
)
.then(({ data }) => {
Review Comment:
**Suggestion:** This lazy query still relies on `.catch()` without calling `.unwrap()`, so RTK Query failures resolve as `{ error }` and bypass the error handler. Use `.unwrap()` so request failures actually reject and populate `errorPayload` correctly. [possible bug]
<details>
<summary><b>Severity Level:</b> Major โ ๏ธ</summary>
```mdx
- โ ๏ธ SQL Lab schema list errors not shown to users.
- โ ๏ธ Schema tree silently fails when `/database/:id/tables/` errors.
```
</details>
```suggestion
.unwrap()
.then(data => {
dispatch({ type: 'SET_TABLE_DATA', key: schemaKey, data });
```
<details>
<summary><b>Steps of Reproduction โ
</b></summary>
```mdx
1. Open SQL Lab so the left sidebar mounts `SqlEditorLeftBar` at
`superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx:190-203`, which
renders `<TableExploreTree queryEditorId={activeQEId} />`.
2. In `TableExploreTree`
(`superset-frontend/src/SqlLab/components/TableExploreTree/index.tsx:68-99`), the `Tree`
component's `onToggle` handler calls `handleToggle(id, true)` from `useTreeData` when a
schema node is expanded.
3. `useTreeData`
(`superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts:200-237`)
handles schema expansion in `handleToggle`; when `identifier === 'schema'` and no cached
tables exist, it calls `fetchLazyTables({ dbId: parsedDbId, catalog, schema, forceRefresh:
false }, true).then(({ data }) => { ... }).catch(error => { dispatch({ type: 'SET_ERROR',
errorPayload: error?.errors?.[0] ?? null }); })` without `.unwrap()`.
4. If the backend `tables` endpoint `/api/v1/database/${dbId}/tables/` defined in
`superset-frontend/src/hooks/apiResources/tables.ts:101-117` fails (e.g., DB
misconfigured, network error), RTK Query's lazy trigger resolves with an object `{
isError, error }` instead of rejecting (as shown by how `useTables` uses
`trigger(...).then(({ isSuccess, isError, data, error }) => ...)` at `tables.ts:51-60`),
so `catch` in `handleToggle` is never invoked and `errorPayload` in `useTreeData` remains
`null`, meaning the `<ErrorMessageWithStackTrace>` in `TableExploreTree`
(`index.tsx:49-51`) is never shown and schema load failures are silently ignored.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts%0A%2A%2ALine%3A%2A%2A%20218%3A218%0A%2A%2AComment%3A%2A%2A%0A%09%2APossible%20Bug%3A%20This%20lazy%20query%20still%20relies%20on%20%60.catch%28%29%60%20without%20calling%20%60.unwrap%28%29%60%2C%20so%20RTK%20Query%20failures%20resolve%20as%20%60%7B%20error%20%7D%60%20and%20bypass%20the%20error%20handler.%20Use%20%60.unwrap%28%29%60%20so%20request%20failures%20actually%20reject%20and%20populate%20%60errorPayload%60%20correctly.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20lef
t%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts%0A%2A%2ALine%3A%2A%2A%20218%3A218%0A%2A%2AComment%3A%2A%2A%0A%09%2APossible%20Bug%3A%20This%20lazy%20query%20still%20relies%20on%20%60.catch%28%29%60%20without%20calling%20%60.unwrap%28%29%60%2C%20so%20RTK%20Query%20failures%20resolve%20as%20%60%7B%20error%20%7D%60%20and%20bypass%20the%20error%20handler.%20Use%20%60.unwrap%28%29%60%20so%20request%20failures%20actually%20reject%20and%20populate%20%60errorPayload%60%20correctly.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A)
*(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/src/SqlLab/components/TableExploreTree/useTreeData.ts
**Line:** 218:218
**Comment:**
*Possible Bug: This lazy query still relies on `.catch()` without calling `.unwrap()`, so RTK Query failures resolve as `{ error }` and bypass the error handler. Use `.unwrap()` so request failures actually reject and populate `errorPayload` correctly.
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.
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=bccd5bc3370fea989f32911293331dcb6e642606deedeeac2a81f283e0e4e085&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=bccd5bc3370fea989f32911293331dcb6e642606deedeeac2a81f283e0e4e085&reaction=dislike'>๐</a>
##########
superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts:
##########
@@ -289,6 +296,19 @@ const useTreeData = ({
[fetchLazyTables],
);
+ const refreshTableSchema = useCallback(
+ (id: string) => {
+ const parts = id.split(':');
+ const [, databaseId, schema, table] = parts;
+ const parsedDbId = Number(databaseId);
+ const tableKey = `${parsedDbId}:${schema}:${table}`;
+
+ dispatch({ type: 'CLEAR_TABLE_SCHEMA_DATA', key: tableKey });
Review Comment:
**Suggestion:** Clearing cached table schema before confirming a successful refresh causes previously loaded columns to disappear permanently if the refresh fails. Keep existing metadata until fresh data is fetched successfully. [logic error]
<details>
<summary><b>Severity Level:</b> Major โ ๏ธ</summary>
```mdx
- โ ๏ธ Refreshing table schema can hide existing columns on error.
- โ ๏ธ Users temporarily lose last known table schema in sidebar.
```
</details>
```suggestion
```
<details>
<summary><b>Steps of Reproduction โ
</b></summary>
```mdx
1. Open SQL Lab so `SqlEditorLeftBar` renders `TableExploreTree`
(`superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx:190-203`), and expand
a schema/table so `handleToggle` in `useTreeData`
(`superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts:200-259`) loads
table metadata via `fetchAndStoreTableSchema(id, true)`, populating
`tableSchemaData[tableKey]` and causing columns to render in the tree.
2. Verify that for an unpinned table, `treeData` in `useTreeData`
(`useTreeData.ts:312-376`) derives `columnsData` from `tableSchemaData[tableKey] ??
pinnedTables[tableKey]` and uses it to build column child nodes; with metadata loaded, the
table shows its columns.
3. Click the "Refresh table schema" action for that table in the UI, which is wired in
`TreeNodeRenderer`
(`superset-frontend/src/SqlLab/components/TableExploreTree/TreeNodeRenderer.tsx:100-105`)
to call `refreshTableSchema(data.id)`. This executes `refreshTableSchema` in `useTreeData`
(`useTreeData.ts:299-308`), which first dispatches `{ type: 'CLEAR_TABLE_SCHEMA_DATA',
key: tableKey }`, immediately removing the cached metadata for that table before starting
`fetchAndStoreTableSchema(id, false)`.
4. If either `/api/v1/database/${dbId}/table_metadata/...` or
`/api/v1/database/${dbId}/table_metadata/extra/...` (defined in
`superset-frontend/src/hooks/apiResources/tables.ts:123-148`) fails during this refresh,
`fetchAndStoreTableSchema`'s `Promise.all(...).catch(() => addDangerToast(...))`
(`useTreeData.ts:161-191`) shows a danger toast but never restores the cleared
`tableSchemaData[tableKey]`, so `treeData` now sees `columnsData` as `undefined` and
renders the table with no columns (and `disableCheckbox: true`) until the user toggles it
again to trigger another load, effectively dropping the last known good schema on a failed
refresh.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts%0A%2A%2ALine%3A%2A%2A%20306%3A306%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20Clearing%20cached%20table%20schema%20before%20confirming%20a%20successful%20refresh%20causes%20previously%20loaded%20columns%20to%20disappear%20permanently%20if%20the%20refresh%20fails.%20Keep%20existing%20metadata%20until%20fresh%20data%20is%20fetched%20successfully.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset-frontend
%2Fsrc%2FSqlLab%2Fcomponents%2FTableExploreTree%2FuseTreeData.ts%0A%2A%2ALine%3A%2A%2A%20306%3A306%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20Clearing%20cached%20table%20schema%20before%20confirming%20a%20successful%20refresh%20causes%20previously%20loaded%20columns%20to%20disappear%20permanently%20if%20the%20refresh%20fails.%20Keep%20existing%20metadata%20until%20fresh%20data%20is%20fetched%20successfully.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0A)
*(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/src/SqlLab/components/TableExploreTree/useTreeData.ts
**Line:** 306:306
**Comment:**
*Logic Error: Clearing cached table schema before confirming a successful refresh causes previously loaded columns to disappear permanently if the refresh fails. Keep existing metadata until fresh data is fetched successfully.
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.
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=5c5b09f42e7bfaa03c81ef48b73a605359e5a70597a3e460578f96745feaa3d6&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39396&comment_hash=5c5b09f42e7bfaa03c81ef48b73a605359e5a70597a3e460578f96745feaa3d6&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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4268342812
CodeAnt AI is running the review.
---
### Thanks for using CodeAnt! ๐
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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(sqllab): enhance table explore tree with schema pinning, column sorting, and table schema refresh [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39396:
URL: https://github.com/apache/superset/pull/39396#issuecomment-4256705996
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