Skip to content

Commit

Permalink
changing to table materialization for BQ
Browse files Browse the repository at this point in the history
  • Loading branch information
callum-mcdata committed Jul 29, 2022
1 parent c0d8378 commit 4918f02
Show file tree
Hide file tree
Showing 36 changed files with 514 additions and 222 deletions.
8 changes: 4 additions & 4 deletions tests/functional/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
# seeds/fact_orders_source.csv
fact_orders_source_csv = """
order_id,order_country,order_total,had_discount,customer_id,order_date
1,France,2,false,1,2022-01-28
2,Japan,1,false,2,2022-01-20
3,France,1,false,1,2022-01-13
4,France,1,true,3,2022-01-06
5,France,1,false,4,2022-01-08
3,France,1,false,1,2022-01-13
2,Japan,1,false,2,2022-01-20
6,Japan,1,false,5,2022-01-21
7,Japan,1,true,2,2022-01-22
8,France,4,true,1,2022-02-15
1,France,2,false,1,2022-01-28
9,Japan,1,false,2,2022-02-03
10,Japan,1,false,3,2022-02-13
8,France,4,true,1,2022-02-15
""".lstrip()

# seeds/dim_customers_source.csv
Expand Down
20 changes: 14 additions & 6 deletions tests/functional/metric_options/date_grains/test_day_grain.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,20 @@
class TestDayGrain:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
21 changes: 14 additions & 7 deletions tests/functional/metric_options/date_grains/test_month_grain.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,20 @@
class TestmonthGrain:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}

if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}
# install current repo as package
@pytest.fixture(scope="class")
def packages(self):
Expand Down
37 changes: 29 additions & 8 deletions tests/functional/metric_options/date_grains/test_week_grain.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,21 @@
- order_country
"""

# seeds/week_grain__expected.csv
week_grain__expected_csv = """
if os.getenv('dbt_target') == 'bigquery':
# seeds/week_grain__expected.csv
week_grain__expected_csv = """
date_week,week_grain_metric
2022-02-13,2
2022-02-06,0
2022-01-30,1
2022-01-23,1
2022-01-16,3
2022-01-09,1
2022-01-02,2
""".lstrip()
else:
# seeds/week_grain__expected.csv
week_grain__expected_csv = """
date_week,week_grain_metric
2022-02-14,1
2022-02-07,1
Expand All @@ -56,12 +69,20 @@
class TestWeekGrain:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,20 @@
class TestMultiDimensionBaseSumMetric:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,20 @@
class TestMultiDimensionExpressionMetric:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,20 @@
class TestSingleDimensionBaseSumMetric:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,20 @@
class TestSingleDimensionExpressionMetric:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,20 @@
class TestEarlyEndDateBaseSumMetric:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@
class TestEndDateExpressionMetric:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,20 @@
class TestEndDateBaseSumMetric:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@
class TestEndDateExpressionMetric:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,20 @@
class TestMultipleMetrics:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@
class TestMultipleMetricsWithDimension:

# configuration in dbt_project.yml
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
if os.getenv('dbt_target') == 'bigquery':
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "table"}
}
else:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "example",
"models": {"+materialized": "view"}
}

# install current repo as package
@pytest.fixture(scope="class")
Expand Down
Loading

0 comments on commit 4918f02

Please sign in to comment.