Repository navigation
Conversation
…stamps Unwrapped google.protobuf.Timestamp fields always became TIMESTAMP(NANOS,true) columns, so consumers limited to microsecond or millisecond resolution (Iceberg v2 clients, for example) could not read them without a schema rewrite. Add parquet.proto.timestampUnit (MILLIS, MICROS, NANOS) so the writer and the schema converter agree on the column's logical type unit. The default stays NANOS, so existing files and callers are unaffected. Values are truncated toward negative infinity rather than rounded, which keeps the stored value a lower bound of the original instant and matches what a reader recovers at that resolution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Unwrapped
google.protobuf.Timestampfields are always written asTIMESTAMP(NANOS,true)columns, which makes them unreadable for consumers capped at microsecond or millisecond resolution — Iceberg v2 clients and Athena among them, since nanosecond timestamp types arrive only in Iceberg v3 (GH-3972).What changes are included in this PR?
Adds the
parquet.proto.timestampUnitsetting, acceptingMILLIS,MICROS(default is stillNANOS):ProtoWriteSupportreads the setting and converts the unwrappedTimestampvalue to that unit's epoch count.ProtoSchemaConverterannotates the column asTIMESTAMP(unit,true)so the footer schema matches the stored values.BadConfigurationExceptionnaming the setting instead of silently producing a mismatched column.parquet-protobuf/README.mddocuments the setting.Values are truncated toward negative infinity rather than rounded, so the stored value stays a lower bound of the original instant and stays monotonic.
Default behavior is unchanged: with the setting absent the column stays
TIMESTAMP(NANOS,true)and the value is the nanosecond count, exactly as before.Are these changes tested?
Yes. New coverage:
ProtoSchemaConverterTest:TIMESTAMP(MICROS,true)/TIMESTAMP(MILLIS,true)schema output, the setting read from aConfiguration, and theNANOSdefault.ProtoWriteSupportTest: micros and millis round trips through a real Parquet file, the exactaddLongvalue written for a millis column, truncation toward negative infinity before the epoch, rejection of an unknown unit, and case-insensitive parsing of the setting.Commands run locally (JDK 17, Maven 3.10):
Are there any user-facing changes?
Yes, additively:
parquet.proto.timestampUnitis a new optional setting. Behavior without it is unchanged.Closes #3972