Reference
The shapeshift command
One binary, seven subcommands. Every flag below is taken from the argument
definitions in shapeshift-cli/src/main.rs at 0.4.0, and the outputs are from
running it. 0.5 adds relocate, --catalog, --where and
--run-id, which are not on this page yet: see the
README and the changelog.
Synopsis
Usage: shapeshift [OPTIONS] <COMMAND> Commands: infer Infer a dataset spec from a sample of the input and print it (ready to edit) shape Shape input JSON/JSONL into Parquet or an Iceberg table inspect Inspect a Parquet file or Iceberg table (schema + row count) compact Compact an Iceberg table: apply every delete and pack small files, in one `replace` snapshot expire Expire old snapshots of an Iceberg table and delete the files only they read cost Price a shape against a managed vendor's MAR (Monthly Active Rows) rate serve Serve a local web console over the shaper (infer/shape/inspect/cost). Requires a build with `--features serve` help Print this message or the help of the given subcommand(s) Options: -v, --verbose... Increase log verbosity (-v = debug, -vv = trace) -h, --help Print help -V, --version Print version
-v is global and may follow any subcommand. Logs go to stderr; reports and
specs go to stdout. serve exists only in a build with the serve
feature.
infer
Sample the input and print a ready-to-edit spec (YAML).
| flag | default | meaning |
|---|---|---|
-i, --input <PATH> | required | File to sample, or - for standard input. |
--format <F> | jsonl | jsonl or json-array. |
--sample <N> | 1000 | Records to sample; 0 reads the whole input. |
--no-flatten | off | Keep each top-level nested object as one json column. |
--dataset <NAME> | input file stem | Dataset name (stdin when reading -). |
-o, --out <PATH> | stdout | Write the spec to a file instead of printing it. |
shape
Shape JSON or JSONL into Parquet or an Iceberg table. With -s it runs a spec and
the flags override it; without, it infers a spec on the fly and -i and
-o are required.
| flag | default | meaning |
|---|---|---|
-s, --spec <PATH> | none | Dataset spec, YAML or JSON. |
-i, --input <PATH> | spec's source.path | Input file, or - for standard input. |
-o, --output <PATH|URL> | spec's output.path | A file or directory for Parquet; a table directory for Iceberg. An s3://, gs://, az:// or file:// URL in an object_store build. |
--to <F> | parquet | parquet or iceberg. |
--format <F> | jsonl | Input format, when there is no spec. |
--compression <C> | snappy | snappy, zstd (needs the zstd feature) or uncompressed. |
--dataset <NAME> | input file stem | Dataset name, when there is no spec. |
--append | off | Iceberg: commit a new snapshot onto the existing table. New optional columns are accepted; other schema changes are refused. Without it, a write onto an existing table replaces it as the next version. |
--partition-by <E> | spec | Iceberg partition fields: a column, or bucket(N, col), truncate(W, col), year|month|day|hour(col). Comma-separate or repeat; commas inside parentheses do not split. |
--merge-on <COLS> | spec | Iceberg: upsert on these key columns. Comma-separate a composite key or repeat the flag. Creates the table if absent. |
--on-drift <P> | spec, else warn | ignore, warn, rescue, quarantine or error (Schema drift). |
--rescue-column <NAME> | _rescued | The catch-all column under rescue. |
--pipeline <M> | auto (on) | auto, on or off. Encode and compress a finished row group on a writer thread while the next is shaped. Never changes the output. |
--summary-json | off | Print one JSON document instead of the text report (below). |
Besides its output, a run may write two files next to it:
<output>.rejects.jsonl— lines that were not JSON, and rows rejected by the reject or quarantine policy, one JSON object each.<output>.drift.json— the full drift report, when something drifted.
The text report always carries one line of counts:
rows_in=.. rows_out=.. rejected=.. parse_errors=.. row_groups=.. bytes=... A merge
adds what it did, a drift adds a summary; see the Quickstart and
Iceberg tables for real ones.
inspect
| argument | meaning |
|---|---|
<PATH> | A Parquet file (footer only, no data scan), an Iceberg table directory, or, in an object_store build, an Iceberg table URL. |
For a table it prints the format version, table uuid, current snapshot, schema and record
count: total-records, or live-records: N (W written, D removed by position
deletes) once merges have deleted rows.
compact
Apply every position delete and pack small files, in one Iceberg replace
snapshot. Commits nothing when there is nothing to do.
| flag | default | meaning |
|---|---|---|
<TABLE> | required | A table directory, or a URL in an object_store build. |
--target-file-size <SIZE> | 512MiB | Files smaller than this are packed together per partition into files of up to about this size. Accepts 512MiB, 64M, 1048576 (K, M, G; binary). 0 packs nothing and only rewrites files that carry deletes. |
--compression <C> | snappy | Codec of the rewritten files. |
--summary-json | off | One JSON document instead of the text report. |
expire
Drop old snapshots, then delete the files only they referenced. Never deletes a file outside the table's location; commits the shorter history before deleting anything.
| flag | default | meaning |
|---|---|---|
<TABLE> | required | A table directory, or a URL in an object_store build. |
--older-than <AGE> | 5d | Expire snapshots committed longer ago than this. A number and a unit: s, m, h, d, w (0s, 12h). |
--retain-last <N> | 1 | Always keep the newest N snapshots of the current history, however old. At least 1. |
--dry-run | off | Report what would go; change nothing. |
--summary-json | off | One JSON document instead of the text report. |
cost
Turn a row count into a managed-vendor-versus-self-host comparison. It never guesses a price: you supply your plan's effective rate. A job too small to pay for its own compute shows a negative saving.
| flag | default | meaning |
|---|---|---|
-i, --input <PATH> | none | Count billable rows by streaming this input (or -), instead of --rows. |
--format <F> | jsonl | Format of --input. |
--rows <N> | none | Billable row count, instead of --input. |
--vendor-per-million <USD> | required | The vendor's effective price per million MAR, from your own plan. |
--self-host-cost <USD> | 0 | What running shapeshift cost you, for a net figure. |
$ shapeshift cost --rows 50000000 --vendor-per-million 0.75 --self-host-cost 12.00 billable rows (MAR-equivalent): 50000000 vendor: $37.50 (@ $0.75/million MAR) self-host: $12.00 saved: $25.50 (68.0%) $ shapeshift cost -i examples/events.jsonl --vendor-per-million 0.75 --self-host-cost 0.01 billable rows (MAR-equivalent): 4 vendor: $0.00 (@ $0.75/million MAR) self-host: $0.01 saved: $-0.01 (-333233.3%)
serve
A local web console over infer, shape, inspect and cost. Build with
--features serve. Single-user, with no authentication: keep it on loopback,
or put your own auth in front of it. Its HTTP endpoints are listed on
Library & HTTP API.
| flag | default | meaning |
|---|---|---|
--addr <ADDR> | 127.0.0.1:8087 | Address to bind. |
--data-dir <DIR> | shapeshift-data | Working directory for output (outputs/), reject sidecars and temporary input (tmp/). |
--allow-host <HOST> | none | An extra Host header value to accept; repeatable. Loopback names and the bind address are always accepted. |
--allow-any-host | off | Disable the Host allow-list. Only behind a trusted proxy. |
$ shapeshift serve
shapeshift serve — console at http://127.0.0.1:8087/
data dir : shapeshift-data
bound to : 127.0.0.1:8087 (Ctrl-C to stop)
Exit status
| status | meaning | what to do |
|---|---|---|
0 | Success. Parse errors, rejected rows and a warn drift do not change it. | Read the counts if they matter to you. |
1 | The run failed: a bad spec, an unreadable input, a strict-mode coercion failure, a drift under error, an I/O or store error. | Read the error; running it again will not help on its own. |
2 | The command line could not be parsed. Printed with the usage text. | Fix the arguments. |
75 | Commit conflict (EX_TEMPFAIL): another writer committed the table version this run built on. Nothing of this run was published, and the files it staged were removed. | Run it again. It will build on the winner. This is the only status worth retrying automatically. |
$ shapeshift shape -i day2.jsonl -o orders --to iceberg --merge-on id Error: commit conflict: another writer committed version 7 of the table while this one ran; nothing of this write was published, and its files were removed. Run it again $ echo $? 75
--summary-json
shape, compact and expire take it. stdout then carries
exactly one JSON document on one line in place of the text report; logs and the text of
an error still go to stderr. The exit status is unchanged.
$ shapeshift shape -i day2.jsonl -o orders --to iceberg --merge-on id --summary-json {"bytes":1732,"command":"shape","dataset":"day2","drift":{"new_fields":[],"policy":"warn","report":null,"rows_quarantined":0,"rows_rescued":0,"rows_scanned":4,"rows_with_drift":0,"truncated":false,"type_mismatches":[]},"merge":{"data_files_pruned":0,"data_files_scanned":1,"delete_files":1,"distinct_keys":2,"duplicates_in_input":1,"key_columns":["id"],"keys_inserted":1,"keys_updated":1,"null_key_rows":1,"position_deletes":2,"prior_rows_replaced":1},"ok":true,"output":{"compression":"snappy","format":"iceberg","path":"orders"},"rejects":null,"row_groups":1,"rows":{"in":4,"out":4,"parse_errors":0,"rejected":0},"summary_version":1,"table":{"metadata":"orders/metadata/v2.metadata.json","snapshot_id":"2400720202925100926","version":2}} $ shapeshift compact orders --summary-json {"bytes":{"rewritten":3459,"written":1772},"command":"compact","committed":true,"data_files":{"kept":0,"rewritten":2,"written":1},"delete_files_removed":1,"ok":true,"options":{"compression":"snappy","target_file_size":536870912},"partitions_compacted":1,"position_deletes_applied":2,"rows_rewritten":5,"snapshot_id":"2107328859142374966","summary_version":1,"table":"orders","version":3}
| command | fields besides summary_version, command, ok |
|---|---|
shape | dataset; output {format, path, compression}; rows {in, out, rejected, parse_errors}; row_groups; bytes; rejects {path, rows} or null; table {version, snapshot_id, metadata}, null for Parquet; merge, null unless merging; drift {policy, rows_scanned, rows_with_drift, rows_quarantined, rows_rescued, new_fields, type_mismatches, truncated, report}, null under ignore; report is the .drift.json path, null when nothing drifted. |
compact | table; committed; version and snapshot_id (null when there was nothing to compact); data_files {rewritten, written, kept}; delete_files_removed; position_deletes_applied; rows_rewritten; bytes {rewritten, written}; partitions_compacted; options {target_file_size, compression}. |
expire | table; dry_run; committed; version (null unless committed); snapshots {expired oldest first, retained}; deleted {data_files, delete_files, manifests, manifest_lists, bytes}, in a dry run what a real run would delete; files_outside_table; files_not_deleted; options {older_than_ms, retain_last}. |
- Snapshot ids are strings. They are 64-bit, past what a JSON number holds exactly in JavaScript and many other tools. Versions and counts are numbers.
- A failed run prints a document too:
{"summary_version":1,"command":…,"ok":false,"error":{"kind":…,"message":…}}.kindisconflict(exit 75; retry), or the engine error —spec,schema,record,drift,arrow,sink,source— orother. summary_versionis the contract. A field may be added within version 1; renaming or removing one, or changing what it means, bumps it.- A command line clap cannot parse is still rejected with status 2 and usage text, not a document.
$ shapeshift shape -i nope.jsonl -o x.parquet --summary-json {"command":"shape","error":{"kind":"other","message":"opening nope.jsonl: io: The system cannot find the file specified. (os error 2)"},"ok":false,"summary_version":1} $ echo $? 1
Environment
| variable | meaning |
|---|---|
RUST_LOG | Log filter (tracing env-filter syntax). When set it replaces the level -v chooses; logs go to stderr. |
SHAPESHIFT_READERS | How many files a merge, compaction or expiry reads at once: a positive integer. Defaults to 8 for an object-store table and up to 4 for a local one. Each reader holds about one row group's key chunks, so lower it for very large row groups. |
AWS_* | S3 credentials, region and endpoint, read by the object_store crate's S3 builder (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_ENDPOINT, …). |
GOOGLE_* | GCS credentials, for example GOOGLE_SERVICE_ACCOUNT. |
AZURE_* | Azure Blob credentials, for example AZURE_STORAGE_ACCOUNT_NAME and AZURE_STORAGE_ACCOUNT_KEY. |
Store variables are read only by an object_store build, through that
crate's from_env() builders; shapeshift neither logs nor stores them. The exact
names are the object_store crate's.
Cargo features
| feature | enables |
|---|---|
zstd | --compression zstd for Parquet and Iceberg data files. |
object_store | URL outputs and table arguments: s3://, gs:// (or gcs://), az:// (or azure://, abfs://, abfss://, adl://), file://. Without it, a URL is a clear error naming the feature. |
serve | The serve subcommand. |
None is on by default. The release binary and the container image are the default build.