Repository navigation
feat(time-range-limits): add time range limits for chart queries - #46038
Open
DamianPendrak wants to merge 3 commits into
Open
DamianPendrak wants to merge 3 commits into
DamianPendrak wants to merge 3 commits into
Conversation
DamianPendrak
requested review from
geido,
michael-s-molina,
msyavuz,
rusackas,
sadpandajoe and
villebro
as code owners
November 5, 2026 14:47
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #46038 +/- ##
==========================================
+ Coverage 85.03% 85.52% +0.48%
==========================================
Files 3080 3123 +43
Lines 209507 216959 +7452
Branches 49391 51388 +1997
==========================================
+ Hits 178164 185547 +7383
- Misses 27963 27992 +29
- Partials 3380 3420 +40
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Add time range limits for chart queries: a longest range (
max_span), earliest start (max_look_back), and latest end (max_look_forward). Deployment config sets the global policy; dataset and dashboard editors can add stricter limits. The strictest applicable rule wins.TIME_RANGE_LIMITSis off by default. With it on, the server checks before cache lookup, async execution, or SQL. An out-of-range or unbounded chart query returns HTTP 400 withTIME_RANGE_LIMIT_ERROR(issue 1042); an invalid applicable stored policy fails closed with HTTP 503.time_range_limitskey behave as before. Limit-specific write validation is bypassed, so supplied metadata can be stored unchecked. Review stored policies before turning the flag on; invalid applicable policies then fail closed.Shared-code changes:
ImportExportMixinfind-existing lookup helpers centralize matching for import validation, including existing rows that a policy may overwrite.common/utils/time_range_utils.pyso query building and limit checks use the same offset handling.Upgrade: Run
superset initto register the newTimeRangeLimitspermission and admin menu item. No database migration is required.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
superset_config.py, enableFEATURE_FLAGS["TIME_RANGE_LIMITS"] = Trueand setTIME_RANGE_LIMITS_GLOBAL = {"schema_version": 1, "max_span": {"quantity": 3, "time_grain": "P1M"}, "max_look_back": {"quantity": 13, "time_grain": "P1M"}, "max_look_forward": {"quantity": 0, "time_grain": "P1D"}}. Restart Superset and runsuperset init.POLICY_UNAVAILABLE. Turn the flag off and confirm chart queries are unaffected and the time range limits endpoints return 404.pytest tests/unit_tests/utils/test_time_range_enforcement.py tests/unit_tests/utils/test_time_range_limits.py tests/unit_tests/utils/test_time_range_save_check.py tests/integration_tests/time_range_limits_tests.py. Run focused frontend tests fromsuperset-frontend:npm run test -- timeRangeLimits.test.ts TimeRangeLimitsSection.test.tsx TimeRangeLimits.test.tsx.ADDITIONAL INFORMATION
TIME_RANGE_LIMITS