You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2025/07/29 07:16:08 UTC

(superset) branch histogram_backend created (now 01ea023460)

This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a change to branch histogram_backend
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 01ea023460 feat(charts): Enable async buildQuery support for complex chart logic

This branch includes the following new commits:

     new 01ea023460 feat(charts): Enable async buildQuery support for complex chart logic

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: feat(charts): Enable async buildQuery support for complex chart logic

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch histogram_backend
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 01ea0234603498319ed9ad7a99ab7642ed63f8b0
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Tue Jul 29 00:15:18 2025 -0700

    feat(charts): Enable async buildQuery support for complex chart logic
    
    This foundational change allows chart plugins to perform asynchronous operations
    during the buildQuery phase while properly managing UI loading states.
    
    Key changes:
    - Move CHART_UPDATE_STARTED dispatch before buildQuery execution in chartAction.js
    - Make buildV1ChartDataPayload async and await buildQuery results
    - Ensure loading spinner shows during async buildQuery operations
    
    Benefits:
    - Chart plugins can now perform multi-phase queries (e.g., fetch min/max then build histogram bins)
    - Plugins can make API calls to determine query structure dynamically
    - Loading state is properly shown during longer-running buildQuery operations
    - Error handling works correctly with async buildQuery functions
    
    This change is backwards compatible - synchronous buildQuery functions continue
    to work as before. The async support opens doors for more sophisticated chart
    implementations like server-side histograms that require preliminary queries
    to determine bin ranges.
    
    Tested with 5-second delays and error throwing to verify both loading states
    and error propagation work correctly.
    
    Related to: #30330
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <no...@anthropic.com>
---
 superset-frontend/src/components/Chart/chartAction.js | 6 +++---
 superset-frontend/src/explore/exploreUtils/index.js   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/superset-frontend/src/components/Chart/chartAction.js b/superset-frontend/src/components/Chart/chartAction.js
index 10e45b385a..2a0bfa5ba9 100644
--- a/superset-frontend/src/components/Chart/chartAction.js
+++ b/superset-frontend/src/components/Chart/chartAction.js
@@ -164,7 +164,7 @@ const v1ChartDataRequest = async (
   ownState,
   parseMethod,
 ) => {
-  const payload = buildV1ChartDataPayload({
+  const payload = await buildV1ChartDataPayload({
     formData,
     resultType,
     resultFormat,
@@ -420,6 +420,8 @@ export function exploreJSON(
     const setDataMask = dataMask => {
       dispatch(updateDataMask(formData.slice_id, dataMask));
     };
+    dispatch(chartUpdateStarted(controller, formData, key));
+
     const chartDataRequest = getChartDataRequest({
       setDataMask,
       formData,
@@ -431,8 +433,6 @@ export function exploreJSON(
       ownState,
     });
 
-    dispatch(chartUpdateStarted(controller, formData, key));
-
     const [useLegacyApi] = getQuerySettings(formData);
     const chartDataRequestCaught = chartDataRequest
       .then(({ response, json }) =>
diff --git a/superset-frontend/src/explore/exploreUtils/index.js b/superset-frontend/src/explore/exploreUtils/index.js
index e26f693626..d8a4c253de 100644
--- a/superset-frontend/src/explore/exploreUtils/index.js
+++ b/superset-frontend/src/explore/exploreUtils/index.js
@@ -207,7 +207,7 @@ export const getQuerySettings = formData => {
   ];
 };
 
-export const buildV1ChartDataPayload = ({
+export const buildV1ChartDataPayload = async ({
   formData,
   force,
   resultFormat,