fix(datetime): raise specific "Missing zone offset" error in  timestamptz_to_nanos (#3505)

# Rationale for this change

  `timestamptz_to_nanos` should raise a clear "Missing zone
  offset" error when it's given a nanosecond timestamp that has no
  timezone. Today it can't: the check meant to detect a zone-less
  timestamp accidentally tests the *same* pattern as the success
  check right above it, so it never matches. The input falls
  through to the vague "Invalid timestamp with zone" error
  instead.

  The fix is one line check the zone-less pattern
  (`ISO_TIMESTAMP_NANO`) instead, mirroring 
  `timestamptz_to_micros`, which already does this correctly.
  (Introduced in #1632.)

  ## Are these changes tested?

  Yes added tests covering the error messages for both
  `timestamptz_to_nanos` and `timestamp_to_nanos`.
  
  ## Are there any user-facing changes?

  Only a clearer error message: a zone-less nanosecond timestamp
  now reports "Missing zone offset" instead of "Invalid timestamp
  with zone". No API changes.
2 files changed
tree: 79a087447cf4be7b08cbe749226f112ee17496e5
  1. .github/
  2. dev/
  3. mkdocs/
  4. notebooks/
  5. pyiceberg/
  6. tests/
  7. vendor/
  8. .asf.yaml
  9. .codespellrc
  10. .gitignore
  11. .markdownlint.yaml
  12. .pre-commit-config.yaml
  13. AGENTS.md
  14. LICENSE
  15. Makefile
  16. MANIFEST.in
  17. NOTICE
  18. pyproject.toml
  19. README.md
  20. ruff.toml
  21. SECURITY-THREAT-MODEL.md
  22. setup.py
  23. uv.lock
README.md

Iceberg Python

PyIceberg is a Python library for programmatic access to Iceberg table metadata as well as to table data in Iceberg format. It is a Python implementation of the Iceberg table spec.

The documentation is available at https://py.iceberg.apache.org/.

Get in Touch