Skip to content

Commit

Permalink
Change amount type to string and update cdk test
Browse files Browse the repository at this point in the history
  • Loading branch information
hawyar committed Dec 5, 2023
1 parent ba1c6ea commit e0d42b5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion common/data/src/providers/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export class Schema {
let type: GlueType = glue.Schema[typeKey]

if (name == "timestamp") type = glue.Schema.TIMESTAMP
if (name === "amount") type = glue.Schema.FLOAT

const comment = property.description
return { name, type, comment }
Expand Down
2 changes: 1 addition & 1 deletion common/data/src/schemas/event.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"description": "The sender's address"
},
"amount": {
"type": "number",
"type": "string",
"description": "The amount transferred in the event"
}
}
Expand Down
7 changes: 2 additions & 5 deletions infrastructure/cdk/src/providers/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { CfnWorkGroup } from "aws-cdk-lib/aws-athena"
*/
export class AnalyticsStack extends cdk.Stack {
public readonly name = pascalCase("analytics")
public readonly workGroupName: string

constructor(scope: Construct, id: string, props: AnalyticsStackProps) {
super(scope, id, props)
Expand All @@ -34,8 +33,8 @@ export class AnalyticsStack extends cdk.Stack {
bucketName: kebabCase(config.getFullStackResourceName(this.name, "output-bucket", config.dataVersion))
})

const workGroup = new CfnWorkGroup(this, config.getFullStackResourceName(this.name, "workgroup", config.dataVersion), {
name: config.getFullStackResourceName(this.name, "workgroup", config.dataVersion),
new CfnWorkGroup(this, config.getFullStackResourceName(this.name, "workGroup", config.dataVersion), {
name: config.getFullStackResourceName(this.name, "workGroup", config.dataVersion),
recursiveDeleteOption: true,
state: "ENABLED",
workGroupConfiguration: {
Expand All @@ -46,8 +45,6 @@ export class AnalyticsStack extends cdk.Stack {
tags: [{ key: "version", value: config.dataVersion.toString() }],
})

this.workGroupName = workGroup.name

new glue.Table(this, config.getFullStackResourceName(this.name, "event-table", config.dataVersion), {
database: database,
tableName: snakeCase(config.getFullStackResourceName(this.name, "event-table", config.dataVersion)),
Expand Down
5 changes: 3 additions & 2 deletions infrastructure/cdk/test/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test("Analytics stack created", () => {
}

const workgroup = analyticsTemplate.findResources("AWS::Athena::WorkGroup")

expect(workgroup).toBeDefined()
const outputBucket = Object.keys(analyticsTemplate.findResources("AWS::S3::Bucket")).filter(key => key.includes("OutputBucket"))[0]
const workgroupRef = workgroup[Object.keys(workgroup)[0]].Properties.WorkGroupConfiguration.ResultConfiguration.OutputLocation["Fn::Join"][1][1]["Ref"]
expect(workgroupRef).toEqual(outputBucket)
})

0 comments on commit e0d42b5

Please sign in to comment.