2
0

More than 1 year has passed since last update.

Athenaで削除とタイムトラベル

Last updated at Posted at 2022-04-06

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

スクリーンショット 0004-04-06 9.51.26.png

データインサート

インサート
insert into iceberg_table
values (1, 'ABC', 'CAT'),
(2, 'DEF', 'CAT'),
(3, 'GHI', 'DOG');

スクリーンショット 0004-04-06 9.51.17.png

select *

select *
SELECT * FROM iceberg_table order by id;

スクリーンショット 0004-04-06 9.53.20.png

削除

削除
DELETE FROM iceberg_table WHERE ID=2;

スクリーンショット 0004-04-06 9.54.33.png

select *

select *
SELECT * FROM iceberg_table order by id;

スクリーンショット 0004-04-06 9.55.29.png

タイムトラベル

タイムトラベル
SELECT * FROM iceberg_table FOR SYSTEM_TIME AS OF (current_timestamp - interval '1' minute)

スクリーンショット 0004-04-06 9.55.57.png

注意点

  • MSCK repair
    Icebergテーブルはテーブルレイアウト情報を追跡するため、Hiveテーブルの場合のようにMSCK REPAIR TABLEを実行する必要はなく、サポートされていません。

  • Iceberフォーマットは現在Parquetのみ対応

  • サポートデータタイプ

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0