Repository navigation
Conversation
30780dc to
56e380e
Compare
|
Assigning reviewers: R: @jrmccluskey for label go. This pull request likely touches a core component ("core" label). Please review with scrutiny. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
Reminder, please take a look at this pr: @jrmccluskey |
56e380e to
718ade5
Compare
718ade5 to
db75cf6
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #40154 +/- ##
=============================================
- Coverage 56.16% 28.73% -27.44%
=============================================
Files 1124 381 -743
Lines 178336 71101 -107235
Branches 1489 0 -1489
=============================================
- Hits 100170 20432 -79738
+ Misses 75645 48819 -26826
+ Partials 2521 1850 -671
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hey there! I'm starting a review pass, if you would go ahead and rebase this PR now that the two diffbase PRs are merged that would make this a little bit smoother as far as reviewing and merging. Thanks! |
… micros_instant types schema.RegisterLogicalTypeConversion registers a logical type identified by a URN together with the conversions between its Go type and its storage type, and derives the row coder from the storage type. schema.RegisterLogicalTypeCoder does the same for logical types whose wire encoding differs from the row encoding of the storage type. The standard beam:logical_type:date:v1 and beam:logical_type:micros_instant:v1 logical types are registered by default as schema.Date and schema.MicrosInstant. The standard coder regression test now builds the expected row from the schema in the coder payload, decodes payload bytes above 0x7f, counts encoding mismatches as failures, and runs the micros_instant case. Part of apache#39684.
db75cf6 to
2689ec7
Compare
|
Thanks a lot for reviewing this series, Jack, and for merging #40152 and #40153! I rebased this one onto master, so the diff now only shows its own changes. I also pushed a small commit that swaps Happy to adjust anything you spot. |
Part of #39684.
The Go SDK could only support a portable logical type by registering it in three places (
schema.RegisterLogicalType,coder.RegisterSchemaProviders, and thebeam.SchemaProviderglue) with hand written encoders, and none of the standard logical types from schema.proto were registered. A schema from another SDK with abeam:logical_type:date:v1orbeam:logical_type:micros_instant:v1field failed withunknown logical type.Registration API, in package
schema:RegisterLogicalTypeConversion[GoT, StorageT](urn, toStorage, fromStorage)registers the URN, the Go type and the storage type, and builds the row coder forGoTfrom the row field coder ofStorageTplus the two conversion functions.RegisterParameterizedLogicalTypeConversionis the same for a logical type with an argument; each argument value gets its own Go type.RegisterLogicalTypeCoder[GoT, StorageT](urn, enc, dec)is for logical types whose wire encoding differs from the row encoding of the storage type, such asmillis_instantanddecimal(following PRs).coder.RowFieldEncoderForTypeandcoder.RowFieldDecoderForTypeexpose the row field encoding of a single type, which the registration builds on. Encoding an untyped nil value or a typed nil pointer returns an error. Pointer storage types are rejected at registration because the row coder decides nullability from the Go type of the field, and interface Go types are rejected because the row coder matches every implementation of an interface and the schema matches only the interface itself.Standard types, registered by default:
schema.Date(beam:logical_type:date:v1), a calendar date stored as days since the epoch. Encoding requires a valid date with a year from -999999999 to 999999999.schema.MicrosInstant(beam:logical_type:micros_instant:v1), atime.Timestored as a row of seconds and microseconds. Encoding a value with sub microsecond precision returns an error, as in the Java SDK. Decoding requires the micros field to be in [0, 999999].The standard types are registered with
runtime.RegisterType, so pipeline graphs with these types in a transform signature serialize. The row decoder also uses a provider registered for a value type when it decodes a top level pointer to that type, as the row encoder already does.time.Timekeeps its current Go specific encoding; the standard types are separate Go types, so existing pipelines are unaffected. Because the Go row coder is built from the Go type alone, each registered logical type needs its own Go type, and a parameterized one needs a Go type per argument value.Regression test changes in
sdks/go/test/regression/coders/fromyaml:beam:coder:row:v1case is built from the schema in the coder payload throughschema.ToType, so logical type fields get their registered Go types. This replaces the name based type table.timestamp:v1cases) are read correctly.micros_instantcase runs. The remaining logical type cases are skipped by URN with a reason pointing at [Task]: Go SDK portable logical type support #39684.Tests: schema conversion and byte level row encoding for
DateandMicrosInstant(the bytes are themicros_instantexample of standard_coders.yaml), date conversion at the epoch boundaries, the sub microsecond error,RegisterLogicalTypeConversionend to end with a user type, andRowFieldEncoderForType/RowFieldDecoderForTypefor atomic, slice and struct types. Tests also cover interface Go type rejection, the date and micros storage ranges, a nil pointer value, a top level pointer with a value provider, and graph serialization of the standard types.Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.