DuckDB¶
Vortex extension is available on Linux and macOS from DuckDB 1.4.2 and on Windows from DuckDB 2.0.
Setup¶
INSTALL vortex; LOAD vortex;
Reading files¶
SELECT * FROM 'data.vortex';
# alternative syntax
SELECT * FROM read_vortex('data.vortex');
# globbing is also supported
SELECT * FROM 'foo/*.vortex';
# you can pass lists of files
SELECT * FROM read_vortex(['1.vortex', '2.vortex']);
# hive_partitioning is supported.
# assuming folder structure data/year=2000/1.vortex, data/year=2001/2.vortex
SELECT * FROM 'data/*/*.vortex';
# alternative syntax supports hive_partitioning, filename, and allow_empty
# parameters
SELECT * FROM read_vortex(['1.vortex', '2.vortex'], filename = true);
Writing files¶
COPY (SELECT * FROM my_table) TO 'output.vortex';
# you can also get file statistics
COPY (SELECT * FROM my_table) TO 'output.vortex' (FORMAT vortex, RETURN_STATS)
Make sure to call LOAD vortex before writing any files. Duckdb writes CSV
files by default, so if Vortex extension wasn’t loaded prior to COPY,
output.vortex will be a CSV file. If you want to prevent this from happening,
you can use COPY ... TO 'output.vortex' (FORMAT vortex) syntax instead which
will fail if Vortex is not loaded.
Warning
DuckDB reserves i64::MAX and -i64::MAX in timestamps and i32::MAX and -i32::MAX in dates
as infinity and -infinity. Vortex has no infinite values, so DuckDB reads Vortex values stored
at those integers as infinities, and COPY writes DuckDB infinities as those finite values. For
example, pandas.Timestamp.max (2262-04-11 23:47:16.854775807) reads as infinity.
Note
DuckDB’s TIMESTAMPTZ and TIMESTAMP_TZ_NS types do not store a per-column time zone. When
reading a Vortex file into DuckDB, any zoned Vortex timestamp column (Timestamp(unit, Some(tz)))
has its time zone metadata erased to DuckDB’s zone-less UTC instant representation, while the
underlying UTC instant is preserved. Writing that data back with COPY always produces "UTC"
timestamps rather than the original column time zone.
Python client¶
import duckdb
duckdb.sql("INSTALL vortex")
duckdb.sql("LOAD vortex")
result = duckdb.sql("SELECT * FROM 'data.vortex' WHERE age > 30")
result.show()
Object storage secrets¶
Vortex does not use DuckDB’s secret storage. It uses environment variables via
object_store instead.
If you want to read or write from an S3 bucket, set the following variables:
export AWS_ACCESS_KEY_ID="your_access_key"
export AWS_SECRET_ACCESS_KEY="your_secret_key"
export AWS_REGION="your_bucket_region"
For Google Cloud Storage, use a key file variable:
export GOOGLE_APPLICATION_CREDENTIALS="my service account JSON key file"
For Azure Blob Storage, use
export AZURE_STORAGE_ACCOUNT="my account"
export AZURE_STORAGE_KEY="my key"