Skip to content

Commit

Permalink
updated saved query tests and fixtures (#10610)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee authored Aug 26, 2024
1 parent 3c55806 commit f25a474
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
46 changes: 23 additions & 23 deletions tests/functional/saved_queries/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
metrics:
- simple_metric
group_by:
- "Dimension('user__ds')"
- "Dimension('id__ds')"
where:
- "{{ Dimension('user__ds', 'DAY') }} <= now()"
- "{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'"
- "{{ TimeDimension('id__ds', 'DAY') }} <= now()"
- "{{ TimeDimension('id__ds', 'DAY') }} >= '2023-01-01'"
- "{{ Metric('txn_revenue', ['id']) }} > 1"
exports:
- name: my_export
Expand All @@ -33,10 +33,10 @@
metrics:
- simple_metric
group_by:
- "Dimension('user__ds')"
- "Dimension('id__ds')"
where:
- "{{ Dimension('user__ds', 'DAY') }} <= now()"
- "{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'"
- "{{ TimeDimension('id__ds', 'DAY') }} <= now()"
- "{{ TimeDimension('id__ds', 'DAY') }} >= '2023-01-01'"
- "{{ Metric('txn_revenue', ['id']) }} > 1"
exports:
- name: my_export
Expand All @@ -54,10 +54,10 @@
metrics:
- simple_metric
group_by:
- "Dimension('user__ds')"
- "Dimension('id__ds')"
where:
- "{{ Dimension('user__ds', 'DAY') }} <= now()"
- "{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'"
- "{{ TimeDimension('id__ds', 'DAY') }} <= now()"
- "{{ TimeDimension('id__ds', 'DAY') }} >= '2023-01-01'"
exports:
- name: my_export
config:
Expand All @@ -72,8 +72,8 @@
metrics:
- simple_metric
group_by:
- "Dimension('user__ds')"
where: "{{ Dimension('user__ds', 'DAY') }} <= now()"
- "Dimension('id__ds')"
where: "{{ TimeDimension('id__ds', 'DAY') }} <= now()"
"""

saved_query_with_extra_config_attributes_yml = """
Expand All @@ -85,10 +85,10 @@
metrics:
- simple_metric
group_by:
- "Dimension('user__ds')"
- "Dimension('id__ds')"
where:
- "{{ Dimension('user__ds', 'DAY') }} <= now()"
- "{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'"
- "{{ TimeDimension('id__ds', 'DAY') }} <= now()"
- "{{ TimeDimension('id__ds', 'DAY') }} >= '2023-01-01'"
exports:
- name: my_export
config:
Expand All @@ -108,10 +108,10 @@
metrics:
- simple_metric
group_by:
- "Dimension('user__ds')"
- "Dimension('id__ds')"
where:
- "{{ Dimension('user__ds', 'DAY') }} <= now()"
- "{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'"
- "{{ TimeDimension('id__ds', 'DAY') }} <= now()"
- "{{ TimeDimension('id__ds', 'DAY') }} >= '2023-01-01'"
exports:
- name: my_export
config:
Expand All @@ -129,10 +129,10 @@
metrics:
- simple_metric
group_by:
- "Dimension('user__ds')"
- "Dimension('id__ds')"
where:
- "{{ Dimension('user__ds', 'DAY') }} <= now()"
- "{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'"
- "{{ TimeDimension('id__ds', 'DAY') }} <= now()"
- "{{ TimeDimension('id__ds', 'DAY') }} >= '2023-01-01'"
exports:
- name: my_export
"""
Expand All @@ -149,10 +149,10 @@
metrics:
- simple_metric
group_by:
- "Dimension('user__ds')"
- "Dimension('id__ds')"
where:
- "{{ Dimension('user__ds', 'DAY') }} <= now()"
- "{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'"
- "{{ TimeDimension('id__ds', 'DAY') }} <= now()"
- "{{ TimeDimension('id__ds', 'DAY') }} >= '2023-01-01'"
exports:
- name: my_export
config:
Expand Down
5 changes: 3 additions & 2 deletions tests/functional/saved_queries/test_saved_query_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)


class TestSavedQueryBuildNoOp:
class TestSavedQueryBuild:
@pytest.fixture(scope="class")
def models(self):
return {
Expand All @@ -31,7 +31,8 @@ def packages(self):
version: 1.1.1
"""

def test_build_saved_queries(self, project):
def test_build_saved_queries_no_op(self, project) -> None:
"""Test building saved query exports with no flag, so should be no-op."""
run_dbt(["deps"])
result = run_dbt(["build"])
assert len(result.results) == 3
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/saved_queries/test_saved_query_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ def test_saved_query_filter_types(self, project):
where_filter.where_sql_template
for where_filter in saved_query1.query_params.where.where_filters
} == {
"{{ Dimension('user__ds', 'DAY') }} <= now()",
"{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'",
"{{ TimeDimension('id__ds', 'DAY') }} <= now()",
"{{ TimeDimension('id__ds', 'DAY') }} >= '2023-01-01'",
}
# String filter
assert len(saved_query2.query_params.where.where_filters) == 1
assert (
saved_query2.query_params.where.where_filters[0].where_sql_template
== "{{ Dimension('user__ds', 'DAY') }} <= now()"
== "{{ TimeDimension('id__ds', 'DAY') }} <= now()"
)

def test_saved_query_metrics_changed(self, project):
Expand Down

0 comments on commit f25a474

Please sign in to comment.