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 for join_to_timespine metrics with custom grain in the group by #1505

Merged
merged 6 commits into from
Nov 5, 2024

Conversation

courtneyholcomb
Copy link
Contributor

@courtneyholcomb courtneyholcomb commented Nov 4, 2024

Support for using custom grains in the group by when querying join_to_timespine metrics.
This includes only limited support for now. Later we will support:

  • Including custom grain in the where filter for these metric queries
  • Queries that require multiple time spines to be joined in one JoinToTimeSpineNode

@cla-bot cla-bot bot added the cla:yes label Nov 4, 2024
@courtneyholcomb courtneyholcomb added the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Nov 4, 2024
@github-actions github-actions bot removed the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Nov 4, 2024
@dbt-labs dbt-labs deleted a comment from github-actions bot Nov 5, 2024
@courtneyholcomb courtneyholcomb force-pushed the court/join-to-time-spine-custom branch 2 times, most recently from c38c05d to c777a36 Compare November 5, 2024 03:42
@courtneyholcomb courtneyholcomb force-pushed the court/join-to-time-spine-custom branch from c777a36 to bc04559 Compare November 5, 2024 03:57
@@ -0,0 +1,17 @@
booking__ds__martian_day bookings_join_to_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.

This is the expected result. All of the bookings source data maps to this martian_day.

@courtneyholcomb courtneyholcomb marked this pull request as ready for review November 5, 2024 04:05
@courtneyholcomb courtneyholcomb added the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Nov 5, 2024
@github-actions github-actions bot removed the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Nov 5, 2024
for grain, time_spine_source in time_spine_sources.items()
if grain.to_int() <= smallest_required_standard_grain.to_int()
}
if not compatible_time_spines_for_standard_grains:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - non-blocking: I kinda like the readability of doing

if compatible_time_spines_for_standard_grains == {}:
# OR
if len(compatible_time_spines_for_standard_grains) == 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call you have given me this feedback before, I'll try to remember in future!!


# If the standard grains can't be satisfied by the same time spines as the custom grains, add the largest compatible one.
if not required_time_spines.intersection(set(compatible_time_spines_for_standard_grains.values())):
required_time_spines.add(time_spine_sources[max(compatible_time_spines_for_standard_grains.keys())])
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you don't need .keys() since it already uses keys by default when you do any functions on a dict.

@courtneyholcomb courtneyholcomb enabled auto-merge (squash) November 5, 2024 17:37
@courtneyholcomb courtneyholcomb merged commit ae8ea72 into main Nov 5, 2024
15 checks passed
@courtneyholcomb courtneyholcomb deleted the court/join-to-time-spine-custom branch November 5, 2024 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants