in Gems/AWSMetrics/cdk/aws_metrics/data_lake_integration.py [0:0]
def _create_events_table(self) -> None:
"""
Create the Glue table for metrics events. This table is used by the Kinesis Data Firehose
to convert data from the JSON format to the Parquet format before writing it to Amazon S3.
"""
self._events_table = glue.CfnTable(
self._stack,
id=f'EventsTable',
catalog_id=self._stack.account,
database_name=self._events_database.ref,
table_input=glue.CfnTable.TableInputProperty(
description=f'Stores metrics event data from the analytics pipeline for stack {self._stack.stack_name}',
name=aws_metrics_constants.GLUE_TABLE_NAME,
table_type='EXTERNAL_TABLE',
partition_keys=[
glue.CfnTable.ColumnProperty(
name='year',
type='string'
),
glue.CfnTable.ColumnProperty(
name='month',
type='string'
),
glue.CfnTable.ColumnProperty(
name='day',
type='string'
),
],
parameters={
'classification': 'parquet',
'compressionType': 'none',
'typeOfData': 'file'
},
storage_descriptor=glue.CfnTable.StorageDescriptorProperty(
input_format=aws_metrics_constants.GLUE_TABLE_INPUT_FORMAT,
output_format=aws_metrics_constants.GLUE_TABLE_OUTPUT_FORMAT,
serde_info=glue.CfnTable.SerdeInfoProperty(
serialization_library=aws_metrics_constants.GLUE_TABLE_SERIALIZATION_LIBRARY,
parameters={
'serialization.format':
aws_metrics_constants.GLUE_TABLE_SERIALIZATION_LIBRARY_SERIALIZATION_FORMAT
}
),
stored_as_sub_directories=False,
location=f's3://{self._analytics_bucket.bucket_name}/{aws_metrics_constants.GLUE_TABLE_NAME}/',
columns=[
glue.CfnTable.ColumnProperty(
name='event_id',
type='string'
),
glue.CfnTable.ColumnProperty(
name='event_type',
type='string'
),
glue.CfnTable.ColumnProperty(
name='event_name',
type='string'
),
glue.CfnTable.ColumnProperty(
name='event_timestamp',
type='string'
),
glue.CfnTable.ColumnProperty(
name='event_version',
type='string'
),
glue.CfnTable.ColumnProperty(
name='event_source',
type='string'
),
glue.CfnTable.ColumnProperty(
name='application_id',
type='string'
),
glue.CfnTable.ColumnProperty(
name='event_data',
type='string'
)
]
)
)
)