Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add db_groups and autocreate flags to Redshift config #2262

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:/fishtown-analytics/dbt/issues/2168), [#2232](https:/fishtown-analytics/dbt/pull/2232))
- Support adapter-specific aliases (like `project` and `dataset` on BigQuery) in source definitions. ([#2133](https:/fishtown-analytics/dbt/issues/2133), [#2244](https:/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:/fishtown-analytics/dbt/issues/2149), [#2220](https:/fishtown-analytics/dbt/pull/2220))
- Added support for `db_groups` and `autocreate` flags in Redshift configurations. ([#1995](https:/fishtown-analytics/dbt/issues/1995, [#2262]https:/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:/fishtown-analytics/dbt/issues/2110), [#2184](https:/fishtown-analytics/dbt/pull/2184))
Expand All @@ -15,6 +16,7 @@
Contributors:
- [@raalsky](https:/Raalsky) ([#2224](https:/fishtown-analytics/dbt/pull/2224), [#2228](https:/fishtown-analytics/dbt/pull/2228))
- [@ilkinulas](https:/ilkinulas) [#2199](https:/fishtown-analytics/dbt/pull/2199)
- [@kyleabeauchamp](https:/kyleabeauchamp) [#2262](https:/fishtown-analytics/dbt/pull/2262)
- [@jeremyyeo](https:/jeremyyeo) [#2259](https:/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