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

Use correct join node specs for GroupByMetrics #1193

Merged
merged 9 commits into from
May 10, 2024

Conversation

courtneyholcomb
Copy link
Contributor

@courtneyholcomb courtneyholcomb commented May 8, 2024

Description

In the process of writing rendering tests, I found an issue with the logic used to determine which specs to include in a joined node. This PR primarily updates that logic to handle GroupByMetricSpecs, plus with some related adjustments along the way.

@cla-bot cla-bot bot added the cla:yes label May 8, 2024
… metrics

Also updates documentation in this function since I had a hard time following the logic previously.
@courtneyholcomb courtneyholcomb force-pushed the court/gb-metric-test2 branch from acf40aa to 2cc544a Compare May 8, 2024 23:19
@dbt-labs dbt-labs deleted a comment from github-actions bot May 8, 2024
@courtneyholcomb courtneyholcomb changed the title Court/gb metric test2 Use correct join node specs for GroupByMetrics May 8, 2024
@courtneyholcomb courtneyholcomb requested review from plypaul and tlento May 8, 2024 23:32
@courtneyholcomb courtneyholcomb marked this pull request as ready for review May 8, 2024 23:32
@courtneyholcomb courtneyholcomb added the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label May 9, 2024
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS May 9, 2024 18:21 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS May 9, 2024 18:21 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS May 9, 2024 18:21 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb temporarily deployed to DW_INTEGRATION_TESTS May 9, 2024 18:21 — with GitHub Actions Inactive
@courtneyholcomb courtneyholcomb removed the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label May 9, 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 are a few oddities in here but unless one of the inline comments makes you say "oh no!" I think the changes themselves are reasonable.

@@ -386,7 +386,7 @@ def _build_conversion_metric_output_node(
metric_spec=metric_spec,
aggregated_measures_node=aggregated_measures_node,
for_group_by_source_node=for_group_by_source_node,
aggregated_to_elements=queried_linkable_specs.as_reference_set,
aggregated_to_elements=set(queried_linkable_specs.as_tuple),
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh right because time dimensions or joined elements can vary.....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, previously we had no need for the full spec but now we do!

metricflow/dataflow/builder/node_evaluator.py Outdated Show resolved Hide resolved
)
# Get the specs needed to join onto this node.
if self.node_to_join.aggregated_to_elements:
include_specs.extend(self.node_to_join.aggregated_to_elements)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we want these as-is or did we want to convert them to the LinklessEntitySpec types at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want them as-is. The reason they were always LinklessEntitySpecs previously is that we were always joining to source nodes (which would not have joins contained WITHIN them). In this case, we are joining to a node that has joins within it, so its instance specs might have entity links.

if include_specs_not_found:
raise RuntimeError(
f"Include specs {include_specs_not_found} are not in the spec set {instance_set.spec_set} - "
f"check if this node was constructed correctly."
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this is an odd follow up. If I think it was constructed correctly and I hit this error, what does that indicate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It indicates that you either 1) constructed the instance set correctly or 2) constructed the node incorrectly, since they don't match!

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 was related to this PR because I ran into this error and that's why I needed to change the instance specs built in the JoinDescription. Definitely could have been split into another PR though.

f"check if this node was constructed correctly."
)
exclude_specs_not_found.append(exclude_spec)
if exclude_specs_not_found:
Copy link
Contributor

Choose a reason for hiding this comment

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

It is very nice to get all of these at once. 😁

Base automatically changed from court/gb-metric-test to main May 10, 2024 03:11
@courtneyholcomb courtneyholcomb enabled auto-merge (squash) May 10, 2024 17:28
@courtneyholcomb courtneyholcomb merged commit d3571c3 into main May 10, 2024
15 checks passed
@courtneyholcomb courtneyholcomb deleted the court/gb-metric-test2 branch May 10, 2024 17:32
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.

2 participants