-
Notifications
You must be signed in to change notification settings - Fork 15k
fix(template_processing): get_filters now works for IS_NULL and IS_NOT_NULL operators #33296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
Category | Issue | Status |
---|---|---|
Unclear Boolean Expression Layout ▹ view |
Files scanned
File Path | Reviewed |
---|---|
superset/jinja_context.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
superset/jinja_context.py
Outdated
and ( | ||
val | ||
or | ||
# IS_NULL and IS_NOT_NULL operators do not have a value | ||
op in ( | ||
FilterOperator.IS_NULL.value, | ||
FilterOperator.IS_NOT_NULL.value, | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear Boolean Expression Layout 
Tell me more
What is the issue?
The boolean expression is split across multiple lines in a way that makes it harder to read, with the 'or' operator dangling on its own line.
Why this matters
Having logical operators on separate lines makes it difficult to quickly scan and understand the boolean logic flow.
Suggested change ∙ Feature Preview
and (val or op in (FilterOperator.IS_NULL.value,
FilterOperator.IS_NOT_NULL.value))
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree that this is an improvement, but happy to change if a more senior contributor does think so!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. The current format does provide clear logical grouping. Let's keep it as is unless senior contributors indicate otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not me talking to an AI: after the ruff-format fix maybe the final logic is a bit too expanded but I'll leave it to a reviewer to decide on what formatting should be used. At least now it's passing the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #33296 +/- ##
===========================================
+ Coverage 0 83.28% +83.28%
===========================================
Files 0 553 +553
Lines 0 39936 +39936
===========================================
+ Hits 0 33259 +33259
- Misses 0 6677 +6677
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:
|
@sfirke Pre-commit now runs successfully locally :) |
I tagged a few committers who I believe are familiar with the Jinja internals. Hopefully one of them can take a quick look and we can get this merged! |
SUMMARY
The macro
get_filters
within the Jinja context can be used to implement filtering in custom locations in your virtual dataset SQL. This works great, except for when filtering with the IS_NULL or IS_NOT_NULL operator. These are ignored, cannot be used, and will break certain implementations that rely on remove_filter to be functional (like the one I've outlined below).The reason the code breaks for these operators is because they are unique in the sense that they don't have a comparator. Adjusting the code to not need a comparator for these operator types fixes the issue.
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION