Athena Create Table
See original GitHub issue-
I’m submitting a …
- 🪲 bug report
- 🚀 feature request
- 📚 construct library gap
- ☎️ security issue or vulnerability => Please see policy
- ❓ 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 ❤️
Issue Analytics
- State:
- Created 4 years ago
- Reactions:15
- Comments:16 (3 by maintainers)
Top Results From Across the Web
Creating tables in Athena - AWS Documentation - Amazon.com
To create a table using the Athena create table form · In the query editor, next to Tables and views, choose Create, and...
Read more >CREATE TABLE AS - Amazon Athena - 亚马逊云科技
Creates a new table populated with the results of a SELECT query. To create an empty table, use CREATE TABLE. For additional information...
Read more >Three ways to create Amazon Athena tables - Better Dev
With tables created for Products and Transactions, we can execute SQL queries on them with Athena. Athena supports not only SELECT queries, but ......
Read more >Create External Table in Amazon Athena Database ...
First select the Athena database name where you want to create a new table. Give a name to your new Athena database table...
Read more >3. AWS Athena - Creating tables and querying data - YouTube
Amazon Athena is an interactive query service that makes it easy to analyze data in Amazon S3 using standard SQL. Athena is serverless ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have recently noticed that this post is still open while looking for approaches to a similar problem.
Both @shwetajoshi601 and @tkblackbelt suggest good approaches. What I found to work best for me was to rely on the concept of Escape Hatches in CDK where you can easily extend CDK code with custom overrides that are not yet supported in L2 constructs.
In this case you could:
My example is in Java, but Escape hatches are supported for all implementations.
Found another workaround. You can do this using the CFN Object instead of the CDK one as shown below.
https://aws.amazon.com/about-aws/whats-new/2020/06/amazon-athena-supports-partition-projection/