Datespine Groups
Generates a date spine across custom groupings. Each grouping will be returned with a continuous set of dates. Spines can be calculated globally using the table min/max or locally using each group min/max.
All intervals are considered to be start-inclusive and end-exclusive, or [start, end]
. The join with the date spine will be an outer join such that all intervals are present and all data that does not fall into one of those intervals is excluded.
Parameters
Name | Type | Description | Is Optional |
---|---|---|---|
group_by | column_list | The column(s) used to partition you data into groups. A datespine will be calculated for each group. | |
date_col | column | The column used to create intervals. This must be a datetime column. | |
start_timestamp | timestamp | The timestamp to start calculating from. If not provided, the min of the date_col will be used | True |
end_timestamp | timestamp | The timestamp to calculate to If not provided, the max of the date_col will be used | True |
interval_type | date_part | A valid SQL datepart to slice the date_col. For interval types, see this Snowflake doc. | |
group_bounds | value | Pass 'global' to construct each datespine using the same start & end date (i.e. the min/max of the entire table) Pass 'local' to constuct each datespine using the min/max of the group as the start & end dates Pass 'mixed' to use a local start, while retaining a global end date 'global' is default | True |
Example
Source Code
Last updated