avz 0.1.2

Blistering-fast Avro CLI tool — a modern replacement for avro-tools and fastavro
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# avz

A blistering-fast Avro CLI tool — a modern replacement for Java's `avro-tools` and Python's `fastavro`.

Supports **local files**, **glob patterns**, and **S3 URIs**.

## Install

### Homebrew (macOS)

```bash
brew tap arunma/tap
brew install avz
```

### Cargo

```bash
cargo install avz
```

### Debian / Ubuntu

Download the `.deb` from [Releases](https://github.com/arunma/avz/releases):

```bash
sudo dpkg -i avz-x86_64-unknown-linux-gnu.deb
```

### From source

```bash
git clone https://github.com/arunma/avz.git
cd avz
cargo build --release
# binary at target/release/avz
```

## Quick Start

```bash
# peek at the first 5 records
avz head -n 5 data.avro

# pretty-print with syntax highlighting
avz cat --pretty data.avro

# search for a record by regex
avz grep "user_id.*12345" data.avro

# search for a literal string (no regex)
avz grep -F "300376641*2967" data.avro

# count records across files using a glob
avz count "logs/*.avro"

# works with S3 too
avz cat "s3://my-bucket/events/dt=2026-03-16/*.avro" --pretty
```

> **Note:** Quote glob patterns and S3 URIs to prevent your shell from expanding them.

## Commands

```
Usage: avz <COMMAND>

Commands:
  cat          Print all records as JSON
  head         Print the first N records (default 10)
  schema       Print the Avro schema as JSON
  count        Count records in Avro files
  meta         Print file metadata (codec, sync marker, user metadata)
  fromjson     Convert JSON records to an Avro file
  concat       Concatenate Avro files into one
  recodec      Re-encode an Avro file with a different codec
  fingerprint  Print schema fingerprint (CRC-64-AVRO, MD5, SHA-256)
  validate     Validate an Avro file or check schema compatibility
  grep         Search records for a pattern, printing matching records as JSON
  random       Generate random records from a schema
```

---

## Command Reference

All examples below use this sample dataset — 8 employee records with fields for id, name, department (enum), salary, email (nullable), tags (array), and active (boolean).

### `cat` — Print records as JSON

Print all records, one JSON object per line:

```bash
$ avz cat employees.avro
```

```json
{"id":1,"name":"Alice Chen","department":"ENGINEERING","salary":125000.0,"email":"alice@example.com","tags":["rust","backend","senior"],"active":true}
{"id":2,"name":"Bob Smith","department":"SALES","salary":95000.0,"email":"bob@example.com","tags":["enterprise","closer"],"active":true}
{"id":3,"name":"Carol Davis","department":"ENGINEERING","salary":140000.0,"email":"carol@example.com","tags":["rust","systems","principal"],"active":true}
...
```

With `--pretty` for colorized, indented output:

```bash
$ avz cat --pretty employees.avro
```

```json
{
  "id": 1,
  "name": "Alice Chen",
  "department": "ENGINEERING",
  "salary": 125000.0,
  "email": "alice@example.com",
  "tags": [
    "rust",
    "backend",
    "senior"
  ],
  "active": true
}
```

Limit output with `-n`:

```bash
$ avz cat -n 2 employees.avro
```

---

### `head` — Print first N records

```bash
$ avz head -n 3 employees.avro
```

```json
{"id":1,"name":"Alice Chen","department":"ENGINEERING","salary":125000.0,"email":"alice@example.com","tags":["rust","backend","senior"],"active":true}
{"id":2,"name":"Bob Smith","department":"SALES","salary":95000.0,"email":"bob@example.com","tags":["enterprise","closer"],"active":true}
{"id":3,"name":"Carol Davis","department":"ENGINEERING","salary":140000.0,"email":"carol@example.com","tags":["rust","systems","principal"],"active":true}
```

With colorized output:

```bash
$ avz head -n 2 --pretty employees.avro
```

```json
{
  "id": 1,
  "name": "Alice Chen",
  "department": "ENGINEERING",
  "salary": 125000.0,
  "email": "alice@example.com",
  "tags": [
    "rust",
    "backend",
    "senior"
  ],
  "active": true
}
{
  "id": 2,
  "name": "Bob Smith",
  "department": "SALES",
  "salary": 95000.0,
  "email": "bob@example.com",
  "tags": [
    "enterprise",
    "closer"
  ],
  "active": true
}
```

Default is 10 records when `-n` is omitted.

---

### `schema` — Print the Avro schema

Outputs colorized JSON with automatic pager for large schemas:

```bash
$ avz schema employees.avro
```

```json
{
  "name": "com.example.hr.Employee",
  "type": "record",
  "fields": [
    {
      "name": "id",
      "type": "int"
    },
    {
      "name": "name",
      "type": "string"
    },
    {
      "name": "department",
      "type": {
        "name": "com.example.hr.Department",
        "type": "enum",
        "symbols": [
          "ENGINEERING",
          "SALES",
          "MARKETING",
          "HR",
          "FINANCE"
        ]
      }
    },
    {
      "name": "salary",
      "type": "double"
    },
    {
      "name": "email",
      "type": [
        "null",
        "string"
      ]
    },
    {
      "name": "tags",
      "type": {
        "type": "array",
        "items": "string"
      }
    },
    {
      "name": "active",
      "type": "boolean"
    }
  ]
}
```

Large schemas automatically pipe through `less -R` in interactive terminals.

---

### `count` — Count records

Single file:

```bash
$ avz count employees.avro
8
```

Multiple files show per-file counts and a total:

```bash
$ avz count employees.avro employees2.avro
employees.avro: 8
employees2.avro: 8
total: 16
```

Works with globs:

```bash
$ avz count "data/*.avro"
```

---

### `meta` — File metadata

Shows the raw schema, codec, sync marker, and any user-defined metadata:

```bash
$ avz meta employees.avro
```

```
avro.schema	{ ... }
avro.codec	null
sync	0be4e3b6562329dbba6c5f06aa43ee96
```

---

### `fingerprint` — Schema fingerprint

Print all fingerprints:

```bash
$ avz fingerprint employees.avro
CRC-64-AVRO	146d06fde15d172f
MD5	874856ac6f65f6eeced12661790a5ec2
SHA-256	3c9dd71e34662cb613aac0d4bdb7afa7309f2712ff97c1991a29028fccd607df
```

Or a specific algorithm:

```bash
$ avz fingerprint --algorithm sha256 employees.avro
3c9dd71e34662cb613aac0d4bdb7afa7309f2712ff97c1991a29028fccd607df
```

Supported: `rabin` (CRC-64-AVRO), `md5`, `sha256`, `all` (default).

---

### `validate` — Validate files and schema compatibility

Validate file integrity (reads every record):

```bash
$ avz validate employees.avro
Validated 8 records in employees.avro
employees.avro: OK
```

Check schema compatibility:

```bash
$ avz validate employees.avro --reader-schema new_schema.json
employees.avro: COMPATIBLE
```

---

### `grep` — Search records

Searches the JSON representation of each record and prints the **entire matching record**:

```bash
$ avz grep "ENGINEERING" employees.avro
```

```json
{"id":1,"name":"Alice Chen","department":"ENGINEERING","salary":125000.0,"email":"alice@example.com","tags":["rust","backend","senior"],"active":true}
{"id":3,"name":"Carol Davis","department":"ENGINEERING","salary":140000.0,"email":"carol@example.com","tags":["rust","systems","principal"],"active":true}
{"id":7,"name":"Grace Kim","department":"ENGINEERING","salary":135000.0,"email":"grace@example.com","tags":["frontend","react","senior"],"active":true}
```

Pretty-print matches:

```bash
$ avz grep --pretty "rust" employees.avro
```

```json
{
  "id": 1,
  "name": "Alice Chen",
  "department": "ENGINEERING",
  "salary": 125000.0,
  "email": "alice@example.com",
  "tags": [
    "rust",
    "backend",
    "senior"
  ],
  "active": true
}
...
```

Case-insensitive:

```bash
$ avz grep -i "alice" employees.avro
{"id":1,"name":"Alice Chen","department":"ENGINEERING","salary":125000.0,...}
```

Fixed string (no regex — useful when pattern has special chars like `*`, `.`, `(`):

```bash
$ avz grep -F "125000.0" employees.avro
{"id":1,"name":"Alice Chen","department":"ENGINEERING","salary":125000.0,...}
```

Count matches:

```bash
$ avz grep -c "ENGINEERING" employees.avro
3
```

Invert match (show non-matching records):

```bash
$ avz grep -v -c "ENGINEERING" employees.avro
5
```

| Flag | Description |
|------|-------------|
| `-i` | Case-insensitive matching |
| `-v` | Invert match (show records that do NOT match) |
| `-c` | Show only the count of matching records |
| `-F` | Treat pattern as a fixed string, not a regex |
| `--pretty` | Colorized pretty-print output |

---

### `fromjson` — Convert JSON to Avro

Convert newline-delimited JSON to an Avro file:

```bash
$ avz fromjson --schema schema.json --output employees.avro employees.jsonl
Wrote 8 records to employees.avro
```

```
Usage: avz fromjson [OPTIONS] --schema <SCHEMA> --output <OUTPUT> [INPUT]

Options:
  -s, --schema <SCHEMA>  Path to the Avro schema JSON file
  -o, --output <OUTPUT>  Output Avro file path
  -c, --codec <CODEC>    Compression codec [default: null]
  [INPUT]                Input JSON file (reads from stdin if omitted)
```

With compression:

```bash
$ avz fromjson --schema schema.json --output data.avro --codec snappy input.jsonl
```

From stdin:

```bash
$ cat records.jsonl | avz fromjson --schema schema.json --output data.avro
```

---

### `concat` — Concatenate Avro files

Merge multiple files into one:

```bash
$ avz concat employees.avro employees2.avro --output merged.avro
Concatenated 16 records from 2 files into merged.avro
```

---

### `recodec` — Re-encode with a different codec

Change the compression codec of an existing Avro file:

```bash
$ avz recodec employees.avro --codec zstandard --output employees-zstd.avro
Re-encoded 8 records with codec 'zstandard' to employees-zstd.avro
```

Verify the codec changed:

```bash
$ avz meta employees-zstd.avro | grep codec
avro.codec	zstandard
```

---

### `random` — Generate random test data

Generate random records from a schema:

```bash
$ avz random --schema schema.json -n 3 --seed 42
```

```json
{"id":52656,"name":"Kate Kim","department":"ENGINEERING","salary":83049.87,"email":"carol821@example.com","tags":["mu xi lambda","iota"],"active":false}
{"id":5028,"name":"Kate Thomas","department":"MARKETING","salary":101244.93,"email":"bob447@test.org","tags":["delta lambda"],"active":true}
{"id":80872,"name":"Grace Smith","department":"ENGINEERING","salary":158813.58,"email":"hank875@example.com","tags":["pi nu"],"active":true}
```

Pretty-print:

```bash
$ avz random --schema schema.json -n 2 --seed 42 --pretty
```

```json
{
  "id": 52656,
  "name": "Kate Kim",
  "department": "ENGINEERING",
  "salary": 83049.87,
  "email": "carol821@example.com",
  "tags": [
    "mu xi lambda",
    "iota"
  ],
  "active": false
}
```

Write directly to Avro format:

```bash
$ avz random --schema schema.json -n 1000 --format avro --output test.avro
```

| Flag | Description |
|------|-------------|
| `-s, --schema` | Path to Avro schema JSON file (required) |
| `-n, --count` | Number of records to generate (default: 10) |
| `--seed` | Random seed for reproducible output |
| `-f, --format` | Output format: `json` (default) or `avro` |
| `-o, --output` | Output file path (required for avro format) |
| `--pretty` | Colorized pretty-print (json format only) |

---

## S3 Support

All read commands work with S3 URIs. AWS credentials are loaded from the standard chain (env vars, `~/.aws/credentials`, IAM role, etc.).

```bash
# single file
avz head -n 5 "s3://my-bucket/data/events.avro"

# glob pattern on S3
avz count "s3://my-bucket/data/dt=2026-03-16/*.avro"

# grep across S3 files
avz grep -F "transaction_id" "s3://my-bucket/data/*.avro"
```

> S3 files are downloaded into memory. For very large individual files, consider downloading first with `aws s3 cp`.

## Supported Codecs

| Codec | Flag value |
|-------|-----------|
| None | `null` |
| Deflate | `deflate` |
| Snappy | `snappy` |
| Zstandard | `zstandard` or `zstd` |
| Bzip2 | `bzip2` or `bzip` |
| XZ | `xz` |

## License

MIT OR Apache-2.0