Skip to main content

JSON output

Commands that report information rather than records print one JSON document with --json (the same as --format-out json). Nothing else goes to stdout, so the output can be piped to jq or read by scripts and agents:

undatum count data.csv --json
undatum headers data.csv --json
undatum stats data.csv --json
{
"schema": "undatum.count/1",
"file": "data.csv",
"rows": 3
}
CommandSchema
countundatum.count/1
headersundatum.headers/1
sniffundatum.sniff/1
statsundatum.stats/1
schema (undatum's own format)undatum.schema/1
schema --validateundatum.schema-validation/1
diffundatum.diff/1
diff --schemaundatum.schema-diff/1
schema-driftundatum.schema-drift/1
validate --rulesundatum.validate/1
validate --fields ... --rule ...undatum.validate-rule/1
analyzeundatum.analyze/1
qualityundatum.quality/1
validate --list-rulesundatum.validate-rules/1
formats listundatum.formats/1
config showundatum.config/1

Record commands (head, frequency, uniq, select, ...) are different: with --json / -O json they print a JSON array of records, without an envelope. schema --format jsonschema|cerberus|avro|parquet prints that standard format as it is.

Versions​

The schema key names the layout and its major version. Adding a key is not a breaking change; removing or renaming a key, or changing its type, raises the version (undatum.stats/1 becomes undatum.stats/2), and the CHANGELOG says so. Check schema before reading a document:

import json, subprocess

result = json.loads(subprocess.run(
["undatum", "count", "data.csv", "--json"], capture_output=True, text=True, check=True
).stdout)
assert result["schema"] == "undatum.count/1"
print(result["rows"])

Errors​

With --json or --format-out json, errors are JSON too: one object on stderr, and the usual exit code (1 user error, 2 usage, configuration or missing dependency, 3 system, 4 internal, 130 interrupted).

undatum stats missing.csv --json
{
"error": {
"code": "file_not_found",
"message": "File not found: 'missing.csv'\nCheck that the file path is correct and the file exists.",
"exit_code": 1,
"details": {"file_path": "missing.csv"}
}
}
CodeExit codeMeaning
file_not_found1An input file does not exist
validation_error1An option value or field name is not valid
format_error1The file format is unknown or cannot be written
invalid_rules1A validation rule file is malformed
invalid_value1A value could not be processed
write_failed1Records could not be written to the output; the output file is incomplete
usage_error2Unknown option, missing argument
configuration_error2Bad configuration
dependency_missing2An optional extra is not installed
permission_denied3A file cannot be read or written
database_error3A database query or connection failed
internal_error4A bug — please report it
interrupted130Ctrl-C

Layouts​

Each layout is also published as a JSON Schema file (linked below).

undatum.repack/1​

Verified local-file recompression outcome. Printed by undatum repack --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.repack/1
inputstringyesSource path
outputstringyesRequested destination
modestringyescontainer or builtin
input_sizeintegeryesOriginal physical source bytes
candidate_sizeintegeryesMeasured encoded candidate bytes
output_sizeinteger or nullyesActual destination bytes, null when absent
statusstringyesreplaced, unchanged, skipped or dry_run
reason_codestringyesaccepted, no_benefit or below_min_savings
publishedbooleanyesWhether this invocation published a destination
changedbooleanyesWhether a changed candidate was published
would_publishbooleanyesWhether policy accepts publication, including original-copy fallback
savings_bytesintegeryesRealized physical savings; zero without publication
savings_percentnumber or nullyesRealized savings percentage, null for zero-size input
candidate_savings_bytesintegeryesOriginal size minus measured candidate size
candidate_savings_percentnumber or nullyesMeasured candidate savings percentage
elapsed_secondsnumberyesTotal operation time including verification and guards
effective_settingsobjectyesCandidate codec/profile/level/threads and whether applied
verificationobjectyesIndependent preservation method and result
resourcesobjectyesDecoded work, scratch peak and native worker monitoring
timingsobjectyesEncoding and verification times in seconds
rowsinteger or nullPreserved native row count
decoded_bytesintegerSource payload/logical native bytes processed once
bytes_readintegerLegacy alias of decoded_bytes
bytes_writteninteger or nullLegacy alias of actual output_size
codecstringRequested outer codec for container mode
compressionstringRequested native codec for builtin mode
levelinteger or nullCandidate compression level
profilestringCandidate performance profile

undatum.count/1​

Number of records in a file. Printed by undatum count --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.count/1
filestringyesInput path
rowsintegeryesNumber of records

undatum.headers/1​

Field names of a file. Printed by undatum headers --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.headers/1
filestringyesInput path
fieldsarrayyesField names in file order (nested fields as dotted paths)

undatum.sniff/1​

Detected file properties. Printed by undatum sniff --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.sniff/1
filestringyesInput path
filetypestringyesDetected format id (csv, jsonl, parquet, ...)
compressionstring or nullCompression codec (gz, zst, ...), null if none
encodingstring or nullText encoding, null for binary formats
delimiterstring or nullField delimiter of delimited text, else null
has_headerboolean or nullWhether the first line is a header (CSV/TSV)
record_countintegeryesNumber of records
sample_sizeintegerRecords sampled for field types
fieldsobjectyesField name -> type and up to 3 examples

undatum.stats/1​

Field statistics. Printed by undatum stats --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.stats/1
countintegeryesRecords profiled
num_fieldsintegeryesNumber of fields
fieldtypesobjectyesField -> detected type: int, float, bool, date, datetime, numstr (digits with leading zeros) or str
fieldsarrayyesPer-field statistics
dictkeysarrayFields with few distinct values
dictsobjectValue lists of the dictionary fields
debugobjectEngine diagnostics (engine, timings); not stable

undatum.schema/1​

Inferred table schema (undatum's own format). Printed by undatum schema --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.schema/1
idstringTable id (file name)
keystringHash of the field list
num_colsintegerNumber of fields
num_recordsintegerRecords read (-1 when not counted)
is_flatbooleanNo nested fields
descriptionstring or nullDescription (with --autodoc)
fieldsarrayyesFields: name, ftype, is_array, description, ...
filesarray or nullFiles with this schema (schema-bulk)
successbooleanInference succeeded
errorstring or nullError message when inference failed

undatum.schema-validation/1​

Rows checked against the inferred schema. Printed by undatum schema --validate --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.schema-validation/1
validbooleanyesNo invalid rows
statsobjectyesvalid, invalid, total, errors_by_field
invalid_samplearrayUp to 20 invalid rows with their errors

undatum.diff/1​

Records added, removed and changed between two files. Printed by undatum diff --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.diff/1
file1stringyesOld file
file2stringyesNew file
keyarray or nullKey fields (null: records compared whole)
summaryobjectyesfile1_count, file2_count, added_count, removed_count, changed_count
addedarrayRecords only in file2 (not with --summary-only)
removedarrayRecords only in file1 (not with --summary-only)
changedarrayChanged records with key, old and new (not with --summary-only)

undatum.schema-diff/1​

Schema changes between two files or declared schemas. Printed by undatum diff --schema --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.schema-diff/1
oldstringyesBaseline file or schema
newstringyesCompared file or schema
summaryobjectyesChanges per kind: added, removed, type, nullability
changesarrayyesChanges: kind, field, old and new type or nullability
renamesarrayyesLikely renames: old, new, name_similarity, value_overlap

undatum.schema-drift/1​

Schema changes of a set of files against a baseline. Printed by undatum schema-drift --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.schema-drift/1
baselinestringyesBaseline file or schema
summaryobjectyesfiles (compared) and drifted (with changes)
filesarrayyesPer file: file, summary, changes, renames

undatum.validate/1​

Rule-file validation report. Printed by undatum validate --rules --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.validate/1
statisticsobjectyestotal_records, total_violations, errors, warnings, info, passed; with a data contract also failed_checks (error, warning, info)
violations_by_fieldobjectField -> number of violations
violations_by_ruleobjectRule -> number of violations
violationsarrayyesViolations (at most --max-violations)
contractobjectWith an ODCS data contract: object, checks (name, fields, metric, value, unit, operator, limit, expected, passed, severity, description), not_checked (name, reason)

undatum.validate-rules/1​

Built-in validation rules. Printed by undatum validate --list-rules --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.validate-rules/1
rulesarrayyesRules: name, description, params, extra
keysobjectyesRule-file keys that are checks (required, unique, ...)

undatum.validate-rule/1​

Values checked against one built-in rule. Printed by undatum validate --rule --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.validate-rule/1
rulestringyesRule name, e.g. common.email
fieldstringyesChecked field
modestringinvalid, valid, all or stats
statisticsobjectyestotal, invalid, novalue, share (percent invalid)
recordsarrayChecked values with a FIELD_valid flag (omitted with --mode stats)

undatum.quality/1​

Data quality report with a pass/fail verdict. Printed by undatum quality --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.quality/1
filestringyesInput path
summaryobjectyesrows, fields, empty_values, violations per severity (null without --rules)
fieldsarrayyesPer field: name, type, values, nulls, null_rate, distinct, conformance, top_values
schema_checkobjectyesexpected, inferred types, changes and renames against --schema
violationsobjectyesby_severity, by_rule and a sample of rule violations
verdictobjectyespassed and the threshold checks (name, target, value, limit, passed)

undatum.analyze/1​

File analysis report. Printed by undatum analyze --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.analyze/1
filenamestringyesInput path
file_sizeintegerSize in bytes
file_typestringDetected format id
compressionstringCompression codec or raw
total_tablesintegerNumber of tables
total_recordsintegerNumber of records
tablesarrayyesPer-table structure: fields, types, descriptions
metadataobjectEncoding, delimiter and other file metadata
successbooleanAnalysis succeeded
errorstring or nullError message when analysis failed

undatum.formats/1​

Supported formats and their capabilities. Printed by undatum formats list --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.formats/1
formatsarrayyesFormats: id, readable, writable, ...

undatum.extensions/1​

DuckDB extensions undatum uses and whether they are installed. Printed by undatum extensions list --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.extensions/1
directorystringyesExtension directory
extensionsarrayyesExtensions: name, purpose, installed, path, size (bytes); install adds downloaded

undatum.cache/1​

Cached command results. Printed by undatum cache list --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.cache/1
directorystringyesCache directory
entriesarrayyesCached files: path, size, mtime, stale, bytes, results (command, created, bytes)

undatum.config/1​

Effective CLI configuration. Printed by undatum config show --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.config/1
filesobjectyesConfig files read: home, project
defaultsobjectyesMerged command defaults

undatum.commands/1​

The command-line interface as data. Printed by undatum commands --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.commands/1
undatum_versionstringyesundatum version
exit_codesobjectyesExit code -> meaning
global_optionsarrayyesOptions of the undatum command itself (see commands)
groupsarrayyesCommand groups: name, summary
commandsarrayyesCommands: name, summary, help, examples, usage, arguments, options (name, flags, negation, type, choices, default, required, multiple, flag, count, deprecated_flags, help), engines, capabilities, results (schema, when), deprecated