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

New test cases for fill_nulls_with #1037

Merged
merged 2 commits into from
Feb 21, 2024
Merged

New test cases for fill_nulls_with #1037

merged 2 commits into from
Feb 21, 2024

Conversation

courtneyholcomb
Copy link
Contributor

Description

Tests for some edge cases that have come up in discussions about coalescing nulls. Getting these SQL examples merged will allow us to see the SQL changes more clearly when working on follow ups like SL-1677.

@courtneyholcomb courtneyholcomb marked this pull request as ready for review February 15, 2024 22:46
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.

Seems reasonable!

---
metric:
name: twice_bookings_fill_nulls_with_0_without_time_spine
description: 2x twice_bookings_fill_nulls_with_0_without_time_spine
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 2x bookings_fill_nulls_with_0_without_time_spine

---
metric:
name: nested_fill_nulls_without_time_spine
description: 2x twice_bookings_fill_nulls_with_0_without_time_spine but then x3
Copy link
Contributor

Choose a reason for hiding this comment

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

Same nit, but this time maybe strike the 2x

dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter,
sql_client: SqlClient,
) -> None:
"""Test conversion metric with constant properties by data flow plan rendering."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's update the docstring here and in the other test cases to indicate any weirdness. Like if this won't fill nulls at every level, we can put that in with a note that this should highlight the relevant changes if/when we alter that behavior.

-- Compute Metrics via Expressions
SELECT
metric_time__day
, CAST(buys AS FLOAT64) / CAST(NULLIF(visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days_fill_nulls_with_0
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh interesting. If we want to support recursively filling nulls with something we'll need to apply it on the metric, because conversion and ratio metrics will return NULL for any zero denominator.

This is the default behavior we want - NULL is the correct result - but users may override when they know, for example, that any zero denominator implies a 0% conversion rate for their analysis purposes.

Nothing to do about that now except maybe make a note of this in the test docstring.

@courtneyholcomb courtneyholcomb merged commit 3aa312f into main Feb 21, 2024
9 checks passed
@courtneyholcomb courtneyholcomb deleted the court/test-cases branch February 21, 2024 18:23
@courtneyholcomb
Copy link
Contributor Author

Shoot, merged this on mobile which had the comments collapsed so I missed them. Will address in a follow up PR!

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