Skip to content

Commit

Permalink
fix(aws-glue): fix glue tableArn and integer schema name (#2585)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Goodwin authored and rix0rrr committed May 21, 2019
1 parent eb35807 commit 99e173e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-glue/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class Schema {
*/
public static readonly integer: Type = {
isPrimitive: true,
inputString: 'integer'
inputString: 'int'
};

/**
Expand Down
14 changes: 12 additions & 2 deletions packages/@aws-cdk/aws-glue/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ export class Table extends Resource implements ITable {
*/
public readonly database: IDatabase;

/**
* Indicates whether the table's data is compressed or not.
*/
public readonly compressed: boolean;

/**
* The type of encryption enabled for the table.
*/
Expand Down Expand Up @@ -235,6 +240,7 @@ export class Table extends Resource implements ITable {
this.columns = props.columns;
this.partitionKeys = props.partitionKeys;

this.compressed = props.compressed === undefined ? false : props.compressed;
const {bucket, encryption, encryptionKey} = createBucket(this, props);
this.bucket = bucket;
this.encryption = encryption;
Expand All @@ -256,7 +262,7 @@ export class Table extends Resource implements ITable {
},
storageDescriptor: {
location: `s3://${this.bucket.bucketName}/${this.s3Prefix}`,
compressed: props.compressed === undefined ? false : props.compressed,
compressed: this.compressed,
storedAsSubDirectories: props.storedAsSubDirectories === undefined ? false : props.storedAsSubDirectories,
columns: renderColumns(props.columns),
inputFormat: props.dataFormat.inputFormat.className,
Expand All @@ -271,7 +277,11 @@ export class Table extends Resource implements ITable {
});

this.tableName = tableResource.tableName;
this.tableArn = `${this.database.databaseArn}/${this.tableName}`;
this.tableArn = this.node.stack.formatArn({
service: 'glue',
resource: 'table',
resourceName: `${this.database.databaseName}/${this.tableName}`
});
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-glue/test/integ.table.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
{
"Ref": "AWS::AccountId"
},
":database/",
":table/",
{
"Ref": "MyDatabase1E2517DB"
},
Expand Down Expand Up @@ -373,7 +373,7 @@
{
"Ref": "AWS::AccountId"
},
":database/",
":table/",
{
"Ref": "MyDatabase1E2517DB"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-glue/test/test.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export = {
},

'integer type'(test: Test) {
test.equals(Schema.integer.inputString, 'integer');
test.equals(Schema.integer.inputString, 'int');
test.equals(Schema.integer.isPrimitive, true);
test.done();
},
Expand Down Expand Up @@ -167,12 +167,12 @@ export = {
test.done();
},

'map<integer,string>'(test: Test) {
'map<int,string>'(test: Test) {
const type = Schema.map(
Schema.integer,
Schema.string
);
test.equals(type.inputString, 'map<integer,string>');
test.equals(type.inputString, 'map<int,string>');
test.equals(type.isPrimitive, false);
test.done();
},
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-glue/test/test.table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ export = {
{
Ref: "AWS::AccountId"
},
":database/",
":table/",
{
Ref: "DatabaseB269D8BB"
},
Expand Down Expand Up @@ -1201,7 +1201,7 @@ export = {
{
Ref: "AWS::AccountId"
},
":database/",
":table/",
{
Ref: "DatabaseB269D8BB"
},
Expand Down Expand Up @@ -1312,7 +1312,7 @@ export = {
{
Ref: "AWS::AccountId"
},
":database/",
":table/",
{
Ref: "DatabaseB269D8BB"
},
Expand Down

0 comments on commit 99e173e

Please sign in to comment.