Skip to content

pg_lake

Data lake extension by Snowflake

pg_lake · Data lake extension by Snowflake

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2560pg_lakepg_lake3.7OLAPApache-2.0C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd--YesYesYesYesnono
No EL8; preload pg_extension_base; matching pgduck_server.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY3.719 18 17 16 15pg_lakepg_lake_copy, pg_lake_table
RPMPIGSTY3.7.419 18 17 16 15pg_lake_$v-
DEBPIGSTY3.7.419 18 17 16 15postgresql-$v-pg-lake-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/AN/AN/AN/AN/A
el8.aarch64N/AN/AN/AN/AN/A
el9.x86_64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
el9.aarch64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
el10.x86_64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
el10.aarch64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
d12.x86_64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
d12.aarch64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
d13.x86_64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
d13.aarch64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
u22.x86_64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
u22.aarch64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
u24.x86_64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
u24.aarch64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
u26.x86_64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
u26.aarch64PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4PIGSTY 3.7.4N/A
PackageVersionOSORGSIZEFile URL
pg_lake_193.7.4el9.x86_64pigsty21.3 MiBpg_lake_19-3.7.4-1PGSTY.el9.x86_64.rpm
pg_lake_193.7.4el9.aarch64pigsty19.5 MiBpg_lake_19-3.7.4-1PGSTY.el9.aarch64.rpm
pg_lake_193.7.4el10.x86_64pigsty22.3 MiBpg_lake_19-3.7.4-1PGSTY.el10.x86_64.rpm
pg_lake_193.7.4el10.aarch64pigsty20.1 MiBpg_lake_19-3.7.4-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-lake3.7.4d12.x86_64pigsty20.6 MiBpostgresql-19-pg-lake_3.7.4-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-lake3.7.4d12.aarch64pigsty18.3 MiBpostgresql-19-pg-lake_3.7.4-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-lake3.7.4d13.x86_64pigsty21.6 MiBpostgresql-19-pg-lake_3.7.4-1PGSTY~trixie_amd64.deb
postgresql-19-pg-lake3.7.4d13.aarch64pigsty19.1 MiBpostgresql-19-pg-lake_3.7.4-1PGSTY~trixie_arm64.deb
postgresql-19-pg-lake3.7.4u22.x86_64pigsty20.5 MiBpostgresql-19-pg-lake_3.7.4-1PGSTY~jammy_amd64.deb
postgresql-19-pg-lake3.7.4u22.aarch64pigsty19.1 MiBpostgresql-19-pg-lake_3.7.4-1PGSTY~jammy_arm64.deb
postgresql-19-pg-lake3.7.4u24.x86_64pigsty20.6 MiBpostgresql-19-pg-lake_3.7.4-1PGSTY~noble_amd64.deb
postgresql-19-pg-lake3.7.4u24.aarch64pigsty19.3 MiBpostgresql-19-pg-lake_3.7.4-1PGSTY~noble_arm64.deb
postgresql-19-pg-lake3.7.4u26.x86_64pigsty21.2 MiBpostgresql-19-pg-lake_3.7.4-1PGSTY~resolute_amd64.deb
postgresql-19-pg-lake3.7.4u26.aarch64pigsty20.1 MiBpostgresql-19-pg-lake_3.7.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_lake_183.7.4el9.x86_64pigsty21.3 MiBpg_lake_18-3.7.4-1PGSTY.el9.x86_64.rpm
pg_lake_183.7.4el9.aarch64pigsty19.6 MiBpg_lake_18-3.7.4-1PGSTY.el9.aarch64.rpm
pg_lake_183.7.4el10.x86_64pigsty22.3 MiBpg_lake_18-3.7.4-1PGSTY.el10.x86_64.rpm
pg_lake_183.7.4el10.aarch64pigsty20.2 MiBpg_lake_18-3.7.4-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-lake3.7.4d12.x86_64pigsty20.6 MiBpostgresql-18-pg-lake_3.7.4-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-lake3.7.4d12.aarch64pigsty18.3 MiBpostgresql-18-pg-lake_3.7.4-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-lake3.7.4d13.x86_64pigsty21.6 MiBpostgresql-18-pg-lake_3.7.4-1PGSTY~trixie_amd64.deb
postgresql-18-pg-lake3.7.4d13.aarch64pigsty19.1 MiBpostgresql-18-pg-lake_3.7.4-1PGSTY~trixie_arm64.deb
postgresql-18-pg-lake3.7.4u22.x86_64pigsty20.5 MiBpostgresql-18-pg-lake_3.7.4-1PGSTY~jammy_amd64.deb
postgresql-18-pg-lake3.7.4u22.aarch64pigsty19.2 MiBpostgresql-18-pg-lake_3.7.4-1PGSTY~jammy_arm64.deb
postgresql-18-pg-lake3.7.4u24.x86_64pigsty20.6 MiBpostgresql-18-pg-lake_3.7.4-1PGSTY~noble_amd64.deb
postgresql-18-pg-lake3.7.4u24.aarch64pigsty19.3 MiBpostgresql-18-pg-lake_3.7.4-1PGSTY~noble_arm64.deb
postgresql-18-pg-lake3.7.4u26.x86_64pigsty21.3 MiBpostgresql-18-pg-lake_3.7.4-1PGSTY~resolute_amd64.deb
postgresql-18-pg-lake3.7.4u26.aarch64pigsty20.1 MiBpostgresql-18-pg-lake_3.7.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_lake_173.7.4el9.x86_64pigsty21.3 MiBpg_lake_17-3.7.4-1PGSTY.el9.x86_64.rpm
pg_lake_173.7.4el9.aarch64pigsty19.5 MiBpg_lake_17-3.7.4-1PGSTY.el9.aarch64.rpm
pg_lake_173.7.4el10.x86_64pigsty22.3 MiBpg_lake_17-3.7.4-1PGSTY.el10.x86_64.rpm
pg_lake_173.7.4el10.aarch64pigsty20.1 MiBpg_lake_17-3.7.4-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-lake3.7.4d12.x86_64pigsty20.6 MiBpostgresql-17-pg-lake_3.7.4-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-lake3.7.4d12.aarch64pigsty18.3 MiBpostgresql-17-pg-lake_3.7.4-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-lake3.7.4d13.x86_64pigsty21.6 MiBpostgresql-17-pg-lake_3.7.4-1PGSTY~trixie_amd64.deb
postgresql-17-pg-lake3.7.4d13.aarch64pigsty19.1 MiBpostgresql-17-pg-lake_3.7.4-1PGSTY~trixie_arm64.deb
postgresql-17-pg-lake3.7.4u22.x86_64pigsty20.7 MiBpostgresql-17-pg-lake_3.7.4-1PGSTY~jammy_amd64.deb
postgresql-17-pg-lake3.7.4u22.aarch64pigsty19.4 MiBpostgresql-17-pg-lake_3.7.4-1PGSTY~jammy_arm64.deb
postgresql-17-pg-lake3.7.4u24.x86_64pigsty20.6 MiBpostgresql-17-pg-lake_3.7.4-1PGSTY~noble_amd64.deb
postgresql-17-pg-lake3.7.4u24.aarch64pigsty19.3 MiBpostgresql-17-pg-lake_3.7.4-1PGSTY~noble_arm64.deb
postgresql-17-pg-lake3.7.4u26.x86_64pigsty21.2 MiBpostgresql-17-pg-lake_3.7.4-1PGSTY~resolute_amd64.deb
postgresql-17-pg-lake3.7.4u26.aarch64pigsty20.1 MiBpostgresql-17-pg-lake_3.7.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_lake_163.7.4el9.x86_64pigsty21.3 MiBpg_lake_16-3.7.4-1PGSTY.el9.x86_64.rpm
pg_lake_163.7.4el9.aarch64pigsty19.5 MiBpg_lake_16-3.7.4-1PGSTY.el9.aarch64.rpm
pg_lake_163.7.4el10.x86_64pigsty22.2 MiBpg_lake_16-3.7.4-1PGSTY.el10.x86_64.rpm
pg_lake_163.7.4el10.aarch64pigsty20.1 MiBpg_lake_16-3.7.4-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-lake3.7.4d12.x86_64pigsty20.5 MiBpostgresql-16-pg-lake_3.7.4-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-lake3.7.4d12.aarch64pigsty18.2 MiBpostgresql-16-pg-lake_3.7.4-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-lake3.7.4d13.x86_64pigsty21.5 MiBpostgresql-16-pg-lake_3.7.4-1PGSTY~trixie_amd64.deb
postgresql-16-pg-lake3.7.4d13.aarch64pigsty19.1 MiBpostgresql-16-pg-lake_3.7.4-1PGSTY~trixie_arm64.deb
postgresql-16-pg-lake3.7.4u22.x86_64pigsty20.7 MiBpostgresql-16-pg-lake_3.7.4-1PGSTY~jammy_amd64.deb
postgresql-16-pg-lake3.7.4u22.aarch64pigsty19.3 MiBpostgresql-16-pg-lake_3.7.4-1PGSTY~jammy_arm64.deb
postgresql-16-pg-lake3.7.4u24.x86_64pigsty20.5 MiBpostgresql-16-pg-lake_3.7.4-1PGSTY~noble_amd64.deb
postgresql-16-pg-lake3.7.4u24.aarch64pigsty19.2 MiBpostgresql-16-pg-lake_3.7.4-1PGSTY~noble_arm64.deb
postgresql-16-pg-lake3.7.4u26.x86_64pigsty21.2 MiBpostgresql-16-pg-lake_3.7.4-1PGSTY~resolute_amd64.deb
postgresql-16-pg-lake3.7.4u26.aarch64pigsty20.1 MiBpostgresql-16-pg-lake_3.7.4-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_lake;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_lake;		# install by package name

pig install pg_lake -v 19;   # install for PG 19
pig install pg_lake -v 18;   # install for PG 18
pig install pg_lake -v 17;   # install for PG 17
pig install pg_lake -v 16;   # install for PG 16

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_extension_base';

Create this extension with:

CREATE EXTENSION pg_lake CASCADE; -- requires pg_lake_copy, pg_lake_table

Usage

Sources:

pg_lake is the top-level extension for Snowflake’s PostgreSQL lakehouse stack. It installs the table, Iceberg, copy, query-engine, extension-base, and map components needed to query object-store files and create transactional Iceberg tables. The PostgreSQL extensions orchestrate planning and transactions while a separate local pgduck_server process executes vectorized work with DuckDB.

Package 3.7.4 supports PostgreSQL 16–19. All eight extensions in the package use SQL version 3.7. Install the extension libraries and query server from the same release.

Start the Packaged Stack

The PIGSTY RPM and DEB install pgduck_server in the bin directory for the PostgreSQL major in use. Start it under a process supervisor before creating the extension.

Add pg_extension_base to shared_preload_libraries and restart PostgreSQL:

shared_preload_libraries = 'pg_extension_base'

pgduck_server listens on /tmp/.s.PGSQL.5332 with mode 0770 by default. Run it as the PostgreSQL operating-system user so PostgreSQL can access the socket. Do not start it as an unrelated login user with the bare command.

# PostgreSQL 18 example. Substitute the installed major (16-19).
PG_LAKE_SERVER=/usr/lib/postgresql/18/bin/pgduck_server
# RHEL-compatible systems use /usr/pgsql-18/bin/pgduck_server.

sudo install -d -o postgres -g postgres -m 0700 \
  /var/lib/pg_lake /var/lib/pg_lake/extensions
sudo install -d -o postgres -g postgres -m 0750 /var/cache/pg_lake
sudo -u postgres -H "$PG_LAKE_SERVER" \
  --pidfile /var/lib/pg_lake/pgduck_server.pid \
  --duckdb_database_file_path /var/lib/pg_lake/pgduck_server.db \
  --extensions_dir /var/lib/pg_lake/extensions \
  --cache_dir /var/cache/pg_lake

This command runs in the foreground and must remain running. Use a service supervisor for production. If you use a dedicated service account instead, make it a member of the postgres group and start the server with --unix_socket_group postgres --unix_socket_permissions 0770.

In another terminal, verify the query engine before creating the extensions:

sudo -u postgres psql -X \
  "host=/tmp port=5332 dbname=postgres connect_timeout=2" \
  -c 'SELECT version();'

Then create the complete dependency tree in the target database:

CREATE EXTENSION pg_lake CASCADE;
SELECT lake.version();

Configure Object-Store Access

Object-store credentials are resolved by pgduck_server, not by the PostgreSQL backend. AWS and GCP can use their normal credential chains. For a local S3-compatible endpoint such as MinIO, first create the bucket, connect directly to pgduck_server, and create a persistent DuckDB secret:

sudo -u postgres psql -X -h /tmp -p 5332 -d postgres
CREATE PERSISTENT SECRET pglake_object_store (
    TYPE S3,
    KEY_ID 'access-key',
    SECRET 'secret-key',
    REGION 'us-east-1',
    ENDPOINT 'minio.example.com:9000',
    SCOPE 's3://analytics-bucket',
    URL_STYLE 'path',
    USE_SSL false
);

Connect to PostgreSQL, then choose the managed Iceberg location in the same session that creates the table:

SET pg_lake_iceberg.default_location_prefix =
    's3://analytics-bucket/warehouse';

Core Workflows

Create and modify a transactional Iceberg table:

CREATE TABLE measurements (
    station_name text NOT NULL,
    measured_at timestamptz NOT NULL,
    value double precision
) USING iceberg;

INSERT INTO measurements VALUES
    ('Istanbul', now(), 18.5),
    ('Haarlem', now(), 9.3);

Import or export Parquet, CSV, or newline-delimited JSON through COPY:

COPY (SELECT * FROM measurements)
TO 's3://analytics-bucket/export/measurements.parquet';

COPY measurements
FROM 's3://analytics-bucket/import/measurements.parquet';

Query files without loading them into PostgreSQL:

CREATE FOREIGN TABLE external_events ()
SERVER pg_lake
OPTIONS (path 's3://analytics-bucket/events/*.parquet');

SELECT count(*) FROM external_events;

Component Index

  • pg_lake: meta-extension and lake.version().
  • pg_lake_table: data-lake FDW, Iceberg table syntax, file utilities, and table catalogs.
  • pg_lake_iceberg: Iceberg metadata, snapshots, manifests, and catalog integration.
  • pg_lake_copy: COPY interception for object-store files and lake formats.
  • pg_lake_engine: shared query rewrite, type conversion, cleanup, and pgduck_server client layer.
  • pg_extension_base: preload and lifecycle-worker infrastructure.
  • pg_extension_updater: optional startup worker for extension updates.
  • pg_map: generated PostgreSQL map types used for nested lake data.

Operational Caveats

  • pgduck_server is required on every PostgreSQL host that can execute lake queries. Keep it supervised and verify its local socket before serving traffic.
  • The default socket mode is 0770; its owner and group come from the account that starts pgduck_server. A mismatched service user causes ERROR: could not start query engine.
  • S3 and compatible credentials are resolved by the DuckDB secrets/credential chain. Grant only the bucket permissions required by the workload.
  • The first start may download the DuckDB spatial extension. Ensure the service account has the required network access and writable state/cache directories.
  • CREATE PERSISTENT SECRET survives server restarts, but DuckDB stores it unencrypted under ~/.duckdb/stored_secrets. Keep the service account and its home directory stable, restrict permissions, and protect those files as credentials.
  • The default memory limit is 80 percent of system memory. Set --memory_limit explicitly when PostgreSQL and pgduck_server share a production host.
  • Iceberg writes create Parquet files per statement. Batch inserts and run regular VACUUM to avoid many small files.
  • The PostgreSQL extensions, pgduck_server, object-store data, and Iceberg catalog form one deployment unit. Back up and upgrade them as separate evidence layers; creating the extension alone does not prove the external services are usable.

Upgrade the Stack

Deploy the 3.7.4 libraries and pgduck_server together and restart processes holding old code. A 3.7.3 installation already has SQL version 3.7. From an earlier SQL revision, update installed components in dependency order to 3.7, then check their versions in each database.

ALTER EXTENSION pg_lake UPDATE TO '3.7';
SELECT extname, extversion
FROM pg_extension
WHERE extname LIKE 'pg_lake%'
   OR extname IN ('pg_extension_base', 'pg_extension_updater', 'pg_map')
ORDER BY extname;

The 3.5.3 patch hardens object deletion credential selection and avoids publishing nameless catalog entries. It retains SQL version 3.5, so SQL version alone cannot prove that the matching patch-level binaries are deployed.

Upstream 3.5.10 Changes

Release 3.5.10 hardens catalog-provided secret endpoints and file paths, pins background-worker search paths, and adds validation for Iceberg metadata. It supports vended Azure SAS tokens and a custom Horizon TLS CA path through pg_lake_iceberg.horizon_tls_ca_path. The query server also handles invalid nested values and oversized results as errors instead of crashing. Deploy matching extension libraries and query-server binaries when upgrading.

3.5.10 Changes

Upstream 3.5.10 drops cached vended credentials after catalog vending stops, preserves Iceberg catalog URLs in object storage, and updates Brotli to 1.1.1 for CVE-2026-111497. Deploy matching extension libraries and pgduck_server; the SQL version remains 3.5.

Upstream 3.6.0

Upstream 3.6.0 adds PostgreSQL 19 support and uses DuckDB 1.5.6. Deploy matching libraries and pgduck_server, keep pg_extension_base preloaded, restart loaded processes and apply the supplied SQL updates to version 3.6. This component’s 3.5-to-3.6 SQL migration is empty; the matching runtime and its dependencies still need the coordinated release upgrade.

Upstream 3.6.1 catalog behavior

Read-only tables attached with catalog = 'snowflake' and inferred columns now default lowercase_column_names to true. Other documented read-only catalog cases retain their existing default; the option is fixed when the table is created and does not rename existing columns. Review inferred names and case collisions when attaching new tables.

The family retains SQL version 3.6. Deploy matching extension libraries and pgduck_server: the patch also includes a Brotli decoder security correction in the query server. Existing package versions are recorded independently and are not evidence that this upstream patch is installed.

Upstream 3.6.2

The 3.6.2 patch corrects byte-by-byte CSV-value transmission in pgduck_server. Deploy the matching query-server binary with the extension libraries and reconnect/restart processes holding old code. The component SQL version remains 3.6; an unchanged extversion does not prove the query-server fix is installed. Package availability remains a separate catalog fact.

Upstream 3.7.0

Release 3.7.0 introduced control version 3.7 for this component. Earlier version sections describe historical behavior and package examples. Upgrade the complete family with matching libraries and pgduck_server, restart processes holding old code, and apply the supplied extension updates to SQL version 3.7. This does not establish package availability.

For newly attached read-only catalog = 'snowflake' tables, lowercase_column_names defaults to true and is fixed at creation. Case collisions are rejected. out_of_range_values = 'error' rejects infinite intervals on PostgreSQL 17+; clamp stores them as NULL without a warning. Review this loss of information before enabling it.

Upstream 3.7.2 and 3.7.3

Version 3.7.2 fixes Iceberg UPDATE/DELETE broken by PostgreSQL 18.7, corrects DELETE RETURNING tuple handling, and backports read/pruning fixes. Version 3.7.3 fixes matching nested fields with a NULL field ID and releases per-row value/null arrays during DELETE. Deploy the matching extension libraries and pgduck_server; these patches retain SQL version 3.7, so extversion alone does not identify whether the fixes are installed.

Upstream 3.7.4

Version 3.7.4 rejects nested SELECT INTO inside COPY TO queries. Family members keep their independent SQL versions; the ten reviewed controls remain 3.7. Deploy matching libraries and query server rather than requesting a nonexistent SQL version 3.7.4.

Table reader