Skip to content

Commit

Permalink
Merge pull request #2262 from kyleabeauchamp/kab_1995
Browse files Browse the repository at this point in the history
Add db_groups and autocreate flags to Redshift config
  • Loading branch information
beckjake authored Apr 1, 2020
2 parents 4c93b51 + f4f10f6 commit aa0e58e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions plugins/redshift/dbt/adapters/redshift/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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')
Expand All @@ -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(
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/unit/test_redshift_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit aa0e58e

Please sign in to comment.