Skip to content
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

Support multiple time spines in one query #1644

Open
wants to merge 4 commits into
base: court/custom-offset8
Choose a base branch
from

Conversation

courtneyholcomb
Copy link
Contributor

@courtneyholcomb courtneyholcomb commented Jan 28, 2025

There are some scenarios where a user might require multiple time spines per query:

  1. When querying multiple custom grains from different time spines.
  2. When querying a custom grain with a standard grain that is smaller than the base grain of the custom grain.
    1 is already supported. This PR provides support for 2.

Not covered: option 2 with a custom offset window metric. This is coming in the next PR up the stack.

@cla-bot cla-bot bot added the cla:yes label Jan 28, 2025
Copy link

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

2020-01-08T00:00:00 2020-01-01T10:00:00 1 3
2020-01-08T00:00:00 2020-01-01T11:00:00 1 3
2020-01-08T00:00:00 2020-01-01T12:00:00 1 3
2020-01-08T00:00:00 2020-01-02T01:00:00 None None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These nulls are expected due to the the join_to_timespine metric. They span all the rows that we have in our hourly test time spine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I'm planning to make some improvements to our time spine test data up the stack. Namely:

  • Some of the feedback you gave me previously about martian_day
  • Adding at least one more custom granularity (something fairly standard like fiscal_quarter)
  • Adding more test data to our hourly time spine so that it at least spans more than one custom granularity period

raise RuntimeError(
str(
LazyFormat(
"Unexpected number of time spine sources required for query - cumulative metrics should require exactly one.",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom grains are joined later for cumulative metrics, so this should always be true.

@dbt-labs dbt-labs deleted a comment from github-actions bot Jan 29, 2025
@courtneyholcomb courtneyholcomb marked this pull request as ready for review January 29, 2025 03:00
@courtneyholcomb courtneyholcomb requested a review from a team as a code owner January 29, 2025 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant