Skip to content

Commit

Permalink
feat(glue): default data location for tables is the root of the bucket (
Browse files Browse the repository at this point in the history
#8999)

Fixes #8472

BREAKING CHANGE: The default location of glue data will be the root of an s3 bucket, instead of `/data`

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
DerkSchooltink committed Jul 13, 2020
1 parent fcca86e commit 28949bd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-glue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ new glue.Table(stack, 'MyTable', {
});
```

By default, an S3 bucket will be created to store the table's data and stored in the bucket root. You can also manually pass the `bucket` and `s3Prefix`:

#### Partitions

To improve query performance, a table can specify `partitionKeys` on which data is stored and queried separately. For example, you might partition a table by `year` and `month` to optimize queries based on a time window:
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-glue/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export interface TableProps {
/**
* S3 prefix under which table objects are stored.
*
* @default data/
* @default - No prefix. The data will be stored under the root of the bucket.
*/
readonly s3Prefix?: string;

Expand Down Expand Up @@ -236,7 +236,7 @@ export class Table extends Resource implements ITable {

this.database = props.database;
this.dataFormat = props.dataFormat;
this.s3Prefix = (props.s3Prefix !== undefined && props.s3Prefix !== null) ? props.s3Prefix : 'data/';
this.s3Prefix = props.s3Prefix ?? '';

validateSchema(props.columns, props.partitionKeys);
this.columns = props.columns;
Expand Down
18 changes: 9 additions & 9 deletions packages/@aws-cdk/aws-glue/test/integ.table.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
{
"Ref": "DataBucketE3889A50"
},
"/data/"
"/"
]
]
},
Expand Down Expand Up @@ -140,7 +140,7 @@
{
"Ref": "DataBucketE3889A50"
},
"/data/"
"/"
]
]
},
Expand Down Expand Up @@ -209,7 +209,7 @@
{
"Ref": "DataBucketE3889A50"
},
"/data/"
"/"
]
]
},
Expand Down Expand Up @@ -278,7 +278,7 @@
{
"Ref": "DataBucketE3889A50"
},
"/data/"
"/"
]
]
},
Expand Down Expand Up @@ -439,7 +439,7 @@
{
"Ref": "MyEncryptedTableBucket7B28486D"
},
"/data/"
"/"
]
]
},
Expand Down Expand Up @@ -532,7 +532,7 @@
"Arn"
]
},
"/data/"
"/"
]
]
}
Expand Down Expand Up @@ -609,7 +609,7 @@
"Arn"
]
},
"/data/"
"/"
]
]
}
Expand Down Expand Up @@ -721,7 +721,7 @@
"Arn"
]
},
"/data/"
"/"
]
]
}
Expand Down Expand Up @@ -827,4 +827,4 @@
}
}
}
}
}
26 changes: 13 additions & 13 deletions packages/@aws-cdk/aws-glue/test/table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test('unpartitioned JSON table', () => {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -139,7 +139,7 @@ test('partitioned JSON table', () => {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -204,7 +204,7 @@ test('compressed table', () => {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -293,7 +293,7 @@ test('encrypted table: SSE-S3', () => {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -436,7 +436,7 @@ test('encrypted table: SSE-KMS (implicitly created key)', () => {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -569,7 +569,7 @@ test('encrypted table: SSE-KMS (explicitly created key)', () => {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -647,7 +647,7 @@ test('encrypted table: SSE-KMS_MANAGED', () => {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -760,7 +760,7 @@ test('encrypted table: CSE-KMS (implicitly created key)', () => {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -875,7 +875,7 @@ test('encrypted table: CSE-KMS (explicitly created key)', () => {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -992,7 +992,7 @@ test('encrypted table: CSE-KMS (explicitly passed bucket and key)', () => {
{
Ref: 'Bucket83908E77',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -1228,7 +1228,7 @@ test('grants: read only', () => {
'Arn',
],
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -1331,7 +1331,7 @@ test('grants: write only', () => {
'Arn',
],
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -1444,7 +1444,7 @@ test('grants: read and write', () => {
'Arn',
],
},
'/data/',
'/',
],
],
},
Expand Down

0 comments on commit 28949bd

Please sign in to comment.