Query Your Data Lake in Postgres
Because pg_mooncake (v0.3.0) embeds DuckDB v2.0.0 via pg_duckdb 1.2.0, you can query external files in your data lake (local disk, S3, Cloudflare R2, GCS, HTTP, or HuggingFace hf:// datasets) directly from PostgreSQL without loading them into heap tables first.
Supported External Formats
- Apache Parquet (
duckdb.read_parquet) - CSV / TSV (
duckdb.read_csv) - JSON / NDJSON (
duckdb.read_json) - Apache Iceberg (
duckdb.iceberg_scan) - Delta Lake (
duckdb.delta_scan)
v0.2 / v0.3 (duckdb.*) vs Legacy v0.1 (mooncake.*) FunctionsIn pg_mooncake v0.2 and v0.3.0, external file readers are provided directly by pg_duckdb (duckdb.read_parquet, duckdb.read_csv, duckdb.iceberg_scan, duckdb.delta_scan). For the legacy v0.1 mooncake.read_parquet syntax, see v0.1 Query External Files.
1. Querying Parquet Files (duckdb.read_parquet)
Use duckdb.read_parquet and specify the expected output columns in the AS (...) clause:
You can also query Hive-partitioned directory structures:
2. Querying CSV Files (duckdb.read_csv)
3. Querying External Iceberg & Delta Lake Tables
First install and load the iceberg or delta DuckDB extension via duckdb.install_extension:
4. Joining External Files with PostgreSQL Tables
You can join external Parquet, Iceberg, or Delta Lake datasets directly with regular PostgreSQL heap tables or USING mooncake columnstore mirrors in a single SQL query:
5. Querying HuggingFace Datasets (hf://)
DuckDB supports reading public HuggingFace datasets directly via the hf://datasets/<org>/<repo>/<path> URI scheme: