Catch schema drift with rugo diff

Correct at time of publishing, tested with rugo 0.5.12. For up-to-date performance and feature information, see rugo.dev.

Nobody announces a schema change. A column is renamed upstream, an ID that was a number turns into text, a new field appears. Every one of those still produces a perfectly valid file, and every one can break whatever reads it next. rugo diff compares the schemas of two files in one command, tells you exactly what moved, and exits 1 when anything did. That exit code is all you need to turn it into a gate.

Two exports, one quiet change

Say an orders export runs every night. Here is last week's file, and this week's, after an upstream team "tidied" the schema without telling anyone. The customer name became a numeric customer_id, order IDs gained a prefix, and there is a new coupon column.

pip install rugo
cat > orders_v1.csv <<'EOF'
order_id,customer,amount,placed_at,note
1001,ada,19.99,2026-11-01,gift
1002,grace,5.00,2026-11-01,
1003,linus,42.50,2026-11-02,rush
EOF

cat > orders_v2.csv <<'EOF'
order_id,customer_id,amount,placed_at,note,coupon
A-1001,7,19.99,2026-11-01,gift,SAVE5
A-1002,8,5.00,2026-11-01,,
A-1003,9,42.50,2026-11-02,rush,
EOF

rugo convert orders_v1.csv orders_v1.parquet
rugo convert orders_v2.csv orders_v2.parquet
orders_v1.csv (csv, 3 rows) -> orders_v1.parquet (parquet)
orders_v2.csv (csv, 3 rows) -> orders_v2.parquet (parquet)

Ask what changed

One command, two paths. Left is the baseline, right is the candidate:

rugo diff orders_v1.parquet orders_v2.parquet; echo "exit code: $?"
+ added:   coupon, customer_id
- removed: customer
~ changed:
name      left_type  right_type  left_nullable  right_nullable
--------  ---------  ----------  -------------  --------------
order_id  int64      varchar     True           True
exit code: 1

Three kinds of change, each on its own line: + added columns, - removed columns, and ~ changed columns, which shows the old and new type and nullability side by side. A rename is a removal plus an addition, which is how customer became customer_id here. The type change is the dangerous one: order_id quietly stopped being a number.

Compare a file with itself and you get the all-clear, with exit code 0:

rugo diff orders_v1.parquet orders_v1.parquet; echo "exit code: $?"
schemas are identical
exit code: 0

It reads footers, not data

A schema diff and a data diff are different questions. A data diff tells you that rows changed, which they do every night. A schema diff tells you the shape of the table changed, which almost never happens on purpose. For Parquet that answer lives in the file footer, and rugo reads only the footer. Comparing a 945 MB, 100-column Parquet file with itself finishes in under a tenth of a second on a laptop, so the check costs nothing whether the files hold three rows or three billion.

Machine-readable, with --json

Add --json and the same result becomes structured data: columns_added, columns_removed, columns_changed and an identical flag. With jq you can shape it however you like:

rugo diff --json orders_v1.parquet orders_v2.parquet |
  jq -c '{added: .columns_added, removed: .columns_removed, changed: [.columns_changed[].name]}'
{"added":["coupon","customer_id"],"removed":["customer"],"changed":["order_id"]}

A breaking-change gate in 15 lines

Not every change deserves a red build. A new column is harmless to existing readers; a removed or retyped one is not. This script encodes that policy: it prints every change, labels it, and fails only on the breaking kind. Save it as tools/check_drift.sh:

#!/usr/bin/env bash
# Usage: check_drift.sh BASELINE CANDIDATE
# Fails on breaking drift (a column removed or retyped). New columns are fine.
set -uo pipefail

report=$(rugo diff --json "$1" "$2") || true
[ -n "$report" ] || { echo "rugo diff produced no report" >&2; exit 2; }

echo "$report" | jq -r '
  (.columns_added[]   | "  + added    \(.)  (compatible)"),
  (.columns_removed[] | "  - removed  \(.)  (BREAKING)"),
  (.columns_changed[] | "  ~ changed  \(.name): \(.left_type) -> \(.right_type)  (BREAKING)")'

breaking=$(echo "$report" | jq '(.columns_removed | length) + (.columns_changed | length)')
if [ "$breaking" -gt 0 ]; then
  echo "$breaking breaking change(s)"
  exit 1
fi
echo "no breaking changes"

rugo diff exits 1 for any difference, so the script captures the JSON report first and makes its own decision from the counts. If the files cannot be read at all there is no report, and it exits 2 so a missing file is never mistaken for clean data. Run it on the nightly pair:

chmod +x tools/check_drift.sh
tools/check_drift.sh orders_v1.parquet orders_v2.parquet; echo "exit code: $?"
  + added    coupon  (compatible)
  + added    customer_id  (compatible)
  - removed  customer  (BREAKING)
  ~ changed  order_id: int64 -> varchar  (BREAKING)
2 breaking change(s)
exit code: 1

Now a purely additive week, where the only change is the new coupon column. The gate lets it through and says why:

cat > orders_v3.csv <<'EOF'
order_id,customer,amount,placed_at,note,coupon
1001,ada,19.99,2026-11-01,gift,SAVE5
1002,grace,5.00,2026-11-01,,
1003,linus,42.50,2026-11-02,rush,
EOF
rugo convert orders_v3.csv orders_v3.parquet

tools/check_drift.sh orders_v1.parquet orders_v3.parquet; echo "exit code: $?"
orders_v3.csv (csv, 3 rows) -> orders_v3.parquet (parquet)
  + added    coupon  (compatible)
no breaking changes
exit code: 0

Run it on every pull request

If Parquet files live in your repository (reference data, exported samples, fixtures that define a contract), the pull request itself is the "two exports". Compare each changed file with the version on the base branch. Save this as .github/workflows/schema-drift.yml:

name: schema-drift

on:
  pull_request:
    paths:
      - "data/**.parquet"

jobs:
  drift:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 0
      - uses: actions/setup-python@v7
        with:
          python-version: "3.12"
      - run: pip install rugo
      - name: Compare each changed Parquet file with its base version
        env:
          BASE: origin/${{ github.base_ref }}
        run: |
          failed=0
          while IFS= read -r -d '' file; do
            echo "== $file"
            git show "$BASE:$file" > /tmp/base.parquet
            tools/check_drift.sh /tmp/base.parquet "$file" || failed=1
          done < <(git diff -z --name-only --diff-filter=M "$BASE"...HEAD -- 'data/*.parquet')
          exit "$failed"

The job only runs when a Parquet file under data/ changes. fetch-depth: 0 brings the base branch into the checkout, and git diff --diff-filter=M picks out the files that were modified, so brand-new files have nothing to be compared against. Each one is checked against its previous version, and one breaking change anywhere fails the job. The log reads exactly like the terminal output above.

Get the most from it

Two files in, one verdict out, and an exit code every scheduler and CI system already understands. Schema drift stops being a surprise in a dashboard and becomes a one-line message in a pull request.