Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Apache Iceberg REST catalog on AWS 〜AWS Glue Ic...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Noritaka Sekiyama Noritaka Sekiyama
June 17, 2025
770

Apache Iceberg REST catalog on AWS 〜AWS Glue Iceberg REST catalog と Amazon S3 Tables の話〜

OTFSG Osaka #1 現地開催でのセッション資料です。https://otfsg-tokyo.connpass.com/event/352637/

この発表では、Apache Iceberg を AWS 上で実践的に活用する方法、特に昨今ますます注目を集める Iceberg REST Catalog API をAWS Glue Catalog で使う方法や、昨年の re:Invent 2024 でリリースされた Amazon S3 Tables の活用方法をデモを交えて紹介します。

Avatar for Noritaka Sekiyama

Noritaka Sekiyama

June 17, 2025
Tweet

Transcript

  1. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Apache Iceberg REST catalog on AWS Noritaka Sekiyama O T F S G O S A K A M E E T U P # 1 Principal Big Data Architect, AWS Analytics Amazon Web Services 1 〜AWS Glue Iceberg REST catalog と Amazon S3 Tables の話〜
  2. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 関⼭ 宜孝 Principal Big Data Architect, AWS Analytics • プロダクト開発チームにて、AI とデータに関する サービス開発と、お客様の技術⽀援を担当 ⾃⼰紹介 @moomindani moomindani
  3. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Iceberg Catalog おさらい 3 manifest list manifest File manifest File manifest File Data Files Data Files Delete Files S2 メタデータ層 データ層 manifest list metadata file Iceberg カタログ Db1.table1 S1 metadata file S1 • テーブル情報の管理と トランザクションの⼀貫性の保証を担う • metadata file のロケーションをポイント
  4. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. (参考) Iceberg テーブル on AWS の使い分け S3 テーブルバケット • Glue Data Catalog と組み合わせて Iceberg テーブルを構成 • 表形式のデータに最適化された新しいバケットタイプで、 Iceberg をフルマネージドに提供 S3 汎⽤バケット • Glue Data Catalog によってメンテナンスを⾃動化 • カスタマイズ性が⾼く、Iceberg や S3 の機能を 隅々まで活⽤可能 • テーブルの内部的な仕組みを意識することなく、 効率的に Iceberg を利⽤可能 • S3 テーブルバケット単独でメンテナンスを⾃動化
  5. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Iceberg REST Catalog おさらい (1/2) Iceberg カタログ 提供サービス A Iceberg カタログ 提供サービス B カタログA ⽤の実装 カタログB ⽤実装 従来 (Iceberg REST API のない世界) クエリエンジンは接続先のカタログの仕様を 「知っている」必要があった (各カタログに対応した実装が必要) 5 クエリエンジン • 多様なカタログ実装が存在 (Hive Metastore、AWS Glueなど) • 異なるカタログ間でのIcebergテーブル 管理には従来カスタム統合が必要 • 相互運⽤性が課題となっていた
  6. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Iceberg REST Catalog おさらい (2/2) Iceberg REST API のある世界 クエリエンジン Iceberg REST Open API 仕様 Iceberg REST Catalog ⽤の実装 標準化された Open API 仕様さえ「知っていれば」 個別のカタログ専⽤の実装が不要になる Iceberg カタログ 提供サービス A Iceberg カタログ 提供サービス B 6 • 相互運⽤性の向上 • ⾔語⾮依存性 • REST APIにより、任意の⾔語(Python、 Javaなど)で書かれたカタログと Icebergクライアントが⼀貫して相互作⽤ • クラウドネイティブな柔軟性 • HTTPベースのため、RESTful相互作⽤が標 準のクラウド環境に適している
  7. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Iceberg REST Catalog API https://iceberg.apache.org/spec/ 7
  8. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Glue Iceberg REST Catalog • Glue Data Catalog を Iceberg REST API で利⽤ • S3 汎⽤バケットと S3 テーブルバケット (S3 Tables) の両⽅に対応 S3 Tables REST Catalog • S3 テーブルバケット (S3 Tables) 専⽤の Iceberg REST Catalog 9 Iceberg REST Catalog on AWS の選択肢
  9. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Glue Iceberg REST Catalog • Iceberg table spec v1 と v2 に対応 (デフォルト: v2) • エンドポイント(リージョン固有)︓ https://glue.<REGION>.amazonaws.com/iceberg • 対応 REST API § GetConfig, ListNamespaces, CreateNamespace, LoadNamespaceMetadata, UpdateNamespaceProperties, DeleteNamespace, ListTables, CreateTable, LoadTable, TableExists, UpdateTable, DeleteTable • View API には現状⾮対応 • (S3 上のテーブルに対する) RenameTable API には現状⾮対応 10
  10. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. S3 Tables REST Catalog • エンドポイント(リージョン固有)︓ https://s3tables.<REGION>.amazonaws.com/iceberg • 対応 REST API § GetConfig, ListNamespaces, CreateNamespace, LoadNamespaceMetadata, DropNamespace, ListTables, CreateTable, LoadTable, RenameTable, TableExists, NamespaceExists, UpdateTable, DropTable • View API には現状⾮対応 • スナップショット管理や圧縮などのテーブルメンテナンスには S3 Tables のメン テナンス API オペレーションを使⽤ 11
  11. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Glue Iceberg REST Catalog • その他のアクセスシナリオ • きめ細やかなアクセスコントロール等 S3 Tables REST Catalog • 1 つの S3 テーブルバケットへの基本的な 読み取り/書き込みアクセスのみが必要な アクセスシナリオ 12 Iceberg REST Catalog on AWS の使い分け S3 汎⽤バケットと S3 Tables (テーブルバケット) の使い分けではなく あくまで Iceberg REST Catalog の使い分け
  12. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 13 Spark の場合 from pyspark.sql import SparkSession spark = SparkSession.builder.appName("glue_iceberg_rest_catalog") \ .config("spark.sql.extensions", "org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions") \ .config("spark.sql.defaultCatalog", "glue_iceberg_rest_catalog") \ .config("spark.sql.catalog.glue_iceberg_rest_catalog", "org.apache.iceberg.spark.SparkCatalog") \ .config("spark.sql.catalog.glue_iceberg_rest_catalog.type", "rest") \ .config("spark.sql.catalog.glue_iceberg_rest_catalog.uri", "https://glue.us-east-2.amazonaws.com/iceberg" .config("spark.sql.catalog.glue_iceberg_rest_catalog.warehouse", "123456789012") \ .config("spark.sql.catalog.glue_iceberg_rest_catalog.rest.sigv4-enabled", "true") \ .config("spark.sql.catalog.glue_iceberg_rest_catalog.rest.signing-name", "glue") \ .config("spark.sql.catalog.glue_iceberg_rest_catalog.rest.signing-region", "us-east-2") \ .getOrCreate() spark.sql(""" CREATE TABLE IF NOT EXISTS iceberg_sql.test_table ( id INT, name STRING, value INT ) LOCATION 's3://path_to_data/' """)
  13. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. デモ • Apache Spark から Iceberg REST を使って Iceberg テーブルを作成する 14 AWS Glue (Apache Spark) S3 汎⽤バケット S3 テーブルバケット Iceberg テーブル Iceberg REST Catalog Spark の場合
  14. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 17 # Configure the catalog catalog_properties = { "type": "rest", "uri": f"https://glue.{region}.amazonaws.com/iceberg", "s3.region": region, "rest.sigv4-enabled": "true", "rest.signing-name": "glue", "rest.signing-region": region } catalog = load_catalog(**catalog_properties) database_name = os.environ.get('GLUE_DATABASE_NAME') table_name = os.environ.get('ICEBERG_TABLE_NAME') identifier = f"{database_name}.{table_name}" # Create the table if it doesn't exist location = f"s3://pyiceberg-lambda-blog-{account_id}-{region}/{database_name}/{table_name}" if not catalog.table_exists(identifier): table = catalog.create_table( identifier=identifier, schema=schema, location=location, partition_spec=partition_spec, sort_order=sort_order ) else: table = catalog.load_table(identifier=identifier) PyIceberg の場合
  15. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Flink の場合 18 CREATE CATALOG irccat WITH ( 'type'='iceberg', 'warehouse'='123456789012', 'catalog-type'='rest', 'rest.sigv4-enabled'='true', 'rest.signing-name'='glue', 'uri'='https://glue.us-east-1.amazonaws.com/iceberg' ); USE CATALOG irccat; CREATE TABLE db.ice_1_irc (id int, name string) WITH ('location'='s3://amzn-s3-demo-bucket/data/iceberg-flink');
  16. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. awscurl の場合 19 123456789012 example
  17. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 実は... • AWS では Amazon Redshift 上のテーブルも Iceberg テーブルとして扱うこと ができる (Amazon SageMaker Lakehouse に含まれる機能) • このアクセスシナリオの場合、通常の AWS Glue Iceberg REST Catalog Endpoint に加えて、AWS Glue Iceberg REST Catalog Extension Endpoint を併⽤する • エンドポイント(リージョン固有)︓ https://glue.<REGION>.amazonaws.com/extensions • さらに、この Iceberg Catalog へのアクセスを透過的に実⾏するための Spark 向けの拡張ライブラリを提供しており、EMR や Glue ではデフォルトで有効 https://github.com/awslabs/glue-extensions-for-iceberg 20 Advanced
  18. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. まとめ • Iceberg REST Catalog は従来の Iceberg Catalog の課題を解決する • AWS には利⽤できる Iceberg REST Catalog がふたつある • S3 テーブルのみのシンプルなユースケースでは S3 Tables REST Catalog, それ 以外のユースケースでは AWS Glue Iceberg REST Catalog を推奨 • Spark/PyIceberg/Flink などさまざまなアプリケーションから Iceberg REST Catalog を使⽤して Iceberg テーブルにアクセスできる 21
  19. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. おまけ • 2025/06/02 StorageJAWS x BigData JAWS 共同開催 ~ S3×Icebergが切り拓く、OTF時代の分析基盤~ https://www.youtube.com/live/OOwBsMaAVK4?t=1830s 22