-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#4252] Serialization error when missing quotes in metrics model ref(…
…) call (#4287)
- Loading branch information
Showing
7 changed files
with
143 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select 1 as id, 'Drew' as first_name, 'Banin' as last_name, 'yellow' as favorite_color, true as loves_dbt, 5 as tenure, current_timestamp as created_at | ||
union all | ||
select 1 as id, 'Jeremy' as first_name, 'Cohen' as last_name, 'indigo' as favorite_color, true as loves_dbt, 4 as tenure, current_timestamp as created_at |
30 changes: 30 additions & 0 deletions
30
test/integration/075_metrics_tests/invalid-models/people_metrics.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: 2 | ||
|
||
metrics: | ||
|
||
- model: "ref(people)" | ||
name: number_of_people | ||
description: Total count of people | ||
label: "Number of people" | ||
type: count | ||
sql: "*" | ||
timestamp: created_at | ||
time_grains: [day, week, month] | ||
dimensions: | ||
- favorite_color | ||
- loves_dbt | ||
meta: | ||
my_meta: 'testing' | ||
|
||
- model: "ref(people)" | ||
name: collective_tenure | ||
description: Total number of years of team experience | ||
label: "Collective tenure" | ||
type: sum | ||
sql: tenure | ||
timestamp: created_at | ||
time_grains: [day] | ||
filters: | ||
- field: loves_dbt | ||
operator: is | ||
value: 'true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select 1 as id, 'Drew' as first_name, 'Banin' as last_name, 'yellow' as favorite_color, true as loves_dbt, 5 as tenure, current_timestamp as created_at | ||
union all | ||
select 1 as id, 'Jeremy' as first_name, 'Cohen' as last_name, 'indigo' as favorite_color, true as loves_dbt, 4 as tenure, current_timestamp as created_at |
30 changes: 30 additions & 0 deletions
30
test/integration/075_metrics_tests/models/people_metrics.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: 2 | ||
|
||
metrics: | ||
|
||
- model: "ref('people')" | ||
name: number_of_people | ||
description: Total count of people | ||
label: "Number of people" | ||
type: count | ||
sql: "*" | ||
timestamp: created_at | ||
time_grains: [day, week, month] | ||
dimensions: | ||
- favorite_color | ||
- loves_dbt | ||
meta: | ||
my_meta: 'testing' | ||
|
||
- model: "ref('people')" | ||
name: collective_tenure | ||
description: Total number of years of team experience | ||
label: "Collective tenure" | ||
type: sum | ||
sql: tenure | ||
timestamp: created_at | ||
time_grains: [day] | ||
filters: | ||
- field: loves_dbt | ||
operator: is | ||
value: 'true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from test.integration.base import DBTIntegrationTest, use_profile, normalize, get_manifest | ||
from dbt.exceptions import ParsingException | ||
|
||
class BaseMetricTest(DBTIntegrationTest): | ||
|
||
@property | ||
def schema(self): | ||
return "test_075" | ||
|
||
@property | ||
def models(self): | ||
return "models" | ||
|
||
@property | ||
def project_config(self): | ||
return { | ||
'config-version': 2, | ||
'seed-paths': ['seeds'], | ||
'seeds': { | ||
'quote_columns': False, | ||
}, | ||
} | ||
|
||
@use_profile('postgres') | ||
def test_postgres_simple_metric(self): | ||
# initial run | ||
results = self.run_dbt(["run"]) | ||
self.assertEqual(len(results), 1) | ||
manifest = get_manifest() | ||
metric_ids = list(manifest.metrics.keys()) | ||
expected_metric_ids = ['metric.test.number_of_people', 'metric.test.collective_tenure'] | ||
self.assertEqual(metric_ids, expected_metric_ids) | ||
|
||
class InvalidRefMetricTest(DBTIntegrationTest): | ||
|
||
@property | ||
def schema(self): | ||
return "test_075" | ||
|
||
@property | ||
def models(self): | ||
return "invalid-models" | ||
|
||
@property | ||
def project_config(self): | ||
return { | ||
'config-version': 2, | ||
'seed-paths': ['seeds'], | ||
'seeds': { | ||
'quote_columns': False, | ||
}, | ||
} | ||
|
||
@use_profile('postgres') | ||
def test_postgres_simple_metric(self): | ||
# initial run | ||
with self.assertRaises(ParsingException): | ||
results = self.run_dbt(["run"]) | ||
|