NewsCrawler.org

Lakehouse integration with S3 Tables and Snowflake

S3 Tables + Snowflake を使用した Lakehouse 統合
Image: zenn.dev

EVERSTEEL's data platform collects large volumes of images and videos every day and manages their metadata, such as S3 paths and sizes, and the team has rebuilt this pipeline as a lakehouse[1] on AWS S3 Tables, a fully managed service for Apache Iceberg[2] tables. In the previous architecture, S3 events triggered a Lambda function that computed image sizes and hashes and generated Parquet files, which were loaded into Snowflake through an external stage with COPY INTO, leaving Snowflake native tables as the single source of truth for the metadata. That setup had drawbacks: anyone with the right permissions could run DELETE or DROP, recovery depended on Snowflake Time Travel[3], whose retention period is limited, and keeping the source of truth inside Snowflake would complicate any future move to other services.

The migration pursues three goals: protect raw data by making S3 Tables the source of truth, with Iceberg snapshots enabling time travel that can retain snapshots longer than Snowflake Time Travel; cut storage costs by eliminating the current double storage of data as Parquet in S3 plus Snowflake native tables, with S3 Tables compaction merging small Parquet files and speeding up reads from Snowflake; and separate storage from the query engine, so a future analytics service could start by simply being given access to S3 Tables, reducing dependence on Snowflake.

S3 Tables itself acts as an Iceberg catalog with a REST endpoint (https://s3tables.<region>.amazonaws.com/iceberg): a Lambda function writes the metadata through PyIceberg and Snowflake reads the same tables, both connecting directly and accessing data with Vended Credentials[4] — temporary, scope-limited credentials — because S3 Tables supports no other authentication method for catalog integration. Glue Data Catalog integration was enabled only so the tables can be queried from Athena; the main data path through Lambda and Snowflake does not use Glue. Setup involved creating a table bucket in the console, a namespace (the equivalent of a database) through the AWS CLI, and the table plus its data load through PyIceberg, since Athena does not yet support some table-creation syntax such as NOT NULL constraints. Two quirks matter when loading data: PyIceberg does not support nanosecond timestamps, so columns must be cast to timestamp[us, tz=UTC], and columns declared required in the Iceberg schema must be non-nullable in PyArrow to avoid schema mismatch errors. Snowflake connects through an IAM role with SigV4 authentication and a catalog integration defined with CATALOG_SOURCE = ICEBERG_REST.

Read the original zenn.dev

Sources

  • Zenn JA

    S3 Tables + Snowflake を使用した Lakehouse 統合

    5 likes1 bookmark0 comments

Published: First seen: Читать по-русски

Open as a page