aws / aws/aws-cdk

Athena Create Table

Open
#3,665 17 comments 18 reactions 0 assignees View on GitHub
@aws-cdk/aws-athena effort/large feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

* **I'm submitting a ...**
- [ ] :beetle: bug report
- [X] :rocket: feature request
- [ ] :books: construct library gap
- [ ] :phone: security issue or vulnerability => Please see [policy](https://github.com/aws/aws-cdk/security/policy)
- [ ] :question: support request => Please see note at the top of this template.

* **What is the current behavior?**
Athena Cfn and SDKs don't expose a friendly way to create tables

* **What is the expected behavior (or behavior of feature suggested)?**
I'd propose a construct that takes
* bucket name
* path
* columns: list of tuples (name, type)
* data format (probably best as an enum)
* partitions (subset of columns)

Then uses the AWS SDK Custom Resource on the Athena SDK to execute
```
querystring = """
CREATE EXTERNAL TABLE IF NOT EXISTS mydb.table_name (
`columns[0][0]` columns[0][1],
`columns[1][0]` columns[1][1]
etc...
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
{data_format}
) LOCATION 's3://{bucket_name}/{path}'
TBLPROPERTIES ('has_encrypted_data'='false');
"""
response = client.start_query_execution(
QueryString=querystring,
ClientRequestToken='string',
QueryExecutionContext={
'Database': 'string'
},
ResultConfiguration={
'OutputLocation': 'string',
'EncryptionConfiguration': {
'EncryptionOption': 'SSE_S3'|'SSE_KMS'|'CSE_KMS',
'KmsKey': 'string'
}
},
WorkGroup='string'
)
```

* **What is the motivation / use case for changing the behavior or adding this feature?**
Athena is the goddess of wisdom and civilization, how can we be a civilized developer tool if we don't support her?

* **Please tell us about your environment:**
All of them

* **Other information**
<3

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the Athena Cfn resources and the AWS SDK Custom Resource entry point, then inspect how Athena's start_query_execution API accepts database, result, workgroup, location, columns, formats, and partitions. Done means a documented construct can create the requested external table with those inputs and has coverage for the generated query and execution configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.