From f4f10f6dd27d17dd16b1c0d4c167dea746d6ac97 Mon Sep 17 00:00:00 2001 From: Kyle Beauchamp Date: Wed, 1 Apr 2020 07:58:25 -0700 Subject: [PATCH] Fixes to changelog --- CHANGELOG.md | 2 ++ plugins/redshift/dbt/adapters/redshift/connections.py | 11 ++++++++--- test/unit/test_redshift_adapter.py | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1189040620..e3ea3f9811a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Added a `get-manifest` API call. ([#2168](https://github.com/fishtown-analytics/dbt/issues/2168), [#2232](https://github.com/fishtown-analytics/dbt/pull/2232)) - Support adapter-specific aliases (like `project` and `dataset` on BigQuery) in source definitions. ([#2133](https://github.com/fishtown-analytics/dbt/issues/2133), [#2244](https://github.com/fishtown-analytics/dbt/pull/2244)) - Users can now use jinja as arguments to tests. Test arguments are rendered in the native context and injected into the test execution context directly. ([#2149](https://github.com/fishtown-analytics/dbt/issues/2149), [#2220](https://github.com/fishtown-analytics/dbt/pull/2220)) +- Added support for `db_groups` and `autocreate` flags in Redshift configurations. ([#1995](https://github.com/fishtown-analytics/dbt/issues/1995, [#2262]https://github.com/fishtown-analytics/dbt/pull/2262)) ### Fixes - When a jinja value is undefined, give a helpful error instead of failing with cryptic "cannot pickle ParserMacroCapture" errors ([#2110](https://github.com/fishtown-analytics/dbt/issues/2110), [#2184](https://github.com/fishtown-analytics/dbt/pull/2184)) @@ -15,6 +16,7 @@ Contributors: - [@raalsky](https://github.com/Raalsky) ([#2224](https://github.com/fishtown-analytics/dbt/pull/2224), [#2228](https://github.com/fishtown-analytics/dbt/pull/2228)) - [@ilkinulas](https://github.com/ilkinulas) [#2199](https://github.com/fishtown-analytics/dbt/pull/2199) + - [@kyleabeauchamp](https://github.com/kyleabeauchamp) [#2262](https://github.com/fishtown-analytics/dbt/pull/2262) - [@jeremyyeo](https://github.com/jeremyyeo) [#2259](https://github.com/fishtown-analytics/dbt/pull/2259) ## dbt 0.16.0 (March 23, 2020) diff --git a/plugins/redshift/dbt/adapters/redshift/connections.py b/plugins/redshift/dbt/adapters/redshift/connections.py index b5d96870251..a60d77cde66 100644 --- a/plugins/redshift/dbt/adapters/redshift/connections.py +++ b/plugins/redshift/dbt/adapters/redshift/connections.py @@ -14,7 +14,7 @@ from hologram.helpers import StrEnum from dataclasses import dataclass, field -from typing import Optional +from typing import Optional, List drop_lock: Lock = dbt.flags.MP_CONTEXT.Lock() @@ -47,6 +47,8 @@ class RedshiftCredentials(PostgresCredentials): iam_duration_seconds: int = 900 search_path: Optional[str] = None keepalives_idle: int = 240 + autocreate: bool = False + db_groups: List[str] = field(default_factory=list) @property def type(self): @@ -85,7 +87,7 @@ def fresh_transaction(self, name=None): @classmethod def fetch_cluster_credentials(cls, db_user, db_name, cluster_id, - duration_s): + duration_s, autocreate, db_groups): """Fetches temporary login credentials from AWS. The specified user must already exist in the database, or else an error will occur""" boto_client = boto3.client('redshift') @@ -96,7 +98,8 @@ def fetch_cluster_credentials(cls, db_user, db_name, cluster_id, DbName=db_name, ClusterIdentifier=cluster_id, DurationSeconds=duration_s, - AutoCreate=False) + AutoCreate=autocreate, + DbGroups=db_groups,) except boto_client.exceptions.ClientError as e: raise dbt.exceptions.FailedToConnectException( @@ -121,6 +124,8 @@ def get_tmp_iam_cluster_credentials(cls, credentials): credentials.database, credentials.cluster_id, iam_duration_s, + credentials.autocreate, + credentials.db_groups, ) # replace username and password with temporary redshift credentials diff --git a/test/unit/test_redshift_adapter.py b/test/unit/test_redshift_adapter.py index 4d509c631c9..79d7a033e06 100644 --- a/test/unit/test_redshift_adapter.py +++ b/test/unit/test_redshift_adapter.py @@ -96,6 +96,8 @@ def test_iam_conn_optionals(self): 'schema': 'public', 'method': 'iam', 'cluster_id': 'my_redshift', + 'db_groups': ["my_dbgroup"], + 'autocreate': True, } }, 'target': 'test'