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

[PR] fix(SqlLab): Hit tableschemaview with a valid queryEditorId [superset]

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

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   An error on screen was firing up all the time a table was selected for a newly created Tab in Sql Lab. This PR fixes the issue by ensuring that the tableschemaview/ endpoint always receives a valid `queryEditorId`.
   
   ### BEFORE
   
   https://github.com/user-attachments/assets/b66bb571-735b-4a33-b64e-abbc06ce09a5
   
   ### AFTER
   
   https://github.com/user-attachments/assets/cb3a2a1a-f066-4360-9c76-65620637cdc2
   
   
   ### TESTING INSTRUCTIONS
   1. Enter SQL Lab
   2. Open a new Tab
   3. Select a db, schema, and table
   4. The table preview should load with no errors
   
   ### 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): Hit tableschemaview with a valid queryEditorId [superset]

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


##########
superset-frontend/src/SqlLab/components/TableElement/index.tsx:
##########
@@ -103,6 +103,19 @@ const TableElement = ({ table, ...props }: TableElementProps) => {
     },
     { skip: !expanded },
   );
+  const tableData = {
+    ...tableMetadata,
+    ...tableExtendedMetadata,
+  };
+  const queryEditors = useSelector<SqlLabRootState, QueryEditor[]>(
+    state => state.sqlLab.queryEditors,
+  );

Review Comment:
   ### Inefficient Redux selector fetching entire array <sub>![category Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The useSelector hook is called on every render to fetch the entire queryEditors array from Redux state, even when only one specific query editor is needed.
   
   
   ###### Why this matters
   This causes unnecessary re-renders and memory allocation when the queryEditors array changes, even if the specific query editor being used hasn't changed. The component will re-render whenever any query editor in the array is modified.
   
   ###### Suggested change ∙ *Feature Preview*
   Use a memoized selector that only returns the specific query editor needed:
   
   ```typescript
   const queryEditor = useSelector<SqlLabRootState, QueryEditor | undefined>(
     state => state.sqlLab.queryEditors.find(
       qe => qe.id === table.queryEditorId || qe.tabViewId === table.queryEditorId
     ),
     (left, right) => left?.tabViewId === right?.tabViewId
   );
   ```
   
   Then remove the separate `find` operation and use `queryEditor` directly.
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/19cf6543-7cb6-44b3-8a2c-78325eafc676/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/19cf6543-7cb6-44b3-8a2c-78325eafc676?what_not_true=true)  [![Not in Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/19cf6543-7cb6-44b3-8a2c-78325eafc676?what_out_of_scope=true) [![Not in coding standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/19cf6543-7cb6-44b3-8a2c-78325eafc676?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/19cf6543-7cb6-44b3-8a2c-78325eafc676)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:1e80ea00-d9d4-4f50-8df8-655a6ed5ccd9 -->
   
   
   [](1e80ea00-d9d4-4f50-8df8-655a6ed5ccd9)



-- 
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): Hit tableschemaview with a valid queryEditorId [superset]

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


-- 
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