Skip to content

Table

Source: src/AWS/Glue/Table.ts

An AWS Glue Data Catalog table — a schema (columns), storage location, and SerDe over data in S3 (or another store). This is the unit Athena, Redshift Spectrum, and EMR query; it is the analytics foundation of a Glue database.

import * as AWS from "alchemy/AWS";
const database = yield* AWS.Glue.Database("Analytics", {
databaseName: "analytics",
});
const events = yield* AWS.Glue.Table("Events", {
databaseName: database.databaseName,
tableName: "events",
tableType: "EXTERNAL_TABLE",
storageDescriptor: {
location: "s3://my-data-lake/events/",
inputFormat:
"org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat",
outputFormat:
"org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat",
serdeInfo: {
serializationLibrary:
"org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe",
},
columns: [
{ name: "id", type: "string" },
{ name: "amount", type: "double" },
],
},
partitionKeys: [{ name: "dt", type: "string" }],
parameters: { classification: "parquet" },
});