codeant-ai-for-open-source[bot] commented on code in PR #42953:
URL: https://github.com/apache/superset/pull/42953#discussion_r3746123417
##########
docs/admin_docs/configuration/cache.mdx:
##########
@@ -134,6 +134,43 @@ CELERY_CONFIG = CustomCeleryConfig
This will cache the top 5 most popular dashboards every hour. For other
strategies, check the `superset/tasks/cache.py` file.
+### Warming Up Native Filter Options
+
+Native filter Value-type dropdown option queries (e.g. `SELECT DISTINCT column
FROM table`) are
+cached the same way as chart data, via `DATA_CACHE_CONFIG`. However, the
strategies above only warm
+up chart render queries, so the first user to open a dashboard's filter
dropdown after a cache entry
+expires still triggers a fresh database query.
+
+The `native_filter_options` strategy pre-populates the cache for these
dropdown queries. It reads
+each dashboard's `native_filter_configuration`, builds the same
`filter_select` chart-data query the
+frontend would send, and executes it as the configured
`SUPERSET_CACHE_WARMUP_USER`:
+
+```python
+class CustomCeleryConfig(CeleryConfig):
+ beat_schedule = {
+ **CeleryConfig.beat_schedule,
+ 'cache-warmup-native-filters': {
+ 'task': 'cache-warmup',
+ 'schedule': crontab(minute=0, hour=3), # daily at 03:00
+ 'kwargs': {
+ 'strategy_name': 'native_filter_options',
+ 'dashboard_ids': [1, 2, 3],
+ },
+ },
+ }
+```
+
+Requirements and limitations:
+
+- `SUPERSET_CACHE_WARMUP_USER` must be set to a user with access to the
dashboards and datasets
+ referenced by the native filters.
+- `DATA_CACHE_CONFIG` must be configured (Redis recommended).
Review Comment:
**Suggestion:** Requiring only that `DATA_CACHE_CONFIG` be configured is
insufficient to make this strategy effective. A configured `NullCache`, an
effective timeout of `-1`, or `NATIVE_FILTER_OPTIONS_CACHE_TIMEOUT = -1`
disables reusable cache writes, so the scheduled task still executes database
queries without warming anything. Document that the effective cache backend
must support storage and that the applicable timeout must be positive. [api
mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Default `NullCache` produces no warmed native-filter entries.
- ⚠️ Disabled timeouts still consume datasource query capacity.
- ⚠️ Users continue receiving cold dropdown queries.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=50e8d891440040a888990102367b8ee1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=50e8d891440040a888990102367b8ee1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** docs/admin_docs/configuration/cache.mdx
**Line:** 167:167
**Comment:**
*Api Mismatch: Requiring only that `DATA_CACHE_CONFIG` be configured is
insufficient to make this strategy effective. A configured `NullCache`, an
effective timeout of `-1`, or `NATIVE_FILTER_OPTIONS_CACHE_TIMEOUT = -1`
disables reusable cache writes, so the scheduled task still executes database
queries without warming anything. Document that the effective cache backend
must support storage and that the applicable timeout must be positive.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42953&comment_hash=a163af9f909f447af3d3551d314d957f91c33649916eb7dd0f6c94398795421b&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42953&comment_hash=a163af9f909f447af3d3551d314d957f91c33649916eb7dd0f6c94398795421b&reaction=dislike'>👎</a>
##########
docs/admin_docs/configuration/cache.mdx:
##########
@@ -134,6 +134,43 @@ CELERY_CONFIG = CustomCeleryConfig
This will cache the top 5 most popular dashboards every hour. For other
strategies, check the `superset/tasks/cache.py` file.
+### Warming Up Native Filter Options
+
+Native filter Value-type dropdown option queries (e.g. `SELECT DISTINCT column
FROM table`) are
+cached the same way as chart data, via `DATA_CACHE_CONFIG`. However, the
strategies above only warm
+up chart render queries, so the first user to open a dashboard's filter
dropdown after a cache entry
+expires still triggers a fresh database query.
+
+The `native_filter_options` strategy pre-populates the cache for these
dropdown queries. It reads
+each dashboard's `native_filter_configuration`, builds the same
`filter_select` chart-data query the
+frontend would send, and executes it as the configured
`SUPERSET_CACHE_WARMUP_USER`:
+
+```python
+class CustomCeleryConfig(CeleryConfig):
+ beat_schedule = {
+ **CeleryConfig.beat_schedule,
+ 'cache-warmup-native-filters': {
+ 'task': 'cache-warmup',
+ 'schedule': crontab(minute=0, hour=3), # daily at 03:00
Review Comment:
**Suggestion:** The daily schedule does not guarantee that warmed entries
remain valid until the next run. Chart, dataset, database, `DATA_CACHE_CONFIG`,
and `NATIVE_FILTER_OPTIONS_CACHE_TIMEOUT` settings can specify a shorter TTL,
so operators following this example can still get cache misses for most of the
day. Document that the schedule must be at least as frequent as the effective
native-filter cache timeout, or use a suitably frequent schedule in the
example. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Native filter dropdowns can miss cache most of each day.
- ⚠️ Expired entries trigger repeated datasource queries.
- ⚠️ Cache warm-up benefits depend on configured TTL values.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=be28bad34fc0491d98de113f8e6f8885&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=be28bad34fc0491d98de113f8e6f8885&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** docs/admin_docs/configuration/cache.mdx
**Line:** 154:154
**Comment:**
*Logic Error: The daily schedule does not guarantee that warmed entries
remain valid until the next run. Chart, dataset, database, `DATA_CACHE_CONFIG`,
and `NATIVE_FILTER_OPTIONS_CACHE_TIMEOUT` settings can specify a shorter TTL,
so operators following this example can still get cache misses for most of the
day. Document that the schedule must be at least as frequent as the effective
native-filter cache timeout, or use a suitably frequent schedule in the example.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42953&comment_hash=cd6ed518ea7d846aee9dab97a10c95d9f86b5182f7b49c2baaeeadac88833475&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42953&comment_hash=cd6ed518ea7d846aee9dab97a10c95d9f86b5182f7b49c2baaeeadac88833475&reaction=dislike'>👎</a>
--
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]