richardfogaca commented on code in PR #35683:
URL: https://github.com/apache/superset/pull/35683#discussion_r2670261236


##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts:
##########
@@ -481,6 +532,54 @@ const buildQuery: BuildQuery<TableChartFormData> = (
       }
     }
 
+    // Create totals query AFTER all filters (including AG Grid filters) are 
applied
+    // This ensures we can properly exclude AG Grid WHERE filters from the 
totals
+    if (
+      metrics?.length &&
+      formData.show_totals &&
+      queryMode === QueryMode.Aggregate
+    ) {
+      // Create a copy of extras without the AG Grid WHERE clause
+      // AG Grid filters in extras.where can reference calculated columns
+      // which aren't available in the totals subquery
+      const totalsExtras = { ...queryObject.extras };
+      if (ownState.agGridComplexWhere) {
+        // Remove AG Grid WHERE clause from totals query
+        const whereClause = totalsExtras.where;

Review Comment:
   the string replacement approach for removing AG Grid WHERE clauses could be 
fragile if the clause appears as a substring elsewhere or if whitespace varies. 
might be safer to track the AG Grid clause separately and build the totals 
WHERE clause from parts rather than parsing it out



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