opendal

Zugriff auf S3, das lokale Dateisystem und andere Speicherdienste über Apache OpenDAL

Maintainer: chitralverma

Installation und Laden

INSTALL opendal FROM community;
LOAD opendal;

Beispiel

-- Install and load the extension
INSTALL opendal FROM community;
LOAD opendal;
-- Create a secret for local filesystem access
CREATE SECRET my_fs (TYPE fs, SCOPE 'fs://', config MAP{'root': '.'});
-- Write a Parquet file through OpenDAL
COPY (SELECT range AS id, range * 2 AS doubled FROM range(100))
TO 'fs:///output/data.parquet' (FORMAT parquet);
-- Read it back
SELECT count(*), sum(doubled) FROM read_parquet('fs:///output/data.parquet');
-- List files
SELECT * FROM opendal_ls('fs:///output/');
-- Stat a file
SELECT name, metadata.content_length FROM opendal_stat('fs:///output/data.parquet');

Über opendal

Die Erweiterung opendal integriert Apache OpenDAL als virtuelles Dateisystem in DuckDB und ermöglicht transparenten Lese- und Schreibzugriff auf mehrere Speicherdienste über eine einheitliche SQL-Schnittstelle.

Unterstützte Speicherdienste

  • fs:// / file:// — Lokales Dateisystem
  • s3:// — Amazon S3 und S3-kompatible Stores (MinIO, R2 usw.)
  • memory:// — In-Memory-Speicher (nützlich zum Testen)
  • weitere Dienste folgen in Kürze

Wichtige Funktionen

  • Lesen und Schreiben von Parquet-, CSV- und JSON-Dateien über jeden unterstützten Dienst
  • Glob-Muster funktionieren transparent (read_parquet('s3://bucket/**/*.parquet'))
  • Tabellenfunktionen für Speicheroperationen:
    • opendal_stat() — Dateimetadaten
    • opendal_ls() — Verzeichnisauflistung mit optionaler Rekursion
    • opendal_glob() — musterbasiertes Auffinden von Dateien
    • opendal_du() — Zusammenfassungen der Speicherbelegung
    • opendal_copy() — Dateikopie zwischen Diensten und innerhalb eines Dienstes
  • Scoped Secrets mit dienstspezifischer Konfiguration über DuckDBs Secret Manager
  • Konfigurierbare Layers — Retry, Timeout, E/A-Nebenläufigkeit und Caching (im Speicher über foyer, optional On-Disk-Tier)
  • Globale Einstellungen für Standard-E/A, Retry, Timeout und Cache-Konfiguration
  • Koexistenz mit DuckDBs nativer httpfs-Erweiterung über die Einstellung opendal_override_native_filesystems
  • DuckDB-FileSystem-Logging-Integration für strukturiertes E/A-Tracing

Konfigurationsbeispiel

CREATE SECRET warehouse (
TYPE s3,
SCOPE 's3://warehouse',
config MAP{
'access_key_id': '...',
'secret_access_key': '...',
'region': 'us-east-1',
'endpoint': 'http://localhost:9000'
},
io_config MAP{'read.concurrent': '4', 'write.chunk_size': '8 MiB'},
retry_config MAP{'max_times': '5', 'jitter': 'true'},
cache_config MAP{'memory_size': '256 MiB'}
);
SELECT * FROM read_parquet('s3://warehouse/data/*.parquet');

Die vollständige Dokumentation finden Sie im Projekt-Repository.

Hinzugefügte Funktionen

function_name function_type description comment examples
opendal_copy table NULL NULL
opendal_du table NULL NULL
opendal_glob table NULL NULL
opendal_is_manually_set scalar NULL NULL
opendal_ls table NULL NULL
opendal_stat table NULL NULL
opendal_version scalar NULL NULL

Überladene Funktionen

Diese Erweiterung fügt keine Funktionsüberladungen hinzu.

Hinzugefügte Typen

Diese Erweiterung fügt keine Typen hinzu.

Hinzugefügte Einstellungen

name description input_type scope aliases
opendal_cache_config Global OpenDAL data-cache options. MAP(VARCHAR, VARCHAR) GLOBAL []
opendal_io_config Global OpenDAL reader/writer options. MAP(VARCHAR, VARCHAR) GLOBAL []
opendal_override_native_filesystems Comma-separated schemes (e.g. ‘s3,gcs’) for which the OpenDAL filesystem overrides native extensions in DuckDB’s filesystem dispatch. Empty disables all overrides. VARCHAR GLOBAL []
opendal_retry_config Global OpenDAL retry-layer options. MAP(VARCHAR, VARCHAR) GLOBAL []
opendal_timeout_config Global OpenDAL timeout-layer options. MAP(VARCHAR, VARCHAR) GLOBAL []