IOException
data
data_error
ai_generated
true
DuckDB Parquet 读取错误:schema 和数据页之间的列数不匹配
DuckDB Parquet read error: column count mismatch between schema and data pages
ID: data/duckdb-parquet-mismatch-column-count
80%修复率
85%置信度
1证据数
2024-01-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| DuckDB 0.9.0+ | active | — | — | — |
| Apache Parquet 1.12.0+ | active | — | — | — |
| PyArrow 12.0.0+ | active | — | — | — |
根因分析
Parquet 文件的元数据页脚损坏,schema 声明的列数多于实际数据页中的列数,通常由不完整的写入或文件截断引起。
English
Parquet file has a corrupted metadata footer where the schema declares more columns than exist in the actual data pages, often caused by incomplete writes or file truncation.
官方文档
https://duckdb.org/docs/data/parquet/overview.html解决方案
-
使用 PyArrow 读取并重写文件修复:`import pyarrow.parquet as pq; table = pq.read_table('corrupted.parquet'); pq.write_table(table, 'fixed.parquet')` -
使用 DuckDB 的 `read_parquet` 并设置 `union_by_name=true` 尝试 schema 协调:`SELECT * FROM read_parquet('file.parquet', union_by_name=true)` -
使用 `parquet-tools meta file.parquet` 手动检查 Parquet 元数据,并在可能的情况下截断页脚中的 schema。
无效尝试
常见但无效的做法:
-
60% 失败
The corruption is in the file itself; re-downloading the same source without verification repeats the issue.
-
90% 失败
DuckDB does not have an ignore_errors option for Parquet; it will fail on metadata parsing.