{
  "id": "data/duckdb-parquet-mismatch-column-count",
  "signature": "DuckDB Parquet read error: column count mismatch between schema and data pages",
  "signature_zh": "DuckDB Parquet 读取错误：schema 和数据页之间的列数不匹配",
  "regex": "column count mismatch.*schema.*data pages|Parquet.*column count.*mismatch",
  "domain": "data",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "Parquet 文件的元数据页脚损坏，schema 声明的列数多于实际数据页中的列数，通常由不完整的写入或文件截断引起。",
  "versions": [
    {
      "version": "DuckDB 0.9.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Apache Parquet 1.12.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PyArrow 12.0.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The corruption is in the file itself; re-downloading the same source without verification repeats the issue.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "DuckDB does not have an ignore_errors option for Parquet; it will fail on metadata parsing.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Repair the file by reading with PyArrow and rewriting: `import pyarrow.parquet as pq; table = pq.read_table('corrupted.parquet'); pq.write_table(table, 'fixed.parquet')`",
      "success_rate": 0.9,
      "how": "Repair the file by reading with PyArrow and rewriting: `import pyarrow.parquet as pq; table = pq.read_table('corrupted.parquet'); pq.write_table(table, 'fixed.parquet')`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use DuckDB's `read_parquet` with `union_by_name=true` to attempt schema reconciliation: `SELECT * FROM read_parquet('file.parquet', union_by_name=true)`",
      "success_rate": 0.7,
      "how": "Use DuckDB's `read_parquet` with `union_by_name=true` to attempt schema reconciliation: `SELECT * FROM read_parquet('file.parquet', union_by_name=true)`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Manually inspect the Parquet metadata with `parquet-tools meta file.parquet` and truncate the schema in the footer if possible.",
      "success_rate": 0.5,
      "how": "Manually inspect the Parquet metadata with `parquet-tools meta file.parquet` and truncate the schema in the footer if possible.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用 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。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://duckdb.org/docs/data/parquet/overview.html",
  "official_doc_section": null,
  "error_code": "IOException",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}