Reference

The dataset transform spec

One small YAML or JSON document that says how a stream of JSON records becomes exactly one columnar table: which fields to select, what type each becomes, which transform runs on the way, what to do when the source drifts, and where the table lands. You write it once per source shape; the engine shapes unbounded rows under it.

Follows docs/SPEC.md and the spec model in shapeshift-core/src/spec.rs and drift.rs at 0.4.0. 0.5 adds a where: row filter, which is not on this page yet: see the changelog.

Format and loading

Skeleton

every key, with its default
dataset: <name>                       # required, non-empty
source:
  format: jsonl | json-array          # default jsonl
  path: <input path>                  # optional; -i overrides; - is stdin
output:                               # required
  format: parquet | iceberg            # required
  path: <file, directory, table or URL> # required
  compression: snappy | zstd | uncompressed   # default snappy
  partition_by: [<col> | <transform(col)>, ...] # default []; Iceberg
  merge_on: [<col>, ...]              # default []; Iceberg upsert keys
schema: infer | strict                # default infer
columns:                              # default []
  - name: <col>
    from: <path>                       # default = name
    type: <logical type>               # required
    transform: <named transform>       # optional
    required: <bool>                   # default false
drift:
  policy: ignore | warn | rescue | quarantine | error   # default warn
  rescue_column: <col>               # default _rescued
  max_examples: <int>                # default 3
options:
  flatten: <bool>                     # default true
  row_group_rows: <int>               # default 50000
  infer_sample: <int>                 # default 1000; 0 = whole input

Top level

keytypedefaultmeaning
datasetstringrequiredTable name. Must not be empty. The Parquet file stem when output.path is a directory; the Iceberg table's name.
sourcemap{format: jsonl}How to read the input (below).
outputmaprequiredHow and where to write (below).
schemainfer | strictinferinfer lets undeclared fields ride along; strict writes only declared columns (Schema modes).
columnslist[]Column declarations (below). In infer mode they refine the inferred schema; in strict mode they are the schema.
driftmap{policy: warn}What a run does when the source outgrows the schema (Schema drift).
optionsmapdefaultsDataset-wide options (below).

source

keytypedefaultmeaning
formatjsonl | json-arrayjsonljsonl: one object per line, streamed a line at a time; blank lines skipped. json-array: one top-level array, streamed an element at a time; a bad element is a per-record reject carrying its 1-based element index, and a structural problem (not an array, truncated, trailing garbage) is reported once.
pathstringnoneInput path. -i overrides it. - is standard input; the source is read once, so a pipe shapes exactly what a file would.

output

keytypedefaultmeaning
formatparquet | icebergrequiredparquet: one file. iceberg: a self-contained Iceberg v2 table, one snapshot per run.
pathstringrequiredParquet: a file, or a directory (then <path>/<dataset>.parquet). Iceberg: the table root, created if absent. With the object_store feature, an s3://, gs://, az:// or file:// URL.
compressionsnappy | zstd | uncompressedsnappyParquet page codec, for data files of either format. zstd needs a build with the zstd feature; the default binary returns a clear error.
partition_bylist of string[]Iceberg partition fields: a column (identity) or a hidden transform (Partitioning). Ignored for Parquet, which is always one file.
merge_onlist of string[]Iceberg only. Upsert on these key columns instead of appending (Merge keys).

columns[]

keytypedefaultmeaning
namestringrequiredOutput column name; unique within the spec.
fromstring= nameSource path into each record (Path selection).
typelogical typerequiredOne of bool, int64, float64, string, date, timestamp, json (Types).
transformnamenoneA value rewrite applied before coercion (Transforms).
requiredboolfalseA missing or null value rejects the row (lenient) or aborts the run (strict); otherwise it is written as null. Also makes the Arrow field non-nullable.

options

keytypedefaultmeaning
flattenbooltrueInference only. Nested objects become dotted columns and arrays become json leaves. Off: each top-level nested object becomes one json column. Declared columns are never affected.
row_group_rowsint50000Rows buffered before a batch is flushed as one Parquet row group. This is what bounds memory: a run never holds more than this many rows. Values below 1 are read as 1.
infer_sampleint1000Records sampled for inference; 0 scans the whole input.

Logical types

A closed set. Each maps onto Arrow, and from there onto Parquet and the Iceberg type system.

type:ArrowIcebergnotes
boolBooleanbooleanJSON true/false only.
int64Int64long64-bit signed.
float64Float64doubleIEEE-754 double.
stringUtf8stringScalars stringify; arrays and objects do not (use json).
dateDate32dateDays since 1970-01-01, no zone.
timestampTimestamp(µs, no zone)timestampMicroseconds since the epoch, zone-less: Iceberg timestamp, not timestamptz.
jsonUtf8stringAny value kept as compact JSON text. Never fails coercion.

Coercion

Coercion runs after the transform, on the selected value, toward the column's type. A missing path or a JSON null is null and never reaches coercion; what happens to it is the reject policy. A value that is present but cannot be represented is a coercion failure.

targetacceptsresult, or failure
boolJSON boolAnything else fails.
int64number; numeric stringAn integer, or an integral finite float (10.0). 10.5 fails. "42" parses; a non-integer string fails.
float64number; numeric string"3.14" parses; a non-numeric string fails.
stringstring, bool, numberStrings as-is; true → "true"; a number → its JSON text. Arrays and objects fail.
datedate string; integerYYYY-MM-DD, or the date part of an RFC3339 string. A bare integer is epoch days.
timestamptimestamp string; integerRFC3339 with an offset (applied to reach UTC, then dropped), or zone-less YYYY-MM-DDThh:mm:ss[.fff] read as UTC. A bare integer is epoch milliseconds.
jsonanythingA string as-is; any other value as compact JSON. Never fails.

Integer dates are days and integer timestamps are milliseconds, deliberately: those are the units common JSON uses for each.

Transforms

A pure value-to-value rewrite applied before coercion. Every transform is total: a value of a type it does not apply to passes through unchanged, and a genuine mismatch surfaces later, in coercion. Parsing dates and times is not a transform; the target type drives it.

transform:effectexample
lowercaseLowercase a string."PRO" → "pro"; 42 → 42
uppercaseUppercase a string."pro" → "PRO"
trimTrim surrounding whitespace." ada " → "ada"
json_encodeA composite value to compact JSON text; a string is left as-is.{"a":1} → "{\"a\":1}"
to_stringStringify a scalar; null stays null; composites to JSON text.42 → "42"; true → "true"
dollars_to_centsMultiply by 100 and round to the nearest integer.12.50 → 1250; -4.2 → -420
absAbsolute value; ints stay ints, floats stay floats.-3.5 → 3.5
empty_to_nullAn empty string becomes null, so required can fire."" → null

Path selection (from)

Schema modes

infer (the default) infers columns from a sample and lets undeclared fields ride along. Declared columns win over inferred ones of the same name and keep their position; the rest follow in first-seen order. Coercion is lenient.

strict writes only the declared columns, run after run: the contract mode. It needs at least one column. Coercion is strict.

Reject policy

Every cell of a row is computed and checked before any of it is appended, so a rejected row never leaves the columns misaligned.

columnlenient: missing / nulllenient: uncoerciblestrict: missing / nullstrict: uncoercible
optionalnullnullnullrun aborts
required: truerow rejectedrow rejectedrun abortsrun aborts

A source line that is not JSON never aborts a run, in either mode. It is counted as a parse_error and written to <output>.rejects.jsonl as {"line", "error", "raw"}. Rows rejected by the lenient policy are counted as rejected.

Schema drift

Sources move after the spec is written. Two movements used to pass silently: a field the spec has no column for (its values are never selected) and a value that stopped coercing in an optional column (written as null). Neither shows in rows_in, rows_out or rejected. shapeshift detects both per record and reports them.

drift.policywhat the run writeswhen
ignoreExactly the 0.1 behaviour: no detection, no per-record work.You measured that you need the last few percent.
warn (default)Every row, unchanged, plus the report.You want to know, and keep loading.
rescueEvery row, plus a json column (rescue_column, default _rescued) holding what the schema would have dropped; null on rows that did not drift. Appended after every declared column, so enabling it is an additive Iceberg schema change.You cannot lose data while the spec catches up.
quarantineOnly rows exactly on the schema; drifted rows go to the reject sidecar.Downstream must never see a partial row.
errorNothing: the run fails at the first drift and never finalizes its output.A contract table: no new data beats quietly different data.

Measured cost of the default (BENCHMARKS.md §7, glibc release build, 1M rows, median of 6): about 6% of wall time on a run that has not drifted, with peak RSS unchanged; 1.47× when every row drifts, and 2.44× under rescue.

Partitioning

partition_by entries are a column name (identity) or one of the Iceberg hidden transforms. Rows fan out to one data file per transformed value, under Hive-style directories. Temporal values are written readably: data/event_at_day=2026-07-11/.

entrysource typespartition value
colanyThe value itself (identity).
bucket(N, col)int64, string, date, timestampMurmur3 bucket per the Iceberg spec, 0..N-1.
truncate(W, col)int64, stringIntegers floored to a multiple of W; strings cut to W code points.
year(col), month(col), day(col)date, timestampYears, months or days since 1970.
hour(col)timestampHours since 1970-01-01T00.

Merge keys (merge_on)

Validation errors

Checked on load, after the document's shape (a missing dataset, output, output.format, output.path or column type fails first).

conditionmessage
empty dataset`dataset` must not be empty
strict with no columnsstrict schema mode requires at least one declared column
two columns share a nameduplicate column name `<name>`
partition column not declaredpartition column `<name>` is not a declared column (declare it to partition by it)
merge_on with Parquet`output.merge_on` applies only to Iceberg tables (`format: iceberg`)
a key named twice`output.merge_on` names `<name>` twice
key not declared (strict)merge key `<name>` is not a declared column (declare it to merge on it)

Inference

Inference samples the first infer_sample records and proposes one optional column per path, with no transform. It only ever widens, so a strict spec derived from an inferred one is safe. Per path, ignoring nulls:

  1. Any array or object seen → json.
  2. Two or more scalar kinds (bool, number, string) → string.
  3. All strings, every one RFC3339 with a time → timestamp; every one exactly YYYY-MM-DD → date; otherwise string.
  4. Numbers with any float → float64; all integers → int64.
  5. All bools → bool. Only nulls seen → string.

Column order is first-seen. A sample that yields no columns (all scalar lines, or empty) with nothing declared is an error.

Spec and command-line flags

The spec is the durable artifact; shape's flags override it for one run without editing the file.

flagoverrides
-i, --inputsource.path
-o, --outputoutput.path
--tooutput.format
--compressionoutput.compression
--partition-byoutput.partition_by
--merge-onoutput.merge_on
--on-drift, --rescue-columndrift.policy, drift.rescue_column

--format and --dataset apply when there is no spec. Flags that change only how a run reports (--summary-json) have no spec field.

Examples

minimal: everything inferred, Parquet out
dataset: events
output:
  format: parquet
  path: ./out/events.parquet
Iceberg, partitioned, a few pinned columns, the whole record kept
dataset: orders
output:
  format: iceberg
  path: ./warehouse/orders
  partition_by: [region]
schema: infer                  # the pinned columns win; other fields ride along
columns:
  - { name: order_id,    from: id,         type: int64, required: true }
  - { name: region,      from: geo.region, type: string, transform: lowercase }
  - { name: total_cents, from: total,      type: int64, transform: dollars_to_cents }
  - { name: payload,     from: $,          type: json }
upsert by key, keep what drifts
dataset: orders
output:
  format: iceberg
  path: s3://warehouse/db/orders   # needs the object_store feature
  merge_on: [id]
drift:
  policy: rescue

The strict billing spec is walked through in the Quickstart.