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

[PR] fix(SQL Lab): syncTable on new tabs [superset]

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

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   After https://github.com/apache/superset/pull/34720 the `syncTable` calls to `/tableschemaview/` fails on new tabes because it passes the old `queryEditorId` (a random string) instead of the integer ID.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### 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(SQL Lab): syncTable on new tabs [superset]

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


-- 
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(SQL Lab): syncTable on new tabs [superset]

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


##########
superset-frontend/src/SqlLab/actions/sqlLab.js:
##########
@@ -956,7 +956,7 @@ export function addTable(queryEditor, tableName, catalogName, schemaName) {
     const { dbId } = getUpToDateQuery(getState(), queryEditor, queryEditor.id);
     const table = {
       dbId,
-      queryEditorId: queryEditor.id,
+      queryEditorId: queryEditor.tabViewId ?? queryEditor.id,

Review Comment:
   ### Inconsistent queryEditorId assignment breaks table-query editor association <sub>![category Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The addTable function uses tabViewId as queryEditorId but other parts of the codebase expect queryEditorId to match the actual queryEditor.id for proper state management and query association.
   
   
   ###### Why this matters
   This inconsistency can cause tables to be associated with the wrong query editor ID, leading to broken functionality when tables are referenced by other parts of the system that expect queryEditorId to match the queryEditor's actual ID. This could result in tables not appearing in the correct tabs or being inaccessible.
   
   ###### Suggested change ∙ *Feature Preview*
   The code should maintain consistency with how queryEditorId is used throughout the system. If tabViewId is needed for backend persistence, it should be handled separately or the entire codebase should be updated to use tabViewId consistently. Consider using:
   
   ```javascript
   queryEditorId: queryEditor.id,
   tabViewId: queryEditor.tabViewId,
   ```
   
   Or ensure all related functions that reference queryEditorId are updated to handle the tabViewId fallback pattern.
   
   
   ###### 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/a4360247-a330-4ec5-b398-263fc8541870/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/a4360247-a330-4ec5-b398-263fc8541870?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/a4360247-a330-4ec5-b398-263fc8541870?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/a4360247-a330-4ec5-b398-263fc8541870?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/a4360247-a330-4ec5-b398-263fc8541870)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:5dd0e9ae-25e6-4f38-99b1-fad98b42ae14 -->
   
   
   [](5dd0e9ae-25e6-4f38-99b1-fad98b42ae14)



##########
superset-frontend/src/SqlLab/components/AceEditorWrapper/useKeywords.ts:
##########
@@ -147,7 +148,12 @@ export function useKeywords(
   const insertMatch = useEffectEvent((editor: Editor, data: any) => {
     if (data.meta === 'table') {
       dispatch(
-        addTable({ id: queryEditorId, dbId }, data.value, catalog, schema),
+        addTable(
+          { id: queryEditorId, dbId, tabViewId },
+          data.value,
+          catalog,
+          schema,
+        ),
       );
     }

Review Comment:
   ### Function with Mixed Responsibilities <sub>![category Design](https://img.shields.io/badge/Design-0d9488)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The insertMatch function handles multiple responsibilities: table insertion, caption formatting, and editor completion. This violates the Single Responsibility Principle.
   
   
   ###### Why this matters
   Mixed responsibilities make the code harder to maintain, test, and modify. Changes to one aspect might affect others unexpectedly.
   
   ###### Suggested change ∙ *Feature Preview*
   Split the function into smaller, focused functions:
   ```typescript
   const handleTableInsertion = (data: TableData) => {
     dispatch(addTable({ id: queryEditorId, dbId, tabViewId }, data.value, catalog, schema));
   };
   
   const formatCaption = (data: CompletionData) => {
     return data.meta === 'table' && data.caption.includes(' ') ? `"${data.caption}"` : data.caption;
   };
   
   const insertMatch = useEffectEvent((editor: Editor, data: CompletionData) => {
     if (data.meta === 'table') {
       handleTableInsertion(data);
     }
     const caption = formatCaption(data);
     editor.completer.insertMatch(`${caption}${['function', 'schema'].includes(data.meta) ? '' : ' '}`);
   });
   ```
   
   
   ###### 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/31198c54-1f3b-4229-9df0-10d8ccce30d2/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/31198c54-1f3b-4229-9df0-10d8ccce30d2?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/31198c54-1f3b-4229-9df0-10d8ccce30d2?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/31198c54-1f3b-4229-9df0-10d8ccce30d2?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/31198c54-1f3b-4229-9df0-10d8ccce30d2)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:f79df6ce-b675-4db5-9bc3-a776adababba -->
   
   
   [](f79df6ce-b675-4db5-9bc3-a776adababba)



##########
superset-frontend/src/SqlLab/components/AceEditorWrapper/useKeywords.ts:
##########
@@ -147,7 +148,12 @@ export function useKeywords(
   const insertMatch = useEffectEvent((editor: Editor, data: any) => {
     if (data.meta === 'table') {
       dispatch(
-        addTable({ id: queryEditorId, dbId }, data.value, catalog, schema),
+        addTable(
+          { id: queryEditorId, dbId, tabViewId },
+          data.value,
+          catalog,
+          schema,
+        ),

Review Comment:
   ### Undefined tabViewId passed to addTable <sub>![category Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The addTable action is called with tabViewId even when it might be undefined, potentially causing inconsistent behavior in table association logic.
   
   
   ###### Why this matters
   If tabViewId is undefined, the addTable action may not properly associate the table with the correct tab, leading to tables being added to the wrong tab or causing state management issues in multi-tab scenarios.
   
   ###### Suggested change ∙ *Feature Preview*
   Add a conditional check to ensure tabViewId is only passed when it has a valid value:
   
   ```typescript
   addTable(
     tabViewId 
       ? { id: queryEditorId, dbId, tabViewId }
       : { id: queryEditorId, dbId },
     data.value,
     catalog,
     schema,
   ),
   ```
   
   
   ###### 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/dfa5a85b-4044-49f1-9b10-da63d1836106/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/dfa5a85b-4044-49f1-9b10-da63d1836106?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/dfa5a85b-4044-49f1-9b10-da63d1836106?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/dfa5a85b-4044-49f1-9b10-da63d1836106?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/dfa5a85b-4044-49f1-9b10-da63d1836106)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:8ce0dfc7-bc57-437e-a43c-b4f9f0f765bb -->
   
   
   [](8ce0dfc7-bc57-437e-a43c-b4f9f0f765bb)



-- 
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(SQL Lab): syncTable on new tabs [superset]

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

   Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment `/korbit-review`.
   
   > Your admin can change your review schedule in the [Korbit Console](https://app.korbit.ai/settings)
   
   
   
   [](6134e5cc-af91-4bbf-b6cf-7bb0accc289e)


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