-
Notifications
You must be signed in to change notification settings - Fork 14k
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: implement time grain in temporal filters #24035
Conversation
@@ -1945,7 +1958,6 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma | |||
inner_groupby_exprs = [] | |||
inner_select_exprs = [] | |||
for gby_name, gby_obj in groupby_series_columns.items(): | |||
label = get_column_name(gby_name) |
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.
bycatch - this variable was not used anywhere (apparently this function is so bloated nowadays that the linters just give up on it)
Codecov Report
@@ Coverage Diff @@
## master #24035 +/- ##
=======================================
Coverage 68.21% 68.22%
=======================================
Files 1941 1941
Lines 75259 75261 +2
Branches 8168 8168
=======================================
+ Hits 51341 51344 +3
+ Misses 21829 21828 -1
Partials 2089 2089
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -1353,6 +1363,7 @@ def get_timestamp_expression( | |||
""" | |||
Return a SQLAlchemy Core element representation of self to be used in a query. | |||
|
|||
:param column: column object |
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.
bycatch - missing docstring
"PT1S": "CAST({col} as TIMESTAMP)" " - MICROSECOND({col}) MICROSECONDS", | ||
"PT1S": "CAST({col} as TIMESTAMP) - MICROSECOND({col}) MICROSECONDS", |
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.
cleanup - that split is no longer needed:
>>> "CAST({col} as TIMESTAMP)" " - MICROSECOND({col}) MICROSECONDS" == "CAST({col} as TIMESTAMP) - MICROSECOND({col}) MICROSECONDS"
True
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.
LGTM
SUMMARY
While the
QueryObjectFilterClause
currently supports passing agrain
(see here:superset/superset/utils/core.py
Lines 223 to 228 in 7fe0ca1
2000-01-01
(Saturday) becomes1999-12-26
(the previous Monday) with weekly timegrain. Without applying the time grain to the temporal range, the observation for the first week in the query will only consist of two days (Saturday and Sunday), which can give the impression that the events for Monday-Friday never took place.While writing the test I noticed we had many redundant split strings (they were likely split before due to line width, but were moved on the same line by black). So I cleaned up the ones I found under
db_engine_specs
.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION