Skip to content

[Go SDK] Add the standard millis_instant and decimal logical types - #40155

Merged
shunping merged 9 commits into
apache:masterfrom
Eliaaazzz:go-logical-types-instants-decimal
Nov 3, 2026
Merged

shunping merged 9 commits into
apache:masterfrom
Eliaaazzz:go-logical-types-instants-decimal

Conversation

@Eliaaazzz

@Eliaaazzz Eliaaazzz commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

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.MillisInstant uses the shifted, big endian INT64 millisecond encoding. Values with submillisecond precision or outside the INT64 millisecond range return an error.
  • schema.Decimal stores 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.
  • Decimal formatting uses scientific notation when scale padding would exceed 1 MiB. The plain-notation parser does not accept exponent notation.
  • Both types are registered for row encoding and pipeline graph type serialization. Their standard_coders.yaml cases now run in Go.

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:

cd sdks
GOMAXPROCS=2 go test -count=1 -p 2 -parallel 2 ./go/pkg/beam/core/runtime/graphx/schema ./go/pkg/beam/core/runtime/graphx ./go/pkg/beam/core/graph/coder ./go/test/regression/coders/...

All four packages passed. git diff upstream/master...HEAD --check passed. 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.

@Eliaaazzz

Copy link
Copy Markdown
Contributor Author

Closing this for now to keep the series at three open PRs while #40152, #40153 and #40154 are reviewed. The branch stays in my fork.

@Eliaaazzz Eliaaazzz closed this Sep 17, 2026
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.
@Eliaaazzz Eliaaazzz reopened this Oct 7, 2026
@Eliaaazzz
Eliaaazzz force-pushed the go-logical-types-instants-decimal branch from 5672f19 to 31d5ef9 Compare October 7, 2026 22:53
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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 assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

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.

@shunping shunping left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Eliaaazzz
Eliaaazzz marked this pull request as draft October 8, 2026 01:18
@Eliaaazzz

Copy link
Copy Markdown
Contributor Author

Thanks, that makes sense. I moved this PR and #40156 to draft until #40152 to #40154 are merged, and I will rebase them then.

@Eliaaazzz
Eliaaazzz marked this pull request as ready for review October 23, 2026 04:41
@Eliaaazzz

Eliaaazzz commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

#40152, #40153 and #40154 have merged. This branch now merges master and contains only the seven millis_instant and decimal feature files. Focused Go tests and the diff check pass on 7515f55; commands and interoperability limits are in the updated description.
R: @shunping

@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.00%. Comparing base (2213e54) to head (b376949).
⚠️ Report is 45 commits behind head on master.

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     
Flag Coverage Δ
go 29.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added the size/l L: 250-999 lines changed label Oct 28, 2026
@Eliaaazzz

Copy link
Copy Markdown
Contributor Author

@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.

@shunping

Copy link
Copy Markdown
Collaborator

Sorry, I missed the previous review notification. I will put this on my list and get back to you soon. Thanks!

@shunping shunping left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for your continued effort on this.

@shunping
shunping merged commit 4b5b9c8 into apache:master Nov 3, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants