fix: support nested function calls in cache_key_wrapper#38569
fix: support nested function calls in cache_key_wrapper#38569michael-s-molina merged 4 commits intoapache:masterfrom
Conversation
Sequence DiagramThis PR updates the ExtraCache regex so templated helper calls, including nested function calls, are detected and incorporated into query cache keys, reducing incorrect cache hits. The diagram shows how query execution now uses the updated detection when building cache keys. sequenceDiagram
participant Client
participant API
participant TemplateProcessor
participant ExtraCache
participant Cache
Client->>API: Run templated query
API->>TemplateProcessor: Render template and prepare cache key
TemplateProcessor->>ExtraCache: Scan template for cache helpers
ExtraCache->>ExtraCache: Match helper calls including nested functions
ExtraCache-->>TemplateProcessor: Indicate extra cache keys present
TemplateProcessor->>Cache: Build cache key with extra values
Cache-->>API: Return cached or fresh result
API-->>Client: Return query result
Generated by CodeAnt AI |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #38569 +/- ##
==========================================
- Coverage 65.01% 64.42% -0.60%
==========================================
Files 1817 2529 +712
Lines 72317 128889 +56572
Branches 23031 29707 +6676
==========================================
+ Hits 47020 83032 +36012
- Misses 25297 44413 +19116
- Partials 0 1444 +1444
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review Agent Run #2600f9
Actionable Suggestions - 2
-
tests/unit_tests/jinja_context_test.py - 1
- Parametrize decorator expects tuple not string · Line 1698-1699
-
tests/integration_tests/sqla_models_tests.py - 1
- Undefined Jinja function in test · Line 848-848
Review Details
-
Files reviewed - 3 · Commit Range:
c071f55..c071f55- superset/jinja_context.py
- tests/integration_tests/sqla_models_tests.py
- tests/unit_tests/jinja_context_test.py
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.
Documentation & Help
Code Review Agent Run #aa597bActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
@neuromantik33 please review if you have the time |
Sequence DiagramThis PR updates the ExtraCache regex so that nested Jinja helper calls (such as cache_key_wrapper wrapping another function) are detected and included when computing query cache keys, improving cache correctness for templated SQL. sequenceDiagram
participant User
participant TemplateProcessor
participant ExtraCache
participant Cache
User->>TemplateProcessor: Submit SQL with Jinja template
TemplateProcessor->>TemplateProcessor: Scan template with ExtraCache regex
alt helper calls found (including nested)
TemplateProcessor->>ExtraCache: Render helper calls and capture values
ExtraCache->>Cache: Append values to extra cache keys
end
TemplateProcessor-->>User: Return result using computed cache key
Generated by CodeAnt AI |
Code Review Agent Run #acb8a5Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
(cherry picked from commit a9def2f)
User description
SUMMARY
#30549 introduced a regression that caused nested function calls inside
cache_key_wrapper()to go undetected. This means, that while the following Jinja snippets were functionally identical, only the former was flagged as containing extra cache keys:{% set abc = myfunc() %} {{ cache_key_wrapper(abc) }}is the same as
{{ cache_key_wrapper(myfunc()) }}The change relaxes the regex to detect both cases correctly, and adds tests to catch a similar regression going forward.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
CodeAnt-AI Description
Detect nested templated function calls when computing extra cache keys
What Changed
Impact
✅ Fewer incorrect cache hits✅ More accurate cache key detection for templated queries✅ Fewer missed extra cache keys from nested function calls💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.