Created
June 15, 2023 03:05
-
-
Save tacck/ceda1f1d750b1be217d1e08b7a1762b2 to your computer and use it in GitHub Desktop.
AWS CDK sample for Athena settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////// Athena ////////// | |
const dataCatalogAggregate = new athena.CfnDataCatalog( | |
scope, | |
"dataCatalogAggregate", | |
{ | |
name: "dataCatalogAggregate", | |
type: "GLUE", | |
parameters: { | |
"catalog-id": accountId, | |
}, | |
} | |
); | |
const DATABASE_NAME = "database_sample"; | |
const databaseAggregate = new glue.CfnDatabase(scope, "databaseAggregate", { | |
catalogId: accountId, | |
databaseInput: { | |
name: DATABASE_NAME, | |
}, | |
}); | |
const table = new glue.CfnTable( | |
scope, | |
"tableCodeProviderAggregate", | |
{ | |
databaseName: DATABASE_NAME, | |
catalogId: accountId, | |
tableInput: { | |
name: "table_sample", | |
description: "table_sample", | |
parameters: { | |
classification: "csv", | |
"projection.enabled": "true", | |
"projection.target_date.type": "date", | |
"projection.target_date.range": "2023/06/01,NOW+9HOURS", | |
"projection.target_date.format": "yyyy/MM/dd", | |
"projection.target_date.interval": 1, | |
"projection.target_date.interval.unit": "DAYS", | |
"projection.source_type.type": "injected", | |
"storage.location.template": `s3://${bucketNameConvert}/\${target_date}/\${source_type}/`, | |
}, | |
tableType: "EXTERNAL_TABLE", | |
partitionKeys: [ | |
{ name: "target_date", type: "string" }, | |
{ name: "source_type", type: "string" }, | |
], | |
storageDescriptor: { | |
location: `s3://${bucketNameConvert}`, | |
columns: [ | |
{ name: "trade_datetime", type: "string" }, | |
{ name: "year", type: "int" }, | |
{ name: "month", type: "int" }, | |
{ name: "date", type: "int" }, | |
{ name: "source_type_value", type: "string" }, | |
{ name: "amount", type: "int" }, | |
], | |
// compressed: true, | |
serdeInfo: { | |
serializationLibrary: | |
"org.apache.hadoop.hive.serde2.OpenCSVSerde", | |
parameters: { | |
separatorChar: ",", | |
quoteChar: '"', | |
escapeChar: "\\", | |
}, | |
}, | |
inputFormat: "org.apache.hadoop.mapred.TextInputFormat", | |
outputFormat: | |
"org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat", | |
}, | |
}, | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment