GitHub user dosubot[bot] added a comment to the discussion: Warm up charts 
cache via API

<!-- Answer -->
This error occurs because warm_up_cache and normal chart rendering process 
filters/context differently. The [post-processing 
validation](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/pandas_postprocessing/utils.py#L114-L133)
 checks that columns referenced in operations like `pivot`, `rename`, and 
`contribution` exist in the DataFrame — but the DataFrame returned during 
warm_up_cache may be different from normal rendering.

**Why this happens:**

[Filter context isn't always propagated correctly during warm_up_cache for 
non-legacy (query_context-based) 
charts](https://github.com/apache/superset/discussions/34979#discussioncomment-14279806).
 This can cause:
- Different SQL queries to execute
- Different columns returned in the DataFrame  
- Post-processing operations failing because expected columns are missing

**Options:**

1. **Upgrade Superset** — [PR 
#36109](https://github.com/apache/superset/pull/36109) fixed dashboard filter 
application for non-legacy visualizations during cache warm-up. If you're on an 
older version, upgrading may resolve this.

2. **Simplify post_processing** — Your query_context has `pivot`, `rename`, 
`contribution`, and `flatten` operations. If the warm_up_cache returns an empty 
or differently-structured DataFrame, these operations fail. Try removing or 
simplifying post_processing operations in your query_context.

3. **Pass dashboard_id** — When calling warm_up_cache, include the 
`dashboard_id` parameter to help propagate filter context:
   ```json
   {"chart_id": 803, "dashboard_id": 275}
   ```

4. **Suppress the error** — If the chart works fine for actual users and you 
just want cache warming as best-effort, you could catch and log this error in 
your client code rather than treating it as fatal.

The root cause is a mismatch between how your query_context post-processing 
expects data vs what warm_up_cache returns without full context.


<!-- Dosu Comment Footer -->
*To reply, just mention 
[@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/991e2e50-d268-441b-a4aa-d6a2eff1a335?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/991e2e50-d268-441b-a4aa-d6a2eff1a335?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/991e2e50-d268-441b-a4aa-d6a2eff1a335?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/991e2e50-d268-441b-a4aa-d6a2eff1a335?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose)
 | [Hallucination](https://app.dosu.dev/response-feedback/991e2e50-d268-44
 
1b-a4aa-d6a2eff1a335?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/991e2e50-d268-441b-a4aa-d6a2eff1a335?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/991e2e50-d268-441b-a4aa-d6a2eff1a335?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20error%20occurs%20because%20warm_up_cache%20and%20normal%20chart%20rendering%20process%20filters/context%20differently.%20The%20%5Bpost-processing%20validation%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/pandas_postprocessing/utils.py%23L114-L133%29%20checks%20that%20columns%20referenced%20in%20operations%20like%20%60pivot%60%2C%20%60rename%60%2C%20and%20%60contribution%60%20exist%20in%20the%20DataFrame%20%E2%80%94%20but%20the%20DataFrame%20returned%20during%20warm_up_cache%20may%20be%20different%20from%20normal%20rendering.%0A%0A%2A%2AWhy%20this%20happens%3A%2A%2A%0A%0A%5BFilter%20context%20isn%27t%20always%20pr
 
opagated%20correctly%20during%20warm_up_cache%20for%20non-legacy%20%28query_context-based%29%20charts%5D%28https%3A//github.com/apache/superset/discussions/34979%23discussioncomment-14279806%29.%20This%20can%20cause%3A%0A-%20Different%20SQL%20queries%20to%20execute%0A-%20Different%20columns%20returned%20in%20the%20DataFrame%20%20%0A-%20Post-processing%20operations%20failing%20because%20expected%20columns%20are%20missing%0A%0A%2A%2AOptions%3A%2A%2A%0A%0A1.%20%2A%2AUpgrade%20Superset%2A%2A%20%E2%80%94%20%5BPR%20%2336109%5D%28https%3A//github.com/apache/superset/pull/36109%29%20fixed%20dashboard%20filter%20application%20for%20non-legacy%20visualizations%20during%20cache%20warm-up.%20If%20you%27re%20on%20an%20older%20version%2C%20upgrading%20may%20resolve%20this.%0A%0A2.%20%2A%2ASimplify%20post_processing%2A%2A%20%E2%80%94%20Your%20query_context%20has%20%60pivot%60%2C%20%60rename%60%2C%20%60contribution%60%2C%20and%20%60flatten%60%20operations.%20If%20the%20warm_up_cache%20returns%20an%
 
20empty%20or%20differently-structured%20DataFrame%2C%20these%20operations%20fail.%20Try%20removing%20or%20simplifying%20post_processing%20operations%20in%20your%20query_context.%0A%0A3.%20%2A%2APass%20dashboard_id%2A%2A%20%E2%80%94%20When%20calling%20warm_up_cache%2C%20include%20the%20%60dashboard_id%60%20parameter%20to%20help%20propagate%20filter%20context%3A%0A%20%20%20%60%60%60json%0A%20%20%20%7B%22chart_id%22%3A%20803%2C%20%22dashboard_id%22%3A%20275%7D%0A%20%20%20%60%60%60%0A%0A4.%20%2A%2ASuppress%20the%20error%2A%2A%20%E2%80%94%20If%20the%20chart%20works%20fine%20for%20actual%20users%20and%20you%20just%20want%20cache%20warming%20as%20best-effort%2C%20you%20could%20catch%20and%20log%20this%20error%20in%20your%20client%20code%20rather%20than%20treating%20it%20as%20fatal.%0A%0AThe%20root%20cause%20is%20a%20mismatch%20between%20how%20your%20query_context%20post-processing%20expects%20data%20vs%20what%20warm_up_cache%20returns%20without%20full%20context.)&nbsp;[![Join
 Discord](http
 
s://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/38718)

GitHub link: 
https://github.com/apache/superset/discussions/38718#discussioncomment-16260282

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


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

Reply via email to