{
  "id": "data/parquet-timestamp-timezone-mismatch",
  "signature": "Parquet timestamp values differ by hours after reading with different timezone settings in Spark or PyArrow",
  "signature_zh": "Parquet时间戳值在Spark或PyArrow中因不同时区设置读取后相差数小时",
  "regex": "timestamp.*timezone|timezone.*mismatch|off.*by.*hours|UTC.*local",
  "domain": "data",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Parquet timestamps are stored as UTC by convention, but the reader (e.g., Spark, PyArrow) may apply a local timezone conversion if the session timezone is not set to UTC, leading to off-by-hours errors.",
  "root_cause_type": "generic",
  "root_cause_zh": "Parquet时间戳按约定存储为UTC，但如果会话时区未设置为UTC，读取器（如Spark、PyArrow）可能会应用本地时区转换，导致数小时的误差。",
  "versions": [
    {
      "version": "Spark 3.4",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PyArrow 12.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Pandas 2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Manually adding or subtracting hours to timestamps after reading",
      "why_fails": "Hard-coded offsets are fragile and do not account for daylight saving time or varying timezone configurations.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Converting all timestamps to local time in the source system before writing",
      "why_fails": "This breaks the UTC convention and causes inconsistent behavior across different readers.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set Spark session timezone to UTC before reading: spark.conf.set('spark.sql.session.timeZone', 'UTC').",
      "success_rate": 0.95,
      "how": "Set Spark session timezone to UTC before reading: spark.conf.set('spark.sql.session.timeZone', 'UTC').",
      "condition": "",
      "sources": []
    },
    {
      "action": "In PyArrow, specify the timestamp resolution: pq.read_table('file.parquet', timestamp_as_object=True) and manually convert to UTC.",
      "success_rate": 0.8,
      "how": "In PyArrow, specify the timestamp resolution: pq.read_table('file.parquet', timestamp_as_object=True) and manually convert to UTC.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在读取前将Spark会话时区设置为UTC：spark.conf.set('spark.sql.session.timeZone', 'UTC')。",
    "在PyArrow中，指定时间戳分辨率：pq.read_table('file.parquet', timestamp_as_object=True)并手动转换为UTC。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://spark.apache.org/docs/latest/sql-ref-datetime.html#timestamp-and-timezone",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.85,
  "resolvable": "partial",
  "first_seen": "2023-05-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}