bito-code-review[bot] commented on code in PR #38153:
URL: https://github.com/apache/superset/pull/38153#discussion_r2836258307


##########
superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx:
##########
@@ -72,7 +74,35 @@ export const useResultsPane = ({
   useEffect(() => {
     // it's an invalid formData when gets a errorMessage
     if (errorMessage) return;
-    if (isRequest && cache.has(queryFormData)) {
+    if (!isRequest) return;
+
+    // Reuse chart data from Redux when available. The chart visualization
+    // query and the results query produce identical SQL on the backend,
+    // so there is no need for a separate network request.
+    if (
+      queriesResponse?.length &&
+      'colnames' in queriesResponse[0]
+    ) {
+      const mapped = queriesResponse.map(q => {
+        const result = q as ChartDataResponseResult;
+        return {
+          colnames: result.colnames,
+          coltypes: result.coltypes,
+          data: result.data,
+          rowcount: result.rowcount,

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Data format conversion missing</b></div>
   <div id="fix">
   
   The data mapping assigns result.data directly, but 
ChartDataResponseResult.data is an array of objects while 
QueryResultInterface.data expects an array of arrays. This causes incorrect 
table rendering when queriesResponse is used. Convert using 
result.colnames.map(col => row[col]) to ensure proper data format.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #1c535b</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: [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