Map DateTime to google.protobuf.Timestamp and document temporal string formats#1306
Open
jwils wants to merge 1 commit into
Open
Map DateTime to google.protobuf.Timestamp and document temporal string formats#1306jwils wants to merge 1 commit into
jwils wants to merge 1 commit into
Conversation
f62a859 to
90e2af5
Compare
5a2e67d to
1537869
Compare
…g formats `DateTime` fields now use the well-known `google.protobuf.Timestamp` type (with `google/protobuf/timestamp.proto` imported automatically) instead of `string`. A Timestamp cannot be malformed the way a string can, and proto consumers get language-native timestamp types. Note that a Timestamp is a UTC instant, so a publisher's original UTC offset is not preserved; `t.protobuf type: "string"` remains available to override. To support this, `t.protobuf` gains two options usable by any scalar: - `import:` maps a scalar to an externally defined proto type, emitting the needed `import` statement in `schema.proto`. - `comment:` documents the expected format on each generated field, used by the built-in `string`-typed temporal scalars (`Date`, `LocalTime`, `TimeZone`) whose proto type is wider than the ElasticGraph type (e.g. `// ISO 8601 date`). Values are still validated at ingestion time, just as with JSON ingestion.
90e2af5 to
616dbfd
Compare
1537869 to
721fe97
Compare
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.
Why
Mapping
DateTimetostringloses the type safety proto offers — a string can be malformed in ways agoogle.protobuf.Timestampcannot, and proto consumers get language-native timestamp types. For the remainingstring-typed temporal scalars, the proto type is much wider than the ElasticGraph type, so the expected format deserves documentation at the point of use (per review discussion).What
DateTimetogoogle.protobuf.Timestamp, importinggoogle/protobuf/timestamp.protoautomatically. ATimestampis a UTC instant, so a publisher's original UTC offset is not preserved;t.protobuf type: "string"remains available as an override.t.protobufgains two options usable by any scalar:import:maps a scalar to an externally defined proto type, emitting the neededimportstatementcomment:documents the expected format on each generated fieldstring-typed temporal scalars (Date,LocalTime,TimeZone) usecomment:to document their formats (e.g.// ISO 8601 date, e.g. "2024-11-25"). Values are still validated at ingestion time, exactly as with JSON ingestion.source name:comments and propagate to the innermost nested-list wrapper field.Risk Assessment
Low — only affects the unreleased
elasticgraph-proto_ingestionextension from #1080.References