Exemples de création de table par fusion sur lecture (MoR)
Hudi crée deux tables dans le métastore pour MoR : une table pour les requêtes d'instantané et une table pour les requêtes à lecture optimisée. Les deux tables peuvent être interrogées. Dans les versions de Hudi antérieures à 0.5.1, la table pour les requêtes à lecture optimisée avait le nom que vous aviez spécifié lorsque vous avez créé la table. À partir de la version 0.5.1 de Hudi, le nom de la table est suffixé par défaut par le suffixe _ro. Le nom de la table pour les requêtes d'instantané est le nom que vous avez spécifié, suivi de _rt.
Table non partitionnée à fusion sur lecture (MoR)
L'exemple suivant crée une table MoR non partitionnée dans Athena pour les requêtes à lecture optimisée. Notez que les requêtes à lecture optimisée utilisent le format d'entrée HoodieParquetInputFormat.
CREATE EXTERNAL TABLE `nonpartition_mor`( `_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/nonpartition_mor/'
L'exemple suivant crée une table MoR non partitionnée dans Athena pour les requêtes d'instantané. Pour les requêtes d'instantané, utilisez le format d'entrée HoodieParquetRealtimeInputFormat.
CREATE EXTERNAL TABLE `nonpartition_mor_rt`( `_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.realtime.HoodieParquetRealtimeInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat' LOCATION 's3://amzn-s3-demo-bucket/folder/nonpartition_mor/'
Table partitionnée à fusion sur lecture (MoR)
L'exemple suivant crée une table MoR partitionnée dans Athena pour les requêtes à lecture optimisée.
CREATE EXTERNAL TABLE `partition_mor`( `_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_mor/'
L'exemple ALTER TABLE ADD PARTITION suivant ajoute deux partitions à la table partition_mor en exemple.
ALTER TABLE partition_mor ADD PARTITION (event_type = 'one') LOCATION 's3://amzn-s3-demo-bucket/folder/partition_mor/one/' PARTITION (event_type = 'two') LOCATION 's3://amzn-s3-demo-bucket/folder/partition_mor/two/'
L'exemple suivant crée une table MoR partitionnée dans Athena pour les requêtes d'instantané.
CREATE EXTERNAL TABLE `partition_mor_rt`( `_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.realtime.HoodieParquetRealtimeInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat' LOCATION 's3://amzn-s3-demo-bucket/folder/partition_mor/'
De même, l'exemple ALTER TABLE ADD PARTITION suivant ajoute deux partitions à la table partition_mor_rt en exemple.
ALTER TABLE partition_mor_rt ADD PARTITION (event_type = 'one') LOCATION 's3://amzn-s3-demo-bucket/folder/partition_mor/one/' PARTITION (event_type = 'two') LOCATION 's3://amzn-s3-demo-bucket/folder/partition_mor/two/'