{
  "id": "data/parquet-float-precision-loss-rounding",
  "signature": "Parquet float column values 0.1 + 0.2 != 0.3 after round-trip due to floating-point rounding in schema",
  "signature_zh": "Parquet浮点数列的值在往返过程中由于模式中的浮点舍入导致0.1 + 0.2 != 0.3",
  "regex": "0\\.1 \\+ 0\\.2|floating.point|precision loss|rounding error",
  "domain": "data",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Parquet uses FLOAT (32-bit) or DOUBLE (64-bit) types; when writing float values, binary representation causes precision loss, and reading back may introduce additional rounding errors in aggregation or comparison.",
  "root_cause_type": "generic",
  "root_cause_zh": "Parquet使用FLOAT（32位）或DOUBLE（64位）类型；写入浮点值时，二进制表示导致精度损失，重新读取时可能在聚合或比较中引入额外的舍入误差。",
  "versions": [
    {
      "version": "PyArrow 12.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Spark 3.4",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Parquet 2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using Decimal type in Parquet schema to store all floats",
      "why_fails": "Decimal type can reduce precision loss but introduces performance overhead and may not be supported by all readers.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Rounding values to a fixed number of decimal places before writing",
      "why_fails": "Rounding can mask the issue but does not eliminate floating-point errors; comparisons still fail for edge cases.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use DOUBLE instead of FLOAT for high-precision columns: pd.read_parquet('file.parquet', dtype_backend='pyarrow') and cast to float64.",
      "success_rate": 0.8,
      "how": "Use DOUBLE instead of FLOAT for high-precision columns: pd.read_parquet('file.parquet', dtype_backend='pyarrow') and cast to float64.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Apply a tolerance when comparing float values: if abs(a - b) < 1e-9: treat as equal.",
      "success_rate": 0.9,
      "how": "Apply a tolerance when comparing float values: if abs(a - b) < 1e-9: treat as equal.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "对于高精度列使用DOUBLE而非FLOAT：pd.read_parquet('file.parquet', dtype_backend='pyarrow')并转换为float64。",
    "在比较浮点值时应用容差：if abs(a - b) < 1e-9: 视为相等。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.75,
  "resolvable": "partial",
  "first_seen": "2023-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}