Skip to content

Commit

Permalink
Write DFP test
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Mar 27, 2024
1 parent 112247a commit 61a4cd0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/dataflow/builder/test_dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,3 +1265,33 @@ def test_offset_to_grain_metric_filter_and_query_have_different_granularities(
mf_test_configuration=mf_test_configuration,
dag_graph=dataflow_plan,
)


def test_metric_in_where_filter(
request: FixtureRequest,
mf_test_configuration: MetricFlowTestConfiguration,
dataflow_plan_builder: DataflowPlanBuilder,
query_parser: MetricFlowQueryParser,
create_source_tables: bool,
) -> None:
"""Test querying a metric that has a metric in its where filter."""
query_spec = query_parser.parse_and_validate_query(
metric_names=("active_listings",),
)
dataflow_plan = dataflow_plan_builder.build_plan(query_spec)

assert_plan_snapshot_text_equal(
request=request,
mf_test_configuration=mf_test_configuration,
plan=dataflow_plan,
plan_snapshot_text=dataflow_plan.structure_text(),
)

display_graph_if_requested(
request=request,
mf_test_configuration=mf_test_configuration,
dag_graph=dataflow_plan,
)


# What if there are multiple entities in the list of group bys?
Original file line number Diff line number Diff line change
Expand Up @@ -753,3 +753,11 @@ metric:
window: 7 days
entity: user
calculation: conversion_rate
---
metric:
name: active_listings
description: Listings with at least 2 bookings
type: simple
type_params:
measure: listings
filter: "{{ Metric('bookings', ['listing']) }} > 2"

0 comments on commit 61a4cd0

Please sign in to comment.