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 default of None properly for cumulative_type_params #371

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

courtneyholcomb
Copy link
Contributor

dbt-core parses YAML differently than DSI. There, the YAML dict for a metric ends up with if that key is empty. Then when we call type_params.get(cumulative_type_params, {}), the result is None because the key does exist in the dict. This results in a key error when we finally call .get(grain_to_date). Thus, we must set the default value outside of .get().

Resolves #

Description

Checklist

dbt-core parses YAML differently than DSI. There, the YAML dict for a metric ends up with  if that key is empty. Then when we call type_params.get(cumulative_type_params, {}), the result is None because the key does exist in the dict. This results in a key error when we finally call .get(grain_to_date). Thus, we must set the default value outside of .get().
Copy link

github-actions bot commented Dec 3, 2024

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.

@@ -209,8 +209,8 @@ def parse_obj(cls, input: Any) -> PydanticMetric:
data = deepcopy(input)

# Ensure grain_to_date is lowercased
type_params = data.get("type_params", {})
grain_to_date = type_params.get("cumulative_type_params", {}).get("grain_to_date")
type_params = data.get("type_params") or {}
Copy link
Contributor

Choose a reason for hiding this comment

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

brutal

@courtneyholcomb courtneyholcomb merged commit 7401056 into main Dec 3, 2024
20 of 21 checks passed
@courtneyholcomb courtneyholcomb deleted the court/defaulty branch December 3, 2024 04:24
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.

3 participants