rusackas commented on code in PR #40037:
URL: https://github.com/apache/superset/pull/40037#discussion_r3222800537


##########
superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx:
##########
@@ -55,8 +56,12 @@ const ExploreCtasResultsButton = ({
   };
 
   const visualize = () => {
-    dispatch(createCtasDatasource(buildVizOptions))
-      .then((data: { table_id: number }) => {
+    (
+      dispatch(createCtasDatasource(buildVizOptions)) as unknown as Promise<{
+        table_id: number;
+      }>

Review Comment:
   Good catch — you're right that the cast was hiding a real contract drift. 
Fixed properly in a3e446d5b6:
   
   - `createCtasDatasource` now returns `Promise<{ table_id: number }>`, 
matching what `/api/v1/dataset/get_or_create/` actually returns per OpenAPI.
   - Normalized `result.table_id` → `{ id }` when dispatching 
`createDatasourceSuccess`, so its existing `{ id: number }` signature stays 
intact and `createDatasource` (the non-CTAS path) keeps working.
   - Removed the `as unknown as` cast in `ExploreCtasResultsButton` — 
`data.table_id` is now type-checked end to end.
   
   As a side effect this also fixes the latent runtime bug you flagged: 
`createDatasourceSuccess` was reading `data.id` from a payload that only had 
`table_id`, so the CTAS Explore flow has been silently building 
`"undefined__table"` as the datasource identifier.



##########
superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx:
##########
@@ -55,8 +56,12 @@ const ExploreCtasResultsButton = ({
   };
 
   const visualize = () => {
-    dispatch(createCtasDatasource(buildVizOptions))
-      .then((data: { table_id: number }) => {
+    (
+      dispatch(createCtasDatasource(buildVizOptions)) as unknown as Promise<{
+        table_id: number;
+      }>
+    )

Review Comment:
   Agreed — fixed in a3e446d5b6. The thunk now declares `Promise<{ table_id: 
number }>` to match the API response, and the call site no longer needs a cast. 
See the reply on the parallel codeant thread above for full details on the 
normalization through `createDatasourceSuccess`.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to