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

Handle no-metric queries with sub-daily metric_time #1359

Merged
merged 9 commits into from
Jul 30, 2024

Conversation

courtneyholcomb
Copy link
Contributor

@courtneyholcomb courtneyholcomb commented Jul 27, 2024

Makes some updates to enable no-metric queries with sub-daily time dimensions and adds integration tests for those queries.

@cla-bot cla-bot bot added the cla:yes label Jul 27, 2024
@courtneyholcomb courtneyholcomb force-pushed the court/subd-no-metrics branch 2 times, most recently from 398c5dc to 2a3a284 Compare July 27, 2024 17:37
@courtneyholcomb courtneyholcomb changed the title Court/subd no metrics Handle no-metric queries with sub-daily metric_time Jul 27, 2024
@dbt-labs dbt-labs deleted a comment from github-actions bot Jul 27, 2024
@courtneyholcomb courtneyholcomb force-pushed the court/subd-no-metrics branch from 22a7253 to 11058a5 Compare July 29, 2024 18:34
@courtneyholcomb courtneyholcomb marked this pull request as ready for review July 29, 2024 18:35
@courtneyholcomb courtneyholcomb added the Reload Test Data in SQL Engines Should be run when test data changes label Jul 29, 2024
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 18:35 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 18:35 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 18:35 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 18:35 — with GitHub Actions Inactive
@github-actions github-actions bot removed the Reload Test Data in SQL Engines Should be run when test data changes label Jul 29, 2024
@courtneyholcomb courtneyholcomb added the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Jul 29, 2024
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 18:50 — with GitHub Actions Inactive
@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 Jul 29, 2024
@courtneyholcomb courtneyholcomb force-pushed the court/test-time-spines branch from 88dbe8b to fdcf983 Compare July 29, 2024 21:53
@courtneyholcomb courtneyholcomb force-pushed the court/subd-no-metrics branch 2 times, most recently from a294e89 to 40b1db3 Compare July 29, 2024 22:28
@courtneyholcomb courtneyholcomb force-pushed the court/test-time-spines branch from e63dfca to eb31d9f Compare July 29, 2024 22:30
@courtneyholcomb courtneyholcomb force-pushed the court/subd-no-metrics branch from 40b1db3 to 2231f38 Compare July 29, 2024 22:30
@courtneyholcomb courtneyholcomb added the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Jul 29, 2024
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 22:32 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 22:32 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb added the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Jul 29, 2024
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 22:49 — with GitHub Actions Inactive
@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 Jul 29, 2024
@courtneyholcomb courtneyholcomb force-pushed the court/test-time-spines branch from b12aebb to b1ec4d6 Compare July 29, 2024 23:13
@courtneyholcomb courtneyholcomb force-pushed the court/subd-no-metrics branch from 79e46c6 to d5cff0a Compare July 29, 2024 23:18
@courtneyholcomb courtneyholcomb force-pushed the court/test-time-spines branch from b1ec4d6 to 2ef8de8 Compare July 29, 2024 23:27
@courtneyholcomb courtneyholcomb force-pushed the court/subd-no-metrics branch from d5cff0a to e984404 Compare July 29, 2024 23:30
@courtneyholcomb courtneyholcomb added the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Jul 29, 2024
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 23:34 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 23:34 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 23:34 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS July 29, 2024 23:34 — with GitHub Actions Inactive
@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 Jul 29, 2024
Copy link
Contributor

@tlento tlento left a comment

Choose a reason for hiding this comment

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

There's a snapshot change I don't understand but if that's expected this seems ok.

I think we probably need to streamline how we handle all of these granularity locations. The TimeDimension granularity specification is quite confusing in this new world where it only fixes a minimum.

Comment on lines +105 to +108
element_name=self.element_name,
time_granularity=self.time_granularity,
date_part=self.date_part,
entity_links=(),
Copy link
Contributor

Choose a reason for hiding this comment

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

oops

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your PR comment gifs are always the best.

Comment on lines 208 to 210
satisfiable_metric_time_specs = set(needed_linkable_specs).intersection(
set(linkable_specs_in_right_node)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok. I think this helps with custom calendar, too, since it'll pull all the extra granularity columns.

@@ -332,7 +332,7 @@ def _build_time_dimension_instances_and_columns(
) -> Tuple[List[TimeDimensionInstance], List[SqlSelectColumn]]:
time_dimension_instances: List[TimeDimensionInstance] = []
select_columns: List[SqlSelectColumn] = []
# Add time dimensions with a smaller granularity for ease in query resolution
# Add time dimensions with a larger granularity for ease in query resolution
Copy link
Contributor

Choose a reason for hiding this comment

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

😂

)
# If querying metric_time without metrics, will query from time spines.
# Defaults to DAY granularity if available in time spines, else smallest available granularity.
min_time_spine_granularity = min(self._time_spine_sources.keys())
Copy link
Contributor

Choose a reason for hiding this comment

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

This default is because the time_spine_sources automatically include the DAY granularity (via TimeSpineSource.create_from_manifest()) if no custom time spines are found, correct?

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 default is set so that if you query ambiguous metric_time without metrics, we don't return nanoseconds if you have that time spine configured. Since metric_time defaults to DAY in all other scenarios (unless overridden by the metric's default granularity), this seemed like the expected behavior.

@@ -419,7 +419,6 @@
'lux_listing__listing__lux_listing__twice_bookings_fill_nulls_with_0_without_time_spine',
'lux_listing__listing__lux_listing__views',
'lux_listing__listing__lux_listing__views_times_booking_value',
'metric_time__day',
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, is this expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! I had the same question and meant to leave a comment explaining but I forgot.
This test is specifically filtering out specs with the property DERIVED_TIME_GRANULARITY. I'm not sure why. But I made a change in this PR that makes all metric_time granularities derived for no-metric queries.
Debatable which behavior would be expected for that property here, but doesn't seem super important since it's only internal.

@courtneyholcomb courtneyholcomb requested a review from tlento July 30, 2024 20:05
Copy link
Contributor

@tlento tlento left a comment

Choose a reason for hiding this comment

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

I could've sworn I approved this before lunch but apparently hunger was making me delusional....

@courtneyholcomb courtneyholcomb merged commit ae263fd into court/test-time-spines Jul 30, 2024
27 checks passed
@courtneyholcomb courtneyholcomb deleted the court/subd-no-metrics branch July 30, 2024 21:02
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