Gems/AWSMetrics/cdk/aws_metrics/data_lake_integration.py [98:211]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            self._stack,
            id='EventDatabaseName',
            description='Glue database for metrics events.',
            export_name=f"{self._application_name}:EventsDatabase",
            value=self._events_database.ref)

    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'
                        )
                    ]
                )
            )
        )

    def _create_events_crawler(self) -> None:
        """
        Create the Glue crawler to populate the AWS Glue Data Catalog with tables.
        """
        self._create_events_crawler_role()

        self._events_crawler = glue.CfnCrawler(
            self._stack,
            id='EventsCrawler',
            name=f'{self._stack.stack_name}-EventsCrawler',
            role=self._events_crawler_role.role_arn,
            database_name=self._events_database.ref,
            targets=glue.CfnCrawler.TargetsProperty(
                s3_targets=[
                    glue.CfnCrawler.S3TargetProperty(
                        path=f's3://{self._analytics_bucket.bucket_name}/{aws_metrics_constants.GLUE_TABLE_NAME}/'
                    )
                ]
            ),
            schema_change_policy=glue.CfnCrawler.SchemaChangePolicyProperty(
                update_behavior='UPDATE_IN_DATABASE',
                delete_behavior='LOG',
            ),
            configuration=aws_metrics_constants.CRAWLER_CONFIGURATION
        )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



Gems/AWSMetrics/cdv1/aws_metrics/data_lake_integration.py [93:206]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            self._stack,
            id='EventDatabaseName',
            description='Glue database for metrics events.',
            export_name=f"{self._application_name}:EventsDatabase",
            value=self._events_database.ref)

    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'
                        )
                    ]
                )
            )
        )

    def _create_events_crawler(self) -> None:
        """
        Create the Glue crawler to populate the AWS Glue Data Catalog with tables.
        """
        self._create_events_crawler_role()

        self._events_crawler = glue.CfnCrawler(
            self._stack,
            id='EventsCrawler',
            name=f'{self._stack.stack_name}-EventsCrawler',
            role=self._events_crawler_role.role_arn,
            database_name=self._events_database.ref,
            targets=glue.CfnCrawler.TargetsProperty(
                s3_targets=[
                    glue.CfnCrawler.S3TargetProperty(
                        path=f's3://{self._analytics_bucket.bucket_name}/{aws_metrics_constants.GLUE_TABLE_NAME}/'
                    )
                ]
            ),
            schema_change_policy=glue.CfnCrawler.SchemaChangePolicyProperty(
                update_behavior='UPDATE_IN_DATABASE',
                delete_behavior='LOG',
            ),
            configuration=aws_metrics_constants.CRAWLER_CONFIGURATION
        )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



