-
Notifications
You must be signed in to change notification settings - Fork 98
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -704,3 +704,39 @@ metric: | |
expr: bookings | ||
metrics: | ||
- name: bookings | ||
--- | ||
metric: | ||
name: twice_bookings_fill_nulls_with_0_without_time_spine | ||
description: 2x twice_bookings_fill_nulls_with_0_without_time_spine | ||
type: derived | ||
type_params: | ||
expr: 2 * bookings_fill_nulls_with_0_without_time_spine | ||
metrics: | ||
- name: 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same nit, but this time maybe strike the |
||
type: derived | ||
type_params: | ||
expr: 3 * twice_bookings_fill_nulls_with_0_without_time_spine | ||
metrics: | ||
- name: twice_bookings_fill_nulls_with_0_without_time_spine | ||
--- | ||
metric: | ||
name: visit_buy_conversion_rate_7days_fill_nulls_with_0 | ||
description: conversion rate on visits-buys on a 7 day window, filling nulls with 0 for both input measures | ||
type: conversion | ||
type_params: | ||
conversion_type_params: | ||
base_measure: | ||
name: visits | ||
fill_nulls_with: 0 | ||
join_to_timespine: true | ||
conversion_measure: | ||
name: buys | ||
fill_nulls_with: 0 | ||
join_to_timespine: true | ||
window: 7 days | ||
entity: user | ||
calculation: conversion_rate |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,3 +168,32 @@ def test_conversion_rate_with_constant_properties( | |
sql_client=sql_client, | ||
node=dataflow_plan.sink_output_nodes[0].parent_node, | ||
) | ||
|
||
|
||
@pytest.mark.sql_engine_snapshot | ||
def test_conversion_metric_fill_nulls_with_0( | ||
request: FixtureRequest, | ||
mf_test_session_state: MetricFlowTestSessionState, | ||
dataflow_plan_builder: DataflowPlanBuilder, | ||
dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, | ||
sql_client: SqlClient, | ||
) -> None: | ||
"""Test conversion metric with constant properties by data flow plan rendering.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
metric_spec = MetricSpec(element_name="visit_buy_conversion_rate_7days_fill_nulls_with_0") | ||
metric_time_spec = TimeDimensionSpec( | ||
element_name="metric_time", entity_links=(), time_granularity=TimeGranularity.DAY | ||
) | ||
dataflow_plan = dataflow_plan_builder.build_plan( | ||
query_spec=MetricFlowQuerySpec( | ||
metric_specs=(metric_spec,), | ||
time_dimension_specs=(metric_time_spec,), | ||
), | ||
) | ||
|
||
convert_and_check( | ||
request=request, | ||
mf_test_session_state=mf_test_session_state, | ||
dataflow_to_sql_converter=dataflow_to_sql_converter, | ||
sql_client=sql_client, | ||
node=dataflow_plan.sink_output_nodes[0].parent_node, | ||
) |
There was a problem hiding this comment.
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