Time Spines
Introduction
A time spine entity is a list of dates, that has relations to date columns of other entities.
The main use cases for a time spine are:
-
Filling in missing data - for example when counting new users by day, a day without users should be counted as 0. But without a time spine, if counting on the new users table on a missing date, then it will just not appear.
-
Providing a common time for different metrics - most metrics are based on time. When metrics are on different entities how to count them to the same day? Connect those entities to a time spine, and count them to the date in the spine.
Building a time spine
The time spine is an entity. It can be a table in the database or on a custom SQL query, such as:
The Honeydew convention for a per-day time spine is to call it date
.
- Time entity should be marked as such through the
is_time_spine
metadata tag in its yaml. - Multiple time spines are not supported.
Always prefer creating time spines as tables and not as custom SQL entities.
Snowflake does not cache queries that use table generators. Using a time spine as custom SQL without materialization will disable caching for queries that involves it.
The time spine should have the granularity column as key - in a per-day spine, the date is the key.
Make sure to set the timegrain
attribute for the granularity column, to enforce that granularity.
Was this page helpful?