Skip to content

[Go SDK] Encode INT16 row fields as big endian to match Java and Python - #40152

Merged
jrmccluskey merged 2 commits into
apache:masterfrom
Eliaaazzz:go-row-int16-bigendian
Oct 8, 2026
Merged

jrmccluskey merged 2 commits into
apache:masterfrom
Eliaaazzz:go-row-int16-bigendian

Conversation

@Eliaaazzz

@Eliaaazzz Eliaaazzz commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #40151. Part of #39684.

The reflection based row coder encoded int16 and uint16 struct fields with the varint encoding. Java (BigEndianShortCoder) and Python (BigEndianShortCoder) encode the INT16 schema type as 2 big endian bytes, so rows with such fields could not be exchanged with the other SDKs. The beam:logical_type:timestamp:v1 cases in standard_coders.yaml depend on this encoding for precisions below 5.

Changes:

  • Add coder.EncodeInt16, DecodeInt16, EncodeUint16 and DecodeUint16.
  • The row encoder and decoder use them for int16 and uint16 fields. uint16 is stored as an INT16 schema field.
  • Byte level test against the Java and Python encoding.
  • CHANGES.md breaking change note: this is an update incompatible change for streaming pipelines that use rows with int16 or uint16 fields.

This is the first PR of a series for #39684 (Go SDK portable logical types).


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: 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, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

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)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

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 force-pushed the go-row-int16-bigendian branch from 525272f to 15745eb Compare September 17, 2026 13:38
@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

case reflect.String:
return typeDecoderFieldReflect{decode: reflectDecodeString}, nil
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
case reflect.Int, reflect.Int8, reflect.Int32, reflect.Int64:

@Abacn Abacn Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Int8 (BYTE) likely has similar inconsistency. Consider a same fix here, or could be a follow up

edit: It's fine: BYTE is backed by uint8. See https://github.com/Eliaaazzz/beam/blob/15745eb513417942b6cfe563961edb508804bd8a/sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go#L658

Comment thread CHANGES.md Outdated
@github-actions

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

@github-actions

Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @shunping

@jrmccluskey

Copy link
Copy Markdown
Contributor

@Eliaaazzz please consider iterating on this PR soon, as you have a number of code changes in a chain that we'd like to review and get in!

@Eliaaazzz

Copy link
Copy Markdown
Contributor Author

@jrmccluskey Thanks for the reminder, and sorry for the delay. Yi's CHANGES.md comment is addressed in b9b7d27, so this one is ready for another look. #40153 and #40154 build on it and are ready for review as well.

@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.22222% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.51%. Comparing base (2bf8ba5) to head (b9b7d27).
⚠️ Report is 211 commits behind head on master.

Files with missing lines Patch % Lines
sdks/go/pkg/beam/core/graph/coder/int.go 76.47% 2 Missing and 2 partials ⚠️
sdks/go/pkg/beam/core/graph/coder/row_decoder.go 77.77% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #40152      +/-   ##
============================================
+ Coverage     55.09%   56.51%   +1.42%     
  Complexity     1722     1722              
============================================
  Files          1076     1076              
  Lines        171812   160948   -10864     
  Branches       1262     1262              
============================================
- Hits          94658    90961    -3697     
+ Misses        74880    67693    -7187     
- Partials       2274     2294      +20     
Flag Coverage Δ
go 28.39% <82.22%> (-0.75%) ⬇️

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.

@jrmccluskey jrmccluskey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thank you!

@jrmccluskey
jrmccluskey merged commit 22abffc into apache:master Oct 8, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Go SDK row coder encodes INT16 schema fields as varint instead of big endian

3 participants