Copy on Write (CoW), Tabellenbeispiele erstellen - Amazon Athena

Copy on Write (CoW), Tabellenbeispiele erstellen

Wenn Sie bereits in AWS Glue erstellte Hudi-Tabellen haben, können Sie diese direkt in Athena abfragen. Wenn Sie in Athena partitionierte Hudi-Tabellen erstellen, müssen Sie ALTER TABLE ADD PARTITION ausführen, um die Hudi-Daten zu laden, bevor Sie sie abfragen können.

Nicht partitionierte CoW-Tabelle

Im folgenden Beispiel wird eine unpartitionierte CoW-Tabelle in Athena erstellt.

CREATE EXTERNAL TABLE `non_partition_cow`( `_hoodie_commit_time` string, `_hoodie_commit_seqno` string, `_hoodie_record_key` string, `_hoodie_partition_path` string, `_hoodie_file_name` string, `event_id` string, `event_time` string, `event_name` string, `event_guests` int, `event_type` string) ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe' STORED AS INPUTFORMAT 'org.apache.hudi.hadoop.HoodieParquetInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat' LOCATION 's3://amzn-s3-demo-bucket/folder/non_partition_cow/'

Partitionierte CoW-Tabelle

Im folgenden Beispiel wird eine partitionierte CoW-Tabelle in Athena erstellt.

CREATE EXTERNAL TABLE `partition_cow`( `_hoodie_commit_time` string, `_hoodie_commit_seqno` string, `_hoodie_record_key` string, `_hoodie_partition_path` string, `_hoodie_file_name` string, `event_id` string, `event_time` string, `event_name` string, `event_guests` int) PARTITIONED BY ( `event_type` string) ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe' STORED AS INPUTFORMAT 'org.apache.hudi.hadoop.HoodieParquetInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat' LOCATION 's3://amzn-s3-demo-bucket/folder/partition_cow/'

Im folgenden ALTER TABLE ADD PARTITION-Beispiel werden der partition_cow-Beispieltabelle zwei Partitionen hinzugefügt.

ALTER TABLE partition_cow ADD PARTITION (event_type = 'one') LOCATION 's3://amzn-s3-demo-bucket/folder/partition_cow/one/' PARTITION (event_type = 'two') LOCATION 's3://amzn-s3-demo-bucket/folder/partition_cow/two/'