Skip to content

KeyError: 'ResultConfiguration' when executes athena.read_sql_query() with a workgroup that doesn't specify Query Result Location #625

Closed
@TakumiHaruta

Description

@TakumiHaruta

Describe the bug

When I executes follwing;

# my-workgroup doesn't specify Query result location
wr.config.workgroup = 'my-workgroup'
df = wr.athena.read_sql_query('SELECT id FROM sales;', database="my-database", ctas_approach=False)

I got this error;

~/jupyter/jupyter/lib/python3.7/site-packages/awswrangler/athena/_utils.py in _get_workgroup_config(session, workgroup)
    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")

KeyError: 'ResultConfiguration'

Currently, the response of athena.get_work_group() doesn't include ResultConfiguration in res["WorkGroup"]["Configuration"] when the workgroup doesn't specify Query Result Location.

I think the response of athena.get_work_group() should have default keys in case ResultConfiguration is null.

To Reproduce

  • Environment
    • Python3.7
    • jupyterlab 3.0.12 on EC2 instance
    • awswrangler: 2.6.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingminor releaseWill be addressed in the next minor releaseready to release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions