Repository navigation
[Go SDK] Add the standard millis_instant and decimal logical types - #40155
Conversation
The reflection based row coder used the varint encoding for int16 and uint16 fields. Java and Python encode the INT16 schema type as 2 big endian bytes, so rows with such fields could not be exchanged with the other SDKs. Fixes apache#40151. Part of apache#39684.
5672f19 to
31d5ef9
Compare
|
Assigning reviewers: R: @shunping 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). |
Logical types registered with an argument now emit argument_type and argument in their FieldType, and schemas from other SDKs are matched on the URN and the argument value. A logical type registered without an argument still matches any argument, so pass through types keep working. Top level logical types carry the argument in a schema option. Part of apache#39684.
… 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.
schema.MillisInstant encodes as the Java InstantCoder does: 8 big endian bytes of the milliseconds shifted by the minimum int64. schema.Decimal encodes as the Java BigDecimalCoder does: the scale as a varint followed by the length prefixed two's complement bytes of the unscaled value. Both cases of standard_coders.yaml now run in the Go regression test. Part of apache#39684.
31d5ef9 to
8fdbfd5
Compare
shunping
left a comment
There was a problem hiding this comment.
Thanks for the contribution, @Eliaaazzz!
Since the prior PRs in this series are still being reviewed, I'd prefer to wait until those go through the pipeline first to avoid any cascading changes you might have to make here.
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40155 +/- ##
===========================================
+ Coverage 0 29.00% +29.00%
===========================================
Files 0 383 +383
Lines 0 71298 +71298
===========================================
+ Hits 0 20677 +20677
- Misses 0 48764 +48764
- Partials 0 1857 +1857
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:
|
|
@shunping #40152, #40153 and #40154 have merged, so this PR no longer waits on them. Could you take another look when you have time? I merged current master into the branch. The earlier Analyze (go) failure was the CodeQL runner hitting its disk quota during the Go build, and this push reruns it. Thank you for reviewing the series. |
|
Sorry, I missed the previous review notification. I will put this on my list and get back to you soon. Thanks! |
shunping
left a comment
There was a problem hiding this comment.
LGTM. Thank you for your continued effort on this.
Part of #39684 and the Go side of #19817. The predecessor PRs #40152, #40153 and #40154 have merged. This branch merges current master and retains only the millis_instant and decimal feature changes.
schema.MillisInstantuses the shifted, big endian INT64 millisecond encoding. Values with submillisecond precision or outside the INT64 millisecond range return an error.schema.Decimalstores an arbitrary precision unscaled integer and an INT32 scale. Its coder uses Java BigDecimalCoder's unsigned 32 bit scale varint and length-prefixed two's complement integer bytes.Interoperability limit: negative decimal scales match Java. Python currently emits a signed 64 bit varint for negative scales, so cross-SDK parity for that case remains limited.
Validation on
7515f5562348fcdbae7616deaa8d39491bda58f7:All four packages passed.
git diff upstream/master...HEAD --checkpassed. These tests include shared YAML wire examples, decimal sign boundaries and negative scale bytes, millisecond ordering, precision, range boundaries and truncated input. Full SDK and runner integration suites were not run.