Skip to content

Core: Load and serialize nanosecond timestamp defaults - #4462

Open
Anurag-S1ngh wants to merge 1 commit into
apache:mainfrom
Anurag-S1ngh:fix/4078-ns-initial-default
Open

Anurag-S1ngh wants to merge 1 commit into
apache:mainfrom
Anurag-S1ngh:fix/4078-ns-initial-default

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Part of #4078.

Rationale for this change

JSON single-value conversion had no handler for timestamp_ns and timestamptz_ns, so loading a V3 metadata file with a nanosecond initial-default raised TypeError: Cannot deserialize bytes, type timestamp_ns not supported.

Python datetime cannot hold nanoseconds, so these values are parsed as nanoseconds since epoch and formatted back as ISO-8601 with nine fractional digits. This preserves the exact value instead of truncating to microseconds.

Are these changes tested?

Yes. The JSON conversion tests cover formatting, round trips, and parsing for both nanosecond types, including values supplied as datetime where the last three digits are zero. A field default test confirms that a nanosecond initial-default loads as an integer and serializes back unchanged. tests/test_conversions.py and tests/test_types.py pass.

Are there any user-facing changes?

No API change. V3 metadata with nanosecond timestamp defaults can now be loaded and serialized.

JSON single-value conversion had no handler for timestamp_ns and
timestamptz_ns, so loading a V3 metadata file with a nanosecond default
raised TypeError. Python datetime cannot hold nanoseconds, so parse these
values as nanoseconds since epoch and format them back with nine
fractional digits.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant