{
  "id": "data/parquet-row-group-size-mismatch",
  "signature": "Parquet row group size mismatch causes memory error during read",
  "signature_zh": "Parquet行组大小不匹配导致读取时内存错误",
  "regex": "(?:OutOfMemoryError|Row group.*size|memory.*parquet|row_group.*too large)",
  "domain": "data",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "Parquet files written with very large row group sizes (e.g., >1GB) cause memory exhaustion when read by systems that load entire row groups into memory, especially in memory-constrained environments like Spark executors or pandas.",
  "root_cause_type": "generic",
  "root_cause_zh": "写入时行组过大（例如>1GB）的Parquet文件，在被需要将整个行组加载到内存的系统读取时（尤其是在Spark执行器或pandas等内存受限的环境中），会导致内存耗尽。",
  "versions": [
    {
      "version": "Apache Spark 3.4",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Apache Spark 3.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "pyarrow 13.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "pandas 2.1.4",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This only postpones the problem; row groups can grow unboundedly and may still exceed the increased heap, causing OOM again.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This setting adjusts shuffle partitions, not Parquet row group sizes; it does not affect how row groups are read.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Compression reduces file size on disk but row groups are decompressed in memory; the memory footprint remains the same.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Rewrite the Parquet file with smaller row group size: `import pyarrow.parquet as pq; table = pq.read_table('large.parquet'); pq.write_table(table, 'small.parquet', row_group_size=100000)`",
      "success_rate": 0.9,
      "how": "Rewrite the Parquet file with smaller row group size: `import pyarrow.parquet as pq; table = pq.read_table('large.parquet'); pq.write_table(table, 'small.parquet', row_group_size=100000)`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use Spark with parquet.row-group-size-bytes set: `spark.conf.set('spark.sql.parquet.rowGroupSize', 256 * 1024 * 1024)` and repartition the data before writing",
      "success_rate": 0.85,
      "how": "Use Spark with parquet.row-group-size-bytes set: `spark.conf.set('spark.sql.parquet.rowGroupSize', 256 * 1024 * 1024)` and repartition the data before writing",
      "condition": "",
      "sources": []
    },
    {
      "action": "Read the Parquet file in chunks using pyarrow's read_row_group method: `for i in range(parquet_file.metadata.num_row_groups): table = parquet_file.read_row_group(i)`",
      "success_rate": 0.88,
      "how": "Read the Parquet file in chunks using pyarrow's read_row_group method: `for i in range(parquet_file.metadata.num_row_groups): table = parquet_file.read_row_group(i)`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Rewrite the Parquet file with smaller row group size: `import pyarrow.parquet as pq; table = pq.read_table('large.parquet'); pq.write_table(table, 'small.parquet', row_group_size=100000)`",
    "Use Spark with parquet.row-group-size-bytes set: `spark.conf.set('spark.sql.parquet.rowGroupSize', 256 * 1024 * 1024)` and repartition the data before writing",
    "Read the Parquet file in chunks using pyarrow's read_row_group method: `for i in range(parquet_file.metadata.num_row_groups): table = parquet_file.read_row_group(i)`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://parquet.apache.org/docs/file-format/",
  "official_doc_section": null,
  "error_code": "OutOfMemoryError",
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.86,
  "resolvable": "true",
  "first_seen": "2024-02-28",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}