Skip to content

Targets

DuckDB

Load into DuckDB: Arrow appends, and Parquet files DuckDB reads itself.

Rows that SQLLoad reads are appended to DuckDB as Arrow. Parquet files in S3, GCS or a local folder load directly: DuckDB reads them with read_parquet, with the same values SQLLoad’s own reader gives.

$ sqlload plan -v
…
├── route DuckDB reads directly from lake/events/ (nothing through the loader)

SQLLoad’s reader loads a files table instead, and plan -v says why, for:

  • another format (CSV, JSON, NDJSON);
  • a custom S3 endpoint (in the connection, or AWS_ENDPOINT or AWS_ENDPOINT_URL);
  • masked columns;
  • a file column named filename or file_row_number;
  • nanosecond or epoch timestamps, and other types DuckDB wouldn’t read exactly;
  • a column loaded as a different type than the files hold;
  • glob characters in a path.

A later batch whose files hold a column differently fails the load, naming the column.

DuckDB reads S3 with the keys SQLLoad finds for the s3 connection, or else the AWS credential chain. The first load from S3 installs DuckDB’s httpfs extension (and aws, for the chain) into ~/.duckdb, which needs the network once.

Parquet files in a gcs connection load directly only when the connection sets an HMAC key (hmac_key_id and hmac_secret): DuckDB takes no service-account key. Without one, or with a custom endpoint, SQLLoad reads the files. plan reads the first file with DuckDB and fails the table with the fix when it can’t.

json_type = "variant" on a DuckDB or MotherDuck target creates json columns as DuckDB’s VARIANT instead of JSON (which holds each value as text):

[targets.dev]
connection = "local"
loader_schema = "raw"
json_type = "variant"

Values load parsed, so objects, arrays, numbers and booleans keep their types: variant_typeof(payload) is OBJECT(user) and payload.user.id is 42. It applies to every json column. A column pinned native("VARIANT") loads the same way on any DuckDB or MotherDuck target.

Changing json_type on an existing table changes its json columns’ type, keeping their values. plan shows each, such as payload json -> native("VARIANT") needs a table rebuild, which runs as type_change_rebuild allows (by default, with --allow-type-change-rebuild).

A DuckDB target takes its part of the run’s memory budget: a memory_limit of half that part, at least 256MB, and one thread per 128 MiB of it, between two and the machine’s cores. plan shows both on its Memory line.

Tables of few, wide rows (values of about 85 KiB and more) need memory for what each commit holds, not just the fetch budget. SQLLoad cuts such commits into pieces and checkpoints as it goes; see Large rows in DuckDB. A table whose last row group (up to 122,880 rows) would hold more large values than DuckDB can rewrite at a checkpoint within the memory_limit fails before it commits, naming the memory_limit that would fit it.

An append under a memory budget creates a _sqlload_unfinished table, empty between loads, in the table’s schema beside _sqlload_runs. If an append stops partway, the next load of that table uses it to remove the rows that append committed, and warns.

With memory_limit = "off", DuckDB keeps its own memory_limit, threads and automatic checkpoints, commits aren’t cut into pieces, and no _sqlload_unfinished table is created. The row-group check stays, against DuckDB’s own memory_limit.