-
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
feat(cross-filters): add support for temporal filters #16139
Conversation
time_grain = extras.get("time_grain_sqla") | ||
dttm_col = columns_by_name.get(granularity) if granularity else None |
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.
These are moved up in the code as they are needed earlier now
41c9ba7
to
dc6e4ed
Compare
def mock_to_adhoc(filt, expressionType="SIMPLE", clause="where"): | ||
result = {"clause": clause.upper(), "expressionType": expressionType} | ||
|
||
if expressionType == "SIMPLE": | ||
result.update( | ||
{"comparator": filt["val"], "operator": filt["op"], "subject": filt["col"]} | ||
) | ||
elif expressionType == "SQL": | ||
result.update({"sqlExpression": filt[clause]}) | ||
|
||
return result | ||
|
||
|
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.
Having a mock like this felt unnecessary and dangerous, as it's mostly the same as the original function + the logic associated with conversion between regular and adhoc metrics is already brittle. Therefore this mock is removed and the assertions updated to reflect what is actually expected to be returned when running the full chain of convert_legacy_filters_into_adhoc
, merge_extra_filters
and split_adhoc_filters_into_base_filters
.
Codecov Report
@@ Coverage Diff @@
## master #16139 +/- ##
==========================================
- Coverage 76.83% 76.71% -0.13%
==========================================
Files 995 996 +1
Lines 52884 52954 +70
Branches 6721 6725 +4
==========================================
- Hits 40636 40626 -10
- Misses 12023 12103 +80
Partials 225 225
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
7f46076
to
37ed386
Compare
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.
Nice improvement! Left some nit picking comments, looks good after conflicts are fixed
78ce73e
to
7f11b86
Compare
/testenv up FEATURE_DASHBOARD_NATIVE_FILTERS=true FEATURE_DASHBOARD_CROSS_FILTERS=true |
@villebro Ephemeral environment spinning up at http://34.212.190.175:8080. Credentials are |
FYI this doesn't work properly with SQLite yet due to the dates being strings. If it's important to add support for SQLite I can add that - otherwise I propose leaving it to a follow-up PR for a rainy day. |
Ephemeral environment shutdown and build artifacts deleted. |
🏷 2021.31 |
* feat(cross-filters): add support for temporal filters * fix test * make filter optional * remove mocks * fix more tests * remove unnecessary optionality * fix even more tests * bump superset-ui * add isExtra to schema * address comments * fix presto test (cherry picked from commit 63ace7b)
* feat(cross-filters): add support for temporal filters * fix test * make filter optional * remove mocks * fix more tests * remove unnecessary optionality * fix even more tests * bump superset-ui * add isExtra to schema * address comments * fix presto test (cherry picked from commit 63ace7b)
* feat(cross-filters): add support for temporal filters * fix test * make filter optional * remove mocks * fix more tests * remove unnecessary optionality * fix even more tests * bump superset-ui * add isExtra to schema * address comments * fix presto test
* feat(cross-filters): add support for temporal filters * fix test * make filter optional * remove mocks * fix more tests * remove unnecessary optionality * fix even more tests * bump superset-ui * add isExtra to schema * address comments * fix presto test (cherry picked from commit 63ace7b)
* feat(cross-filters): add support for temporal filters * fix test * make filter optional * remove mocks * fix more tests * remove unnecessary optionality * fix even more tests * bump superset-ui * add isExtra to schema * address comments * fix presto test
* feat(cross-filters): add support for temporal filters * fix test * make filter optional * remove mocks * fix more tests * remove unnecessary optionality * fix even more tests * bump superset-ui * add isExtra to schema * address comments * fix presto test (cherry picked from commit 63ace7b)
* feat(cross-filters): add support for temporal filters * fix test * make filter optional * remove mocks * fix more tests * remove unnecessary optionality * fix even more tests * bump superset-ui * add isExtra to schema * address comments * fix presto test (cherry picked from commit f042910)
SUMMARY
Add support for time grain based native-filters and cross-filters. The frontend work is done in apache-superset/superset-ui#1281 (this PR can be merged independently of that PR, as it only adds backend support for the feature). Other changes:
TypedDict
s forAdhocFilterClause
andQueryObjectFilterClause
and implement necessary changes where we were previously assuming filters wereDict[str, Any]
.to_adhoc
function intosimple_filter_to_adhoc
andform_data_to_adhoc
, as the previous implementation was mixing filter objects with form data. Also fix affected tests + remove a mock that is deemed unnecessary.ADDITIONAL INFORMATION