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

shapeshift --help
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).

flagdefaultmeaning
-i, --input <PATH>requiredFile to sample, or - for standard input.
--format <F>jsonljsonl or json-array.
--sample <N>1000Records to sample; 0 reads the whole input.
--no-flattenoffKeep each top-level nested object as one json column.
--dataset <NAME>input file stemDataset name (stdin when reading -).
-o, --out <PATH>stdoutWrite 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.

flagdefaultmeaning
-s, --spec <PATH>noneDataset spec, YAML or JSON.
-i, --input <PATH>spec's source.pathInput file, or - for standard input.
-o, --output <PATH|URL>spec's output.pathA file or directory for Parquet; a table directory for Iceberg. An s3://, gs://, az:// or file:// URL in an object_store build.
--to <F>parquetparquet or iceberg.
--format <F>jsonlInput format, when there is no spec.
--compression <C>snappysnappy, zstd (needs the zstd feature) or uncompressed.
--dataset <NAME>input file stemDataset name, when there is no spec.
--appendoffIceberg: 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>specIceberg 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>specIceberg: upsert on these key columns. Comma-separate a composite key or repeat the flag. Creates the table if absent.
--on-drift <P>spec, else warnignore, warn, rescue, quarantine or error (Schema drift).
--rescue-column <NAME>_rescuedThe 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-jsonoffPrint one JSON document instead of the text report (below).

Besides its output, a run may write two files next to it:

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

argumentmeaning
<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.

flagdefaultmeaning
<TABLE>requiredA table directory, or a URL in an object_store build.
--target-file-size <SIZE>512MiBFiles 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>snappyCodec of the rewritten files.
--summary-jsonoffOne 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.

flagdefaultmeaning
<TABLE>requiredA table directory, or a URL in an object_store build.
--older-than <AGE>5dExpire snapshots committed longer ago than this. A number and a unit: s, m, h, d, w (0s, 12h).
--retain-last <N>1Always keep the newest N snapshots of the current history, however old. At least 1.
--dry-runoffReport what would go; change nothing.
--summary-jsonoffOne 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.

flagdefaultmeaning
-i, --input <PATH>noneCount billable rows by streaming this input (or -), instead of --rows.
--format <F>jsonlFormat of --input.
--rows <N>noneBillable row count, instead of --input.
--vendor-per-million <USD>requiredThe vendor's effective price per million MAR, from your own plan.
--self-host-cost <USD>0What running shapeshift cost you, for a net figure.
cost
$ 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.

flagdefaultmeaning
--addr <ADDR>127.0.0.1:8087Address to bind.
--data-dir <DIR>shapeshift-dataWorking directory for output (outputs/), reject sidecars and temporary input (tmp/).
--allow-host <HOST>noneAn extra Host header value to accept; repeatable. Loopback names and the bind address are always accepted.
--allow-any-hostoffDisable the Host allow-list. Only behind a trusted proxy.
serve
$ 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

statusmeaningwhat to do
0Success. Parse errors, rejected rows and a warn drift do not change it.Read the counts if they matter to you.
1The 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.
2The command line could not be parsed. Printed with the usage text.Fix the arguments.
75Commit 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.
a refused commit (from the repository README)
$ 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.

a merge, then a compaction (keys sorted; their order is not part of the contract)
$ 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}
commandfields besides summary_version, command, ok
shapedataset; 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.
compacttable; 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}.
expiretable; 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}.
a failed run (captured on Windows; the OS error text varies)
$ 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

variablemeaning
RUST_LOGLog filter (tracing env-filter syntax). When set it replaces the level -v chooses; logs go to stderr.
SHAPESHIFT_READERSHow 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

featureenables
zstd--compression zstd for Parquet and Iceberg data files.
object_storeURL 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.
serveThe serve subcommand.

None is on by default. The release binary and the container image are the default build.