Sources
Files
The files source: settings, which files load, columns, columns from paths, whole records, SFTP servers and the files a destination reads itself.
A files source is one table built from every file under a folder, in S3, Google Cloud Storage, a local folder or an SFTP server. To set one up, see Load files.
[connections.lake]kind = "s3"bucket = "example-bucket"region = "eu-west-2"
[sources.events]kind = "files"connection = "lake"path = "events/"format = "parquet"description = "Click events, partitioned by day."partition_columns = { dt = "date" }write_strategy = "delete_insert"cursor_column = "dt"| Setting | Meaning |
|---|---|
connection |
An s3, gcs, filesystem or sftp connection. |
path |
The folder, relative to the connection. |
format |
parquet (default), ndjson, json (objects in sequence, or an array), csv, xlsx or xml. |
compression |
auto (default, by .gz or .zst name), none, gzip, zstd, or zip for archives. |
csv |
Default { delimiter = ",", header = true, quote = '"', null_values = [""] }; also escape, encoding, encoding_check, skip_rows. Headerless columns are column_1, column_2, … |
xlsx |
{ sheet = "...", header = true, skip_rows = 0 } (the first sheet by default), or range and header_row. |
xml |
{ record_path = "orders/order", lists = [] }; record_path is required. |
column_names |
Names for the columns of headerless CSV or Excel files. |
members |
With compression = "zip", a glob member names must match. |
pattern |
A glob over paths below path, in place of the format’s suffix. |
order |
modified (default) or path. |
after_load |
"keep" (default), "delete" or { move_to = "<folder>" }. |
on_empty |
fail (default) or skip. |
shape |
columns (default) or record, into record_column (record by default). |
partition_columns |
Hive key=value folders as typed columns, such as { dt = "date" }. |
path_columns |
A template capturing columns from paths; unmatched_paths is fail (default) or skip. |
constant_columns |
The same value in every row, such as { region = "eu" }. |
transform |
A Python function run on each file. |
copy_to_internal_stage |
Snowflake only: upload files no external stage covers (Load methods). |
Choosing files
Section titled “Choosing files”Without pattern, a source reads files ending in its format’s suffix: .csv, .csv.gz and
.csv.zst for csv, and so on; a folder of other files fails plan, suggesting pattern.
pattern is a glob over each path below path, so files of any name load as format:
[sources.exports]kind = "files"connection = "drop"path = "erp/"pattern = "file_*.txt"format = "csv"csv = { delimiter = "|" }write_strategy = "merge"unique_key = ["id"]* matches within one name and ** across folders: "file_*.txt" reads file_1.txt but not
old/file_2.txt; "**/file_*.txt" reads both. Compression still follows the name. With zip,
pattern picks the archives and members their members. Files that don’t match are never read,
moved or deleted, and a folder holding only those counts as empty.
├── files 2 new of 2 matching file_*.txt, 1 other file ignoredWhich files load
Section titled “Which files load”| Strategy | Reads |
|---|---|
append |
Files not loaded yet, by _sqlload_source_file. A file rewritten in place since, or loaded without a version (an empty _sqlload_source_version), fails the table; --reload fixes it. |
delete_insert with a partition cursor_column (from partition_columns or path_columns) |
The newest loaded partition and everything after it, each replaced whole. |
delete_insert with a replace_key |
New or changed files. See Replacing rows by a key. |
replace |
Every file, swapped in as a new table. |
merge with a unique_key |
New or changed files. See Merging files. |
A files source needs a write_strategy, and a merge its unique_key. plan refuses an append
table that excludes _sqlload_source_file or _sqlload_source_version. Loads commit every 1,000
files or about 1 GB; delete_insert never splits a partition across commits.
$ sqlload plan -v…└── raw.events_log append ├── source files lake/events/ parquet ├── files 1 new of 3 listed ├── route DuckDB reads directly from lake/events/ (nothing through the loader)…With a partition cursor, a file below the range the load reads fails the table if it changed since it loaded (a monthly file corrected after the next month loaded), if it’s new in a partition the table holds (a part file added to a loaded month), or if the table holds it without a version. Skipping it would keep its old rows or never load it:
$ sqlload plan…Errors (1)└── raw.le ├── reason /data/drop/le_LE-FY27-P01.csv changed since it was loaded (version e3c0-3b9aca00-47 │ is now e3c0-b2d05e00-3b), but its file_version LE-FY27-P01 is below this load's │ range, which starts at LE-FY27-P02, so delete_insert would skip it and keep its old │ rows └── fix set replace_key to replace rows by a column the files hold (and drop cursor_column), load from it with --start-cursor LE-FY27-P01, or rebuild the table with --reloadTo find them, each plan reads the table’s file and version columns (billed on BigQuery), unless
the load has --start-cursor or --reload.
Replacing rows by a key
Section titled “Replacing rows by a key”delete_insert with a replace_key and no cursor_column loads each new or changed file in
order. Each file replaces the rows holding the key values it holds, so a corrected file replaces
its version whole, dropped lines included, and leaves other versions alone.
[sources.le]kind = "files"connection = "lake"path = "finance/le/"format = "csv"description = "Latest Estimate, one file per version, with its le_version."write_strategy = "delete_insert"replace_key = ["le_version"]$ sqlload plan -v…└── raw.le delete_insert (replace_key: le_version; NULLs in keys match)… └── batch 1 file, 1 commit, oldest modified first (ties by path), each recorded in the run logOne file must hold all of a value’s rows. If a value’s rows came from another file still in the
folder, or loaded earlier in the run, the table fails, naming both files, and that commit rolls
back. Put each value in one file, set on_overlapping_files = "last_wins" (below), remove the older
file, or set after_load so loaded files leave the folder.
It loads into DuckDB and Postgres targets only. --reload, state = "logged", a cursor_column
and excluding _sqlload_source_file are refused.
When newer files restate older ones
Section titled “When newer files restate older ones”on_overlapping_files = "last_wins" (default "fail") lets the file last in order replace the
values it holds while an earlier file holding them is still in the folder. The earlier file’s other
values stay:
sales/ sales_2026-11-07.csv business_date Nov 1 .. Nov 7 sales_2026-11-14.csv business_date Nov 5 .. Nov 14 <- Nov 5 to 7 come from this file[sources.sales]kind = "files"connection = "lake"path = "sales/"pattern = "sales_*.csv"format = "csv"description = "Daily sales, each delivery restating the days before it."write_strategy = "delete_insert"replace_key = ["business_date"]order = "path"on_overlapping_files = "last_wins"- Set
order = "path"when names sort by date. By default the file modified last wins. - A file that sorts before one already loaded, such as an older file sent late, still fails, as
does, under
order = "path", a file rewritten while a later one isn’t. By modified time a rewritten file sorts last and replaces the values. - Keep
"fail"when files may be parts of one export:"last_wins"keeps only the last part. - A table that excludes
_sqlload_source_rowloads each file in its own commit.
Merging files
Section titled “Merging files”merge upserts each new or changed file on its unique_key, oldest modified first, so the file
modified last wins a repeated key. Each commit records its files in the table’s run log,
_sqlload_runs, and later loads skip them. A failed commit rolls
back with its files, and the next load continues from there.
[sources.prices]kind = "files"connection = "lake"path = "prices/"format = "csv"description = "Price lists, each file updating the prices it names."write_strategy = "merge"unique_key = ["sku"]- A file that arrives late, or changes, merges after the others, as the newest. With
newest_by, its rows still replace only older rows. order = "path"orders by path belowpath(a ZIP member as<archive>.zip/<member>), in code point order. Use it when names carry an ISO date, such asexport_2026-11-09.csv, as unzipping,cp,gsutiland sync tools rewrite modified times.- Files with the same modified time, such as one archive’s members or SFTP files from one second, go in path order.
- A key repeated in one file merges its last row, or the newest by
newest_by; see Repeated keys.on_duplicate_keys = "fail"fails such a file instead, and commits each file alone. - It loads into DuckDB and Postgres targets only (MotherDuck through its DuckDB connection, not
tested live).
state = "logged"and acursor_columnare refused.
Deleting or moving loaded files
Section titled “Deleting or moving loaded files”after_load deletes or moves each file once the table’s load succeeds:
[sources.orders]kind = "files"connection = "lake"path = "drop/"format = "csv"description = "Orders dropped by the nightly export."write_strategy = "append"after_load = { move_to = "loaded" }- It needs
append,merge, ordelete_insertwith areplace_key. Not for SFTP or files targets. - A failed load touches no file, even files committed before the failure. Later loads skip those, so move them yourself.
move_tois a folder on the same connection, not insidepathor holding it. Files keep their key:drop/2026/a.csvmoves toloaded/2026/a.csv.- A move never replaces a file at the destination. On S3, a file written to the same key at that moment could be replaced, and a file over 5 GB stays. A file that changed since it was read stays.
- A failed delete or move warns but doesn’t fail the load;
load --jsongivesafter_loadstatus"failed", listing the files. - A ZIP archive is handled once every member read from it has committed.
planrefuses this while another source reads ZIP archives in that folder, or one inside or around it.
Empty folders
Section titled “Empty folders”An existing folder with no files (hidden ones aside) fails the load, in case of a broken mount or
wrong path: no .csv, .csv.gz, .csv.zst files found; ... where an empty folder is normal, set on_empty = "skip".
[sources.orders]kind = "files"connection = "landing"path = "orders/"format = "csv"description = "Orders unzipped into the landing folder by the download step."write_strategy = "merge"unique_key = ["order_id"]order = "path"on_empty = "skip"With on_empty = "skip", or once after_load has emptied the folder of a table that has loaded,
the table is skipped and the load exits 0, with the reason in plan and load --json’s
plan.skipped: no files to load in orders/ (on_empty = "skip").
- A missing or unreadable folder, or one holding files of another format or that don’t match
path_columns, still fails. - S3, GCS and SFTP list a missing folder as empty, so there a skip needs the table to exist. Watch
the
skippedreason. - An empty folder whose table another source also loads fails; run the others with
--exclude.
Reloading a files table
Section titled “Reloading a files table”sqlload load <table> --reload reads every listed file into a new table, swapped in at the end.
Postgres targets refuse it.
| Table | --reload |
|---|---|
append, replace, delete_insert on a partition cursor |
Reads the files in batches, as a first load. |
merge |
Under order = "path", every file by path. Otherwise the files merged before, in the order they merged, then the others, oldest modified first. Refused with unnest: drop the table and its child tables and load again. |
delete_insert with a replace_key, or after_load = "delete" |
Refused. |
With move_to, the reload also reads the moved files, through SQLLoad rather than the destination,
and _sqlload_source_file still names them under path. A failed reload moves nothing and leaves
the old table.
├── files 3 to read of 3 listed: 1 in ./drop/, 2 in ./done/Columns
Section titled “Columns”Parquet columns come from the files’ footers. CSV and JSON columns are inferred from a sample unless
pinned in columns, or loaded as text with
infer_types = false. Each row also gets
the _sqlload_source_* columns.
- Parquet lists, structs and maps load as
json, with decimals and times inside as strings such as"1.50", and their files go through SQLLoad. Snowflake loading from a stage failsplanon such a column: leave it out withexclude_columns. - Pin a list column, or a JSON array, as
array(T)to load an array. flattenloads a JSON object’s keys as columns, andparsereads text as times.
Columns from paths
Section titled “Columns from paths”path_columns is a template over each file’s path below path:
[sources.orders]kind = "files"connection = "lake"path = "orders/"path_columns = "{region}/{channel}/{order_date:date}/*.parquet"constant_columns = { shop = "main", schema_version = 2 }write_strategy = "delete_insert"cursor_column = "order_date"A file at orders/eu/web/2026-11-08/part-0.parquet loads with region = 'eu', channel = 'web',
order_date = 2026-11-08, shop = 'main' and schema_version = 2.
| In a template | Matches |
|---|---|
{name} or {name:type} |
A value inside one name, loaded as column name; any partition_columns type, text by default. |
* |
Any text inside one name. |
** |
Any number of folders, as a whole segment: **/{day:date}.json. |
| Anything else | Itself. |
- The template matches the whole path. A
datecapture matches2026-11-08or20261108, and an integer capture digits only. A text capture takes the shortest match, so keep a literal between two captures. - A path that doesn’t match fails
planunlessunmatched_paths = "skip". A value that doesn’t convert always fails. constant_columnstypes TOML values: a string astext, an integerint, a floatfloat, a booleanbool, a datedate, and a date-timetimestamp_tzwith an offset ortimestamp_ntzwithout. Otherwise write{ value = "12.50", type = "decimal(10,2)" }.- Both work like Hive partition columns. A captured date can be the
cursor_columnofdelete_insert; a constant can’t. A same-named column in the files is replaced. Each column comes from only one ofpartition_columns,path_columnsandconstant_columns, ignoring case.
Whole records
Section titled “Whole records”shape = "record" loads each record whole into one json column, to parse in the destination:
[sources.events]kind = "files"connection = "lake"path = "events/"format = "ndjson"shape = "record"record_column = "payload"partition_columns = { dt = "date" }write_strategy = "append"- JSON and NDJSON: each object. A record that isn’t an object fails, naming its file and line.
- CSV: each line as a JSON array of strings, such as
["1", "a,b", null]. Withheader = true, each file’s first line is skipped unchecked. Every line needs as many fields as the file’s first. - Nothing is sampled, so tables pin no other
columns; partition, path, constant and_sqlload_source_*columns load beside it. The column isjson(VARIANTin Snowflake). Parquet, Excel and XML can’t use it.
Formats and transforms
Section titled “Formats and transforms”CSV quoting and encodings, Excel/XML/ZIP options, headerless columns, and per-file Python transforms are documented on File formats and transforms.
Files on an SFTP server
Section titled “Files on an SFTP server”An sftp connection reads from an SFTP server; see
Load files from an SFTP server.
pathis below the login folder, or absolute when it starts with/. Hidden folders and symbolic links are skipped.- The host key must be in
known_hosts; otherwise the load fails with the key’s fingerprint and the command that adds it. - A file’s version is
<size>-<mtime in milliseconds>. SFTP gives times to the second, so a same-size rewrite within one second isn’t noticed. _sqlload_source_fileissftp://host/path, orsftp://user@host/~/pathbelow the login folder. Changinghostorusermakesappendload every file again. The port isn’t part of it, so two SFTP sources loading one table must not name the samehostand path from/.- Rows always pass through SQLLoad;
copy_to_internal_stageis refused. SQLLoad never writes, moves or deletes files on the server. - Each table being read uses one SFTP channel. OpenSSH allows 10 per connection (
MaxSessions), so keepconcurrencyat 10 or less for one server.
Files the destination reads itself
Section titled “Files the destination reads itself”Where the destination can load the files exactly, it reads them itself and no row passes through
SQLLoad: Parquet into DuckDB (S3, a local folder, or GCS with an HMAC key), MotherDuck (S3, or GCS
with an HMAC key), ClickHouse (S3) and BigQuery (GCS, when the table excludes _sqlload_source_row),
and Parquet, JSON, NDJSON and CSV into Snowflake through an external stage. plan shows each
table’s route. See Let the warehouse read the files and
Load methods.