-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
fix: filter_values in jinja_context not processing adhoc_filters #9348
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9348 +/- ##
=======================================
Coverage 58.96% 58.96%
=======================================
Files 374 374
Lines 12137 12137
Branches 2992 2992
=======================================
Hits 7156 7156
Misses 4802 4802
Partials 179 179 Continue to review full report at Codecov.
|
return_val.append(v) | ||
else: | ||
return_val.append(f["val"]) | ||
for f in form_data.get("filters", {}): |
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 was working on filters recently and I'm pretty sure these are now under adhoc_filters
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.
This wan't completely familiar territory to me, so I might be wrong here. But currently process_query_filters()
in viz..py
, which is the first thing query_obj()
calls, goes through a long step of transformations that first changes everything into adhoc_filters
, and finally changes those to regular filters
. I'm unsure why this happens, but my takeaway was that if process_query_filters
is run, you are left with nothing but filters
, despite how they started out.
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.
Oh wow. This is confusing. Looks like you looked into it deeper than I have. 👍
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.
Probably something for the refactor backlog. I took another pass at how this works in practice, and these are my takeaways:
connectors/sqla/model.py
has no logic for handlingadhoc_metrics
, so all filters are expected to be in base filter form: https://github.com/apache/incubator-superset/blob/master/superset/connectors/sqla/models.py#L837-L877 . The same goes for the legacy Druid connector.QueryObject
used by the new Query API only supports base filters: https://github.com/apache/incubator-superset/blob/master/superset/common/query_object.py#L115 . I think we need to change this so thatadhoc_filters
are allowed in the constructor signature and are converted to base filters into_dict()
.
Anyway, in the short term, I think this fix is the right solution.
WOW , it works very well. Thank you @villebro <3 |
This is a great improvement, thank you again. |
@lilila I assume this is on the Public role? |
@mistercrunch is this ok to merge? |
Yes @villebro it is on public role. Thank you for your help |
@lilila I expect these are bugs that surface due to the Public role which isn't as frequently used as the regular ones. Would you mind opening issues for these, preferably one per problem? It will make it easier to identify and fix the bugs. Thanks! |
I'll do this
|
I'm closing this in favor of #9582 . |
CATEGORY
Choose one
SUMMARY
Currently the
filter_values
function injinja_context.py
is not able to processadhoc_filters
when a chart is rendered in the Explore View. This PR moves filter preprocessing logic fromviz.py
intoutlis/core.py
and applies said logic toform_data
in the Jinja context.TEST PLAN
Local testing + new and old tests
ADDITIONAL INFORMATION
REVIEWERS
@sahiljain001 @lilila