Skip to content

Commit 58a14c8

Browse files
Pass WorkGroup parameter to GetTableMetadata and ListTableMetadata APIs
When using PyAthena with a configured work_group, the GetTableMetadata and ListTableMetadata API calls now include the WorkGroup parameter. This allows IAM policies to use specific workgroup ARNs instead of wildcards, improving security posture. Fixes #645 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f76e1a5 commit 58a14c8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pyathena/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ def _build_list_table_metadata_request(
292292
request.update({"Expression": expression})
293293
if next_token:
294294
request.update({"NextToken": next_token})
295+
if self._work_group:
296+
request.update({"WorkGroup": self._work_group})
295297
return request
296298

297299
def _build_list_databases_request(
@@ -359,11 +361,13 @@ def _get_table_metadata(
359361
schema_name: Optional[str] = None,
360362
logging_: bool = True,
361363
) -> AthenaTableMetadata:
362-
request = {
364+
request: Dict[str, Any] = {
363365
"CatalogName": catalog_name if catalog_name else self._catalog_name,
364366
"DatabaseName": schema_name if schema_name else self._schema_name,
365367
"TableName": table_name,
366368
}
369+
if self._work_group:
370+
request.update({"WorkGroup": self._work_group})
367371
try:
368372
response = retry_api_call(
369373
self._connection.client.get_table_metadata,

0 commit comments

Comments
 (0)