Athenaで削除とタイムトラベルをやってみる
公式ドキュメント を参考にやってみた
事前準備
リージョン:東京
S3バケット作成:demo-iceberg-uehara-t
Athenaで作業
ICEBERGのテーブル作成
テーブル作成
CREATE TABLE iceberg_table (
id int,
data string,
category string)
PARTITIONED BY (category, bucket(16,id))
LOCATION 's3://demo-iceberg-uehara-t/athena_iceberg'
TBLPROPERTIES (
'table_type'='ICEBERG',
'format'='parquet',
'write_target_data_file_size_bytes'='536870912',
'optimize_rewrite_delete_file_threshold'='10'
)
データインサート
インサート
insert into iceberg_table
values (1, 'ABC', 'CAT'),
(2, 'DEF', 'CAT'),
(3, 'GHI', 'DOG');
select *
select *
SELECT * FROM iceberg_table order by id;
削除
削除
DELETE FROM iceberg_table WHERE ID=2;
select *
select *
SELECT * FROM iceberg_table order by id;
タイムトラベル
タイムトラベル
SELECT * FROM iceberg_table FOR SYSTEM_TIME AS OF (current_timestamp - interval '1' minute)
注意点
-
MSCK repair
Icebergテーブルはテーブルレイアウト情報を追跡するため、Hiveテーブルの場合のようにMSCK REPAIR TABLEを実行する必要はなく、サポートされていません。 -
Iceberフォーマットは現在Parquetのみ対応