Skip to content

Targets

Parquet and CSV files

Write each table as zstd Parquet or CSV files in S3, Google Cloud Storage or a local folder, partitioned by a template.

A files target writes each table as Parquet or CSV files in its own folder.

[connections.out]
kind = "filesystem"
root = "out"
[targets.files]
connection = "out"
path = "{source}/{table}/dt={cursor:date}/"
Key Meaning
connection An s3, gcs or filesystem connection.
path Each table’s folder: a template with {source}, {schema}, {table}, and {cursor} or {cursor:date} to partition by the cursor. Default {source}/{table}/.
format parquet (default), or csv. See CSV files.
compression CSV only: none (default), gzip or zstd.
csv CSV only: { delimiter, header, quote, null_value }. Default { delimiter = ",", header = true, quote = '"', null_value = "" }.
single_file Write one file per table, or per partition, named after the table folder. Default false.
max_footer_reads The most Parquet footers plan reads for one table’s schema. Default 100.

A source’s destination_path, or one table’s, overrides the target’s path.

$ sqlload plan -v
Plan ready 1 selected, 1 to load
Loads (1) sqlload load
└── app__orders delete_insert (cursor: updated_at)
├── source postgres app public.orders
├── reads updated_at: first run, everything
├── columns 5
├── files out/app/orders/ parquet (zstd) partitions dt={cursor:date}/
├── schema first files, 7 columns
├── note each partition written or in the window gets its new files first, then its older files are deleted; not atomic, so a reader in between sees both
└── commits about every 1 GB, in updated_at order (an index leads with it, NULLs first), between distinct values; each commit replaces its own cursor range
✓ Plan complete 1 selected, 1 to load

Files targets take append, replace and delete_insert; plan refuses merge, which needs a table format that updates rows in place. delete_insert writes each partition’s new files first, then deletes its older ones, so a reader in between sees both, as the plan’s note says.

The table’s schema is the footers of the newest load in its newest partition. sqlload contract diff --all-files reads every file’s footer to report files whose columns differ. See sqlload contract.

A postgres_cdc source loads into a files target as a changelog, adding files with each load.

A files source loads into a files target with append, replace, or delete_insert by a partition cursor. Each commit records the source files it loaded under _sqlload/loaded/, and an append skips them on the next load. With a partition cursor, append reads from the target’s newest partition onward, so a late file in an older partition isn’t loaded. A source file rewritten in place fails the table until you load it with --reload, or use delete_insert on a partition cursor. If you delete a commit’s files, its source files load again.

A record written by an older SQLLoad blocks the table rather than treat its files as never loaded:

…/_sqlload/loaded/<commit>.json is a record of loaded source files in the format of an older SQLLoad, which this one cannot read. Fix: load the table with --reload, which rewrites its files and records

plan blocks a target folder that is the source folder, inside it or around it, since a load would delete or read back its own source files. A files source can’t load into a single_file target.

SQLLoad keeps each table’s bookkeeping under <table folder>/_sqlload/; leave it in place. Only one load writes a table at a time: a load holds a lease on the table, renewed every minute, and while another load holds it, plan blocks the table and load refuses it:

the table is being loaded by load 3f9c… (started 2026-11-08 09:00:00 UTC, lease until 2026-11-08 09:10:00 UTC); retry once it finishes

A lease lasts 10 minutes, so a load that crashed holds the table until then; the next load repairs what it left. A load that lost its lease stops before deleting any files. A load also stops before writing when another load changed the table after it was planned, since it could load the same rows again. Run it again:

orders: another load changed the table's files in out/orders/ after this load was planned, so what it would read may already be loaded; stopped before writing. Run the load again

How replace and --reload write the new table depends on where it is:

Where the table is How the new table is written What a reader sees
A local folder on Linux (ext4, XFS, Btrfs, tmpfs) or macOS (APFS) In a hidden folder beside the table folder, swapped in with one rename The old files or the new ones, never both
A local folder on a filesystem that can’t swap two folders in one rename (NFS, EFS, SMB mounts), or on Windows Into the table folder, then the older files are deleted Both, for a moment between the write and the delete
A table at the root of the folder connection As the row above, since it has no folder beside it Both, for a moment
S3 or GCS As the row above Both, for a moment

The swap carries over the _sqlload/ folder and any other file you keep beside the data. The next load deletes a hidden folder that a stopped load left. One ending in -old, left by an earlier release, is kept with a warning, as it may hold the table’s only copy. If the swap fails, the load stops and leaves the table as it was.

[targets.exports]
connection = "out"
path = "{table}/"
format = "csv"
compression = "gzip"
csv = { delimiter = ",", header = true, quote = '"', null_value = "" }
single_file = true

Files are named part-<load id>.<commit>-<n>.csv, with .gz or .zst when compressed. With single_file = true each table, or each partition, is one file named after the table folder, such as orders/orders.csv.gz, held in memory and written whole at the end of the load. A load that would hold more than 2 GiB fails. Outside the local swap the file is overwritten in place, so a load that fails while writing several partitions can leave some new and others old until it is rerun. A table whose columns grow during a load (a Python source adding a column) can’t use single_file.

Columns are written in the table’s order, _sqlload_load_id and _sqlload_loaded_at last:

Type Written as
text, varchar, uuid As is
int, smallint Digits, with - when negative
decimal(p,s) Plain digits with exactly s decimals, such as -0.05
float The shortest digits that read back the same value, never an exponent, such as 0.0000001; NaN, Infinity, -Infinity
bool true, false
date 2026-11-08
time 05:00:00.123456
timestamp_tz In UTC: 2026-11-08T05:00:00.123456Z (years outside 0 to 9999 as +10000-…)
timestamp_ntz 2026-11-08T05:00:00.123456
json Compact JSON text: no whitespace outside strings, keys in their order
binary Lowercase hex

A value is quoted when it is empty, equals null_value, or holds the delimiter, the quote or a line break; a quote inside it is doubled. NULL is written as null_value, unquoted, so with the default a NULL is an empty field and an empty string is "".

CSV files have no footers, so plan doesn’t compare an existing CSV table’s columns with the new ones, append by a {cursor:date} partition and postgres_cdc sources need Parquet, and single_file doesn’t take append; plan says so.

  • The lease trusts the clocks of the machines that load, and needs a store that honours create-only writes, as a local folder and S3 (If-None-Match: *) do. An S3-compatible store that ignores that header can let two loads write one table. With AWS_CONDITIONAL_PUT=disabled, loads into S3 fail instead.
  • A load that lost its lease is kept from counting its files as written for 7 days after another load repaired the table, not longer.