Skip to content

fix: format identity partition paths for nanosecond timestamps - #3659

Open
anxkhn wants to merge 1 commit into
apache:mainfrom
anxkhn:patch-18
Open

anxkhn wants to merge 1 commit into
apache:mainfrom
anxkhn:patch-18

Conversation

@anxkhn

@anxkhn anxkhn commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

Identity transforms render timestamp_ns and timestamptz_ns partition values
as raw integers because neither type is registered with the human-string
formatter.

Register both types and add integer-only nanosecond formatters. Fractional
trailing zeros are trimmed, whole seconds have no fraction, and timezone-aware
values use +00:00. This matches Java's DateTimeUtil.nanosToIsoTimestamp and
nanosToIsoTimestamptz. The earlier fixed-nine-digit description was incorrect.

Are these changes tested?

  • make lint passes, including mypy, Ruff, codespell, and lockfile validation.
  • make test passes the full unit suite.
  • Formatter tests cover whole seconds, leading and trailing fractional zeros,
    nanosecond precision, negative timestamps, and UTC offsets.
  • Transform and partition-path tests cover both nanosecond types alongside the
    existing microsecond types.
  • Output was checked against the Java reference implementation.

Docker/Spark integration tests were not run locally.

Are there any user-facing changes?

Yes. Human strings and identity partition paths for nanosecond timestamp columns
now contain ISO-8601 timestamps rather than raw integers.

This update was prepared with AI assistance through OpenCode and independently
source-reviewed by Opus 5.5 and Gemini 4 Neon. Those reviews are not maintainer
approvals.

@anxkhn

anxkhn commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@kevinjqliu when you have a chance, could you please take a look at this pr and let me know if any update is needed?

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this!

The description says the fixed 9-digit output "matches the Java DateTimeUtil.nanosToIsoTimestamp behavior… with no trailing-zero trimming", but Java actually does the opposite. It trims trailing zeros (and drops the fraction entirely for a whole second). nanosToIsoTimestamp formats via DateTimeFormatter.ISO_LOCAL_DATE_TIME, whose appendFraction(NANO_OF_SECOND, 0, 9, true) omits trailing zeros.

Copilot AI lite review requested due to automatic review settings September 17, 2026 04:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved blocking issues were identified.

Pull request overview

Fixes ISO-8601 formatting for identity-partitioned nanosecond timestamps.

Changes:

  • Adds nanosecond timestamp formatting helpers.
  • Registers handlers for nanosecond timestamp types.
  • Adds unit and partition-path coverage.
File summaries
File Description
tests/utils/test_datetime.py Tests nanosecond formatting edge cases.
tests/test_transforms.py Tests identity transform output.
tests/table/test_partitioning.py Tests generated partition paths.
pyiceberg/utils/datetime.py Adds nanosecond ISO formatting.
pyiceberg/transforms.py Registers nanosecond type handlers.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Nov 25, 2026
Identity transforms on timestamp_ns and timestamptz_ns rendered raw integers
instead of ISO-8601 partition directory values.

Add integer-only nanosecond formatters and register both timestamp types.
Preserve nanosecond precision while trimming trailing fractional zeros and
omitting the fraction for whole seconds, matching Java DateTimeUtil.
Use the explicit +00:00 offset for timezone-aware values.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants