Skip to content

Commit b740f64

Browse files
authored
Add default workgroup result configuration (#633)
1 parent fb68d91 commit b740f64

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

awswrangler/athena/_utils.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,21 @@ def _start_query_execution(
170170

171171

172172
def _get_workgroup_config(session: boto3.Session, workgroup: Optional[str] = None) -> _WorkGroupConfig:
173+
enforced: bool
174+
wg_s3_output: Optional[str]
175+
wg_encryption: Optional[str]
176+
wg_kms_key: Optional[str]
177+
178+
enforced, wg_s3_output, wg_encryption, wg_kms_key = False, None, None, None
173179
if workgroup is not None:
174-
res: Dict[str, Any] = get_work_group(workgroup=workgroup, boto3_session=session)
175-
enforced: bool = res["WorkGroup"]["Configuration"]["EnforceWorkGroupConfiguration"]
176-
config: Dict[str, Any] = res["WorkGroup"]["Configuration"]["ResultConfiguration"]
177-
wg_s3_output: Optional[str] = config.get("OutputLocation")
178-
encrypt_config: Optional[Dict[str, str]] = config.get("EncryptionConfiguration")
179-
wg_encryption: Optional[str] = None if encrypt_config is None else encrypt_config.get("EncryptionOption")
180-
wg_kms_key: Optional[str] = None if encrypt_config is None else encrypt_config.get("KmsKey")
181-
else:
182-
enforced, wg_s3_output, wg_encryption, wg_kms_key = False, None, None, None
180+
res = get_work_group(workgroup=workgroup, boto3_session=session)
181+
enforced = res["WorkGroup"]["Configuration"]["EnforceWorkGroupConfiguration"]
182+
config: Dict[str, Any] = res["WorkGroup"]["Configuration"].get("ResultConfiguration")
183+
if config is not None:
184+
wg_s3_output = config.get("OutputLocation")
185+
encrypt_config: Optional[Dict[str, str]] = config.get("EncryptionConfiguration")
186+
wg_encryption = None if encrypt_config is None else encrypt_config.get("EncryptionOption")
187+
wg_kms_key = None if encrypt_config is None else encrypt_config.get("KmsKey")
183188
wg_config: _WorkGroupConfig = _WorkGroupConfig(
184189
enforced=enforced, s3_output=wg_s3_output, encryption=wg_encryption, kms_key=wg_kms_key
185190
)

0 commit comments

Comments
 (0)