parquet-cli 0.1.2

A Parquet CLI for AI agents: inspect, measure and convert Parquet files.
Documentation

parquet-cli

A Parquet CLI for AI agents.

It answers the three questions a program has about a Parquet file: what is in it, how big is it, and what does the data look like. Every command is non-interactive, and every command has a JSON form, so the caller is usually a script rather than a person.

Install

cargo install parquet-cli

The binary is called pqt.

Use

pqt info events.parquet          # size, rows, row groups, who wrote it
pqt schema events.parquet        # the columns and their types
pqt columns events.parquet       # per-column statistics
pqt columns events.parquet --scan  # ... and the exact distinct counts
pqt advise events.parquet        # what could be better about this file
pqt head events.parquet -n 5     # the first rows
pqt cat a.parquet b.parquet      # the rows of several files
pqt validate events.parquet      # is the file sound?
pqt to events.parquet --out events.csv --format csv

The JSON form

Every command takes --json, and then prints one object on stdout:

pqt --json info events.parquet
{
  "file": "events.parquet",
  "size_bytes": 48852480,
  "rows": 2439233,
  "row_groups": 18,
  "columns": 51,
  "bytes_per_row": 20.03,
  "compressions": ["ZSTD"],
  "encodings": ["DELTA_BINARY_PACKED", "PLAIN", "RLE"]
}

pqt head --format jsonl keeps the types of the values (numbers stay numbers), which is what a program wants; --format csv and --format table are there for a person.

Advising on a file

pqt advise looks at the data and says what could be better. It reads the footer only, so it is cheap:

pqt advise events.parquet
column   type              bytes   share  distinct
id       int64             401360  39.3%  100000
country  utf8              3437    0.3%   7
score    decimal128(21,1)  525980  51.5%  100000

warning  type-too-wide        score: 精度 21 > 18 ⇒ 一个值 16 字节;用得着那么多位吗
warning  column-dominates     score: 这一列占了全文件的 51.5%(525980 字节)

The rules it knows: a type that is wider than the values need, a string column whose values repeat but that was written without a dictionary, a column that takes most of the file, a column that is mostly empty, a column whose values are all the same, row groups that are too small, and a footer that takes a big share of the file.

--scan reads the data as well, so the advice can use the distinct values. --contrast N goes one step further: it rewrites the N largest columns with a constant in them, so the difference in size says whether a column is expensive because of its values or because of its shape. That costs a rewrite of the file, so it is opt-in.

Checking a file

pqt validate compares the footer with the file's own bytes: the row counts have to add up, the column chunks have to fit inside the file, and they must not overlap. It exits with 1 when something is wrong, so it can be used in a pipeline.

Where it comes from

The questions it answers are the ones that came up while building Sumimi's cold layer (Parquet archives of a web analytics database): how much smaller is a Parquet copy than the DuckDB file, which columns cost the most bytes, and whether the row groups are the size they should be.

Release

The version lives in Cargo.toml. To cut a release:

# bump the version, then:
git tag v0.1.0
git push origin v0.1.0

GitHub Actions then publishes the crate to crates.io, builds the binaries for macOS, Linux and Windows, and puts them in a GitHub release.

License

Apache-2.0. See LICENSE.