From 1c1f10056d83d8c9320ce625865a0d387a821daf Mon Sep 17 00:00:00 2001 From: Jacob Beck Date: Wed, 17 Jun 2020 07:39:41 -0600 Subject: [PATCH] Fix a regression where dbt ignored aliases in config() calls --- CHANGELOG.md | 1 + core/dbt/context/context_config.py | 3 ++- .../040_override_database_test/models/view_2.sql | 8 +++++--- test/integration/base.py | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 384ed38274d..7068a5ba604 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - dbt compile and ls no longer create schemas if they don't already exist ([#2525](https://github.com/fishtown-analytics/dbt/issues/2525), [#2528](https://github.com/fishtown-analytics/dbt/pull/2528)) - `dbt deps` now respects the `--project-dir` flag, so using `dbt deps --project-dir=/some/path` and then `dbt run --project-dir=/some/path` will properly find dependencies ([#2519](https://github.com/fishtown-analytics/dbt/issues/2519), [#2534](https://github.com/fishtown-analytics/dbt/pull/2534)) - `packages.yml` revision/version fields can be float-like again (`revision: '1.0'` is valid). ([#2518](https://github.com/fishtown-analytics/dbt/issues/2518), [#2535](https://github.com/fishtown-analytics/dbt/pull/2535)) +- dbt again respects config aliases in config() calls ([#2557](https://github.com/fishtown-analytics/dbt/issues/2557), [#2559](https://github.com/fishtown-analytics/dbt/pull/2559)) ## dbt 0.17.0 (June 08, 2020) diff --git a/core/dbt/context/context_config.py b/core/dbt/context/context_config.py index a33be3357e4..3cdf9bf92e1 100644 --- a/core/dbt/context/context_config.py +++ b/core/dbt/context/context_config.py @@ -131,8 +131,9 @@ def active_project_configs( def _update_from_config( self, result: T, partial: Dict[str, Any], validate: bool = False ) -> T: + translated = self.active_project.credentials.translate_aliases(partial) return result.update_from( - partial, + translated, self.active_project.credentials.type, validate=validate ) diff --git a/test/integration/040_override_database_test/models/view_2.sql b/test/integration/040_override_database_test/models/view_2.sql index bdfa5369fa7..9ac6bdad6a7 100644 --- a/test/integration/040_override_database_test/models/view_2.sql +++ b/test/integration/040_override_database_test/models/view_2.sql @@ -1,4 +1,6 @@ -{{ - config(database=var('alternate_db')) -}} +{%- if target.type == 'bigquery' -%} + {{ config(project=var('alternate_db')) }} +{%- else -%} + {{ config(database=var('alternate_db')) }} +{%- endif -%} select * from {{ ref('seed') }} diff --git a/test/integration/base.py b/test/integration/base.py index 7122d1a6c86..9079dfb50ea 100644 --- a/test/integration/base.py +++ b/test/integration/base.py @@ -1021,6 +1021,8 @@ def assertManyRelationsEqual(self, relations, default_schema=None, default_datab first_columns = None for relation in specs: key = (relation.database, relation.schema, relation.identifier) + # get a good error here instead of a hard-to-diagnose KeyError + self.assertIn(key, column_specs, f'No columns found for {key}') columns = column_specs[key] if first_columns is None: first_columns = columns