diff --git a/packages/@aws-cdk/aws-glue/README.md b/packages/@aws-cdk/aws-glue/README.md index 3f61ce18700b7..d7bb3cad73639 100644 --- a/packages/@aws-cdk/aws-glue/README.md +++ b/packages/@aws-cdk/aws-glue/README.md @@ -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: diff --git a/packages/@aws-cdk/aws-glue/lib/table.ts b/packages/@aws-cdk/aws-glue/lib/table.ts index 6e65278fbb7d0..3ed844d2d600a 100644 --- a/packages/@aws-cdk/aws-glue/lib/table.ts +++ b/packages/@aws-cdk/aws-glue/lib/table.ts @@ -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; @@ -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; diff --git a/packages/@aws-cdk/aws-glue/test/integ.table.expected.json b/packages/@aws-cdk/aws-glue/test/integ.table.expected.json index c56c5990fe7cf..8be4979ba9ba2 100644 --- a/packages/@aws-cdk/aws-glue/test/integ.table.expected.json +++ b/packages/@aws-cdk/aws-glue/test/integ.table.expected.json @@ -71,7 +71,7 @@ { "Ref": "DataBucketE3889A50" }, - "/data/" + "/" ] ] }, @@ -140,7 +140,7 @@ { "Ref": "DataBucketE3889A50" }, - "/data/" + "/" ] ] }, @@ -209,7 +209,7 @@ { "Ref": "DataBucketE3889A50" }, - "/data/" + "/" ] ] }, @@ -278,7 +278,7 @@ { "Ref": "DataBucketE3889A50" }, - "/data/" + "/" ] ] }, @@ -439,7 +439,7 @@ { "Ref": "MyEncryptedTableBucket7B28486D" }, - "/data/" + "/" ] ] }, @@ -532,7 +532,7 @@ "Arn" ] }, - "/data/" + "/" ] ] } @@ -609,7 +609,7 @@ "Arn" ] }, - "/data/" + "/" ] ] } @@ -721,7 +721,7 @@ "Arn" ] }, - "/data/" + "/" ] ] } @@ -827,4 +827,4 @@ } } } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/aws-glue/test/table.test.ts b/packages/@aws-cdk/aws-glue/test/table.test.ts index 70d4caf3d5242..592fadf650165 100644 --- a/packages/@aws-cdk/aws-glue/test/table.test.ts +++ b/packages/@aws-cdk/aws-glue/test/table.test.ts @@ -62,7 +62,7 @@ test('unpartitioned JSON table', () => { { Ref: 'TableBucketDA42407C', }, - '/data/', + '/', ], ], }, @@ -139,7 +139,7 @@ test('partitioned JSON table', () => { { Ref: 'TableBucketDA42407C', }, - '/data/', + '/', ], ], }, @@ -204,7 +204,7 @@ test('compressed table', () => { { Ref: 'TableBucketDA42407C', }, - '/data/', + '/', ], ], }, @@ -293,7 +293,7 @@ test('encrypted table: SSE-S3', () => { { Ref: 'TableBucketDA42407C', }, - '/data/', + '/', ], ], }, @@ -436,7 +436,7 @@ test('encrypted table: SSE-KMS (implicitly created key)', () => { { Ref: 'TableBucketDA42407C', }, - '/data/', + '/', ], ], }, @@ -569,7 +569,7 @@ test('encrypted table: SSE-KMS (explicitly created key)', () => { { Ref: 'TableBucketDA42407C', }, - '/data/', + '/', ], ], }, @@ -647,7 +647,7 @@ test('encrypted table: SSE-KMS_MANAGED', () => { { Ref: 'TableBucketDA42407C', }, - '/data/', + '/', ], ], }, @@ -760,7 +760,7 @@ test('encrypted table: CSE-KMS (implicitly created key)', () => { { Ref: 'TableBucketDA42407C', }, - '/data/', + '/', ], ], }, @@ -875,7 +875,7 @@ test('encrypted table: CSE-KMS (explicitly created key)', () => { { Ref: 'TableBucketDA42407C', }, - '/data/', + '/', ], ], }, @@ -992,7 +992,7 @@ test('encrypted table: CSE-KMS (explicitly passed bucket and key)', () => { { Ref: 'Bucket83908E77', }, - '/data/', + '/', ], ], }, @@ -1228,7 +1228,7 @@ test('grants: read only', () => { 'Arn', ], }, - '/data/', + '/', ], ], }, @@ -1331,7 +1331,7 @@ test('grants: write only', () => { 'Arn', ], }, - '/data/', + '/', ], ], }, @@ -1444,7 +1444,7 @@ test('grants: read and write', () => { 'Arn', ], }, - '/data/', + '/', ], ], },