-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
Datetime grouping by parts #1458
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1458 +/- ##
==========================================
+ Coverage 92.66% 92.71% +0.04%
==========================================
Files 130 130
Lines 5560 5598 +38
==========================================
+ Hits 5152 5190 +38
Misses 408 408
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Would it be easy to add support for additional groupings? The original ticket called for additional groupings (e.g. decade, century, quarter, anything supported by the |
Yes, (but). The problems with that are two-fold. First, we don't have (at this moment) a way to encode acceptable string arguments to a given function in the function info endpoint. Thus, we can't have (for example) a 2-argument function to describe both the desire to extract a date part, and which date part to extract without the front end needing to hard-code every string that it wants to be able to extract. After talking a bit with @dmos62 , we decided to avoid creating a separate The second problem is that simply extracting a date part and then grouping on it is a bit unintuitive, and less likely to be useful than the current truncating logic. In case my example from the description was unclear, extracting (for example) the month from a date and grouping on that will put all dates that happen to occur in December in the same group, regardless of their year. This is in contrast with the current logic, where a "month" grouping is actually a year-month pair grouping. As an interim step, I'll add a 2-arg extraction version so if we want to hard-code the various strings describing date parts, and get the behavior described in the second paragraph, the functionality will be there. For the current cycle, I recommend the UI call the pre-fab year, month, and day truncating functions since those make more sense for the report generation described in the storyboard. |
Note: don't commit while blind with integration test rage in the future
I agree with your decision here, I don't think we should naively group by date part. I think other common groupings that users may want are:
I assume those will be handled in subsequent PRs (maybe not in this cycle)? |
Long run, I want to improve the function description machinery to handle describing acceptable string arguments, then redo most of this work. This would enable those. |
Can you create a ticket to track this work? |
Fixes #429
This adds grouping by year, month, or day for any date/time types that include those parts. This also adds a separate grouping method that lets one group by any extractable date part (see below for details).
Technical details
Method 1: simplified truncating
The first, simplified, grouping method utilizes the
preproc
functionality of grouping, and simply specifies some appropriate preprocessing functions to accomplish the desired part extraction. Note that I went with truncating rather than proper part extraction, so[2022-01-01, 2022-01-02, 2023-01-01, 2023-02-01]
Would produce 2 groups when grouped by year, 3 groups when grouped by month, and then 4 groups grouped by day. This is in contrast to 2 groups by year, 2 groups by month, and 2 groups by day, which would be the effect of actually extracting date parts and grouping by those. I deemed the former logic to be more likely to be the intent of most users.
This should be called with a request like:
or
or
Method 2: Extraction
This grouping method actually extracts a date (or time or interval) part based on a given parameter, and groups based only on that part. So,
[2022-01-01, 2022-01-02, 2023-01-01, 2023-02-01]
would produce 2 groups by year, 2 groups by month, and 2 groups by day.
This method can use any extractable date or time part listed in the documentation
It should be called with a request like:
extract_field
is the parameter giving the desired date part for grouping.Screenshots
Checklist
Update index.md
).master
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin