Skip to content

feat: replace carquet C library with pure Zig zig-parquet - #217

Merged
vmvarela merged 6 commits into
masterfrom
feat/zig-parquet-migration
Aug 4, 2026
Merged

feat: replace carquet C library with pure Zig zig-parquet#217
vmvarela merged 6 commits into
masterfrom
feat/zig-parquet-migration

Conversation

@vmvarela

@vmvarela vmvarela commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

Replace bundled C carquet + compression libs (zstd, lz4, zlib) with pure Zig zig-parquet library. Remove ~60 C source files (~150K LOC).

Changes

Build System

  • Add zig_parquet dependency (main branch, Zig 0.16 compatible) with codecs=zig-only
  • Remove all carquet/zstd/lz4/zlib C sources from build.zig
  • Remove pthread + math system library links

Core Logic (src/parquet.zig)

  • Rewrite using zig-parquet DynamicReader API (openBufferDynamic, readAllRows)
  • Schema-based type mapping with logical type support (DATE, TIME, TIMESTAMP, DECIMAL)
  • Row-group batch processing via readAllRows()

Cleanup

  • Delete lib/zstd/, lib/lz4/, lib/zlib/, lib/carquet/ (~60 C files, ~150K LOC)
  • Update .gitignore to remove carquet/zstd/lz4/zlib patterns

Documentation

  • Update codemap.md (root) — replace carquet references with zig-parquet
  • Update src/codemap.md — replace carquet FFI description with zig-parquet DynamicReader API

Verification

  • zig build — compiles
  • zig build test — 120+ integration tests pass
  • zig build unit-test — CSV unit tests pass
  • Manual Parquet tests: sample.parquet, logical_types.parquet, sample_logical.parquet all work correctly

What Remains (C sources)

  • lib/sqlite3.c/h — SQLite amalgamation (no pure Zig alternative)
  • lib/yaml/ — libyaml subset (pure Zig alternatives exist but not yet migrated)

Oracle Reviews

All 3 Oracle review gates passed (Phases 1, 2, 4).

- Remove ~60 C source files (~150K LOC) from lib/carquet/, lib/zstd/, lib/lz4/, lib/zlib/
- Add zig-parquet dependency (main branch, Zig 0.16 compatible) with codecs=zig-only
- Rewrite src/parquet.zig using DynamicReader API (openBufferDynamic, readAllRows)
- Schema-based type mapping with logical type support (DATE, TIME, TIMESTAMP, DECIMAL)
- All compression codecs now pure Zig (zstd, gzip, snappy, lz4, brotli)
- Update documentation (codemap.md, src/codemap.md, .gitignore)
- All 120+ integration tests pass
@github-actions github-actions Bot added the type:feature New functionality label Aug 4, 2026
- Fix DECIMAL byte-array panic: bind raw bytes as TEXT (matches carquet)
- Fix INT96: convert to ISO timestamp (like TIMESTAMP) instead of raw nanos
- Hoist schema lookups out of inner loop (O(R×C²) → O(R×C))
- Trim lib/parquet from 166 to 83 files (remove tests/examples/docs/C-API/WASM/C-codecs)
- Strip C dep declarations from lib/parquet/build.zig.zon
- All 120+ tests pass
… fixture test

- src/parquet.zig: physicalToAffinity maps .int96 to TEXT to match ISO
  timestamp text binding (was INTEGER, causing schema/value mismatch)
- lib/parquet/build.zig: remove opt-in c_api/wasm_wasi/wasm_freestanding
  blocks and wasm-smoke step that referenced deleted src/api surfaces
- build.zig: integration test 206g for INT96 legacy timestamps
- tests/fixtures/int96.parquet: physical INT96 fixture (no logical type)
@vmvarela
vmvarela merged commit 5f227a0 into master Aug 4, 2026
4 checks passed
@vmvarela
vmvarela deleted the feat/zig-parquet-migration branch August 4, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant