Troubleshooting Common Parquet File Errors and Corruption
A practical field troubleshooting guide for resolving common Apache Parquet file reading errors, magic number failures, Snappy decompression errors, and schema mismatches.
Error 1: "Invalid Magic Number (Expected PAR1)"
Symptoms: When opening a Parquet file, your query engine throws "Invalid Parquet file: invalid magic number" or "File does not end with PAR1".
Root Cause: The Apache Parquet specification dictates that every valid file must begin and end with the 4-byte ASCII sequence "PAR1". If this error occurs, the file is almost certainly incomplete or truncated.
Fix: Verify file size against the source system. This frequently happens when an S3 multipart download is interrupted, a disk runs out of space during writing, or an HTTP transfer fails midway.
# Inspect the first and last 4 bytes of the file in terminal:
head -c 4 damaged_file.parquet
# Expected output: PAR1
tail -c 4 damaged_file.parquet
# Expected output: PAR1Error 2: "Snappy Decompressor Stream Corrupted"
Symptoms: Querying or scanning a table fails with "snappy: corrupt input" or "decompression failed on page 4".
Root Cause: This error indicates byte corruption within the compressed data pages. Common causes include network packet corruption during raw FTP/HTTP transfers without checksum validation, or mismatched Snappy framing (raw Snappy stream vs framed Snappy format).
Fix: Re-generate the partition using Zstandard (Zstd) compression, or verify MD5/SHA256 checksums across network transfer boundaries.
Error 3: "Schema Mismatch Across Row Groups or Partitions"
Symptoms: When reading a partitioned directory of Parquet files, you encounter "Cannot merge schemas: column [user_id] has conflicting types INT32 and INT64".
Root Cause: Over time, upstream services modify data models without updating past historical files. Parquet files written before the migration contain 32-bit integers, while newly generated files contain 64-bit integers.
Fix: In DuckDB or Spark, enable schema reconciliation or cast the column explicitly during your SELECT projection.
-- In DuckDB, read partitioned datasets with automatic union of schemas:
SELECT *
FROM read_parquet('data/year=2026/**/*.parquet', union_by_name = true);Frequently Asked Questions
Can TableView.dev open partially corrupted Parquet files?
TableView relies on DuckDB-Wasm. If the footer metadata is intact, DuckDB can often read uncorrupted row groups. If the footer itself is truncated, the file cannot be parsed.
How can I prevent Parquet file corruption in cloud pipelines?
Always use atomic committers (such as the S3A Magic Committer in Hadoop/Spark or transactional formats like Apache Iceberg/Delta Lake) to prevent partial files from being exposed to readers.