Apache Iceberg v2 & Object Storage Configuration
Every columnstore mirror table in pg_mooncake (v0.3.0) is backed by moonlink, which writes data as standard Parquet files and maintains Apache Iceberg v2 table metadata.
By default, Moonlink writes files to the local filesystem under $PGDATA/pg_mooncake/. You can configure pg_mooncake to write directly to Amazon S3, Cloudflare R2, MinIO, or Google Cloud Storage (GCS) so external engines (DuckDB, Apache Spark, Trino, Snowflake, PyIceberg) can query your PostgreSQL tables directly from object storage.
1. Configure Object Storage Credentials (duckdb.secrets)
pg_mooncake reads object storage credentials from pg_duckdb’s duckdb.secrets table and passes them to both Moonlink and DuckDB.
Amazon S3
Cloudflare R2 / S3-Compatible (MinIO)
2. Configure Table Storage (table_config & mooncake.default_bucket)
In pg_mooncake v0.3.0, you can configure S3 / R2 / GCS storage directly in the table_config JSON parameter of mooncake.create_table (or set mooncake.default_bucket as documented in upstream v0.1/v0.2 guides):
3. Materialize an Apache Iceberg v2 Snapshot
While in-database queries on orders_analytics automatically read both flushed Parquet files and Moonlink’s in-memory Arrow write buffer, external Iceberg readers only see data that has been flushed into an Iceberg metadata snapshot.
To force-flush all committed rows up to the current PostgreSQL WAL LSN and write a new v*.metadata.json file:
v0.3.0 (moonlink v0.0.1)In pg_mooncake 0.3.0, CALL mooncake.create_snapshot('orders_analytics') completes immediately even if the database WAL has advanced due to writes on other, unrelated tables since the last write to orders.
4. Locate the Iceberg Warehouse & Query Externally
Use mooncake.list_tables() to inspect the commit LSN, flushed LSN, and exact iceberg_warehouse_location:
Example output:
Querying from External DuckDB / PyIceberg / Spark
Inside the iceberg_warehouse_location directory, Moonlink writes standard Apache Iceberg v2 metadata (metadata/v1.metadata.json, v2.metadata.json, etc.):
5. Compacting Files (mooncake.optimize_table)
To compact small Parquet files and reconcile Roaring Bitmap deletion vectors into clean base files: