Skip to content

Commit

Permalink
feat(glue): implement empty string as s3Prefix
Browse files Browse the repository at this point in the history
fixes #8472

BREAKING CHANGE: the default location of glue data will be the root of an s3 bucket, instead of /data
  • Loading branch information
DerkSch committed Jul 10, 2020
1 parent 2386faa commit 04ddd5d
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', {
});
```

The default for `s3Prefix` is the root of the bucket.

#### 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 empty string
*/
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 !== undefined && props.s3Prefix !== null) ? 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/test.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export = {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -140,7 +140,7 @@ export = {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -206,7 +206,7 @@ export = {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -298,7 +298,7 @@ export = {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -442,7 +442,7 @@ export = {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -576,7 +576,7 @@ export = {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -655,7 +655,7 @@ export = {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -769,7 +769,7 @@ export = {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -885,7 +885,7 @@ export = {
{
Ref: 'TableBucketDA42407C',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -1003,7 +1003,7 @@ export = {
{
Ref: 'Bucket83908E77',
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -1244,7 +1244,7 @@ export = {
'Arn',
],
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -1348,7 +1348,7 @@ export = {
'Arn',
],
},
'/data/',
'/',
],
],
},
Expand Down Expand Up @@ -1462,7 +1462,7 @@ export = {
'Arn',
],
},
'/data/',
'/',
],
],
},
Expand Down

0 comments on commit 04ddd5d

Please sign in to comment.