Skip to content

[Go SDK] Add pass through registration for the fixed and variable length string and bytes logical types - #40156

Draft
Eliaaazzz wants to merge 5 commits into
apache:masterfrom
Eliaaazzz:go-logical-types-passthrough
Draft

Eliaaazzz wants to merge 5 commits into
apache:masterfrom
Eliaaazzz:go-logical-types-passthrough

Conversation

@Eliaaazzz

Copy link
Copy Markdown
Contributor

Part of #39684, the Go side of #23526. Depends on #40155 (the first four commits); review the last commit.

beam:logical_type:fixed_char:v1, var_char:v1, fixed_bytes:v1 and var_bytes:v1 are STRING and BYTES on the wire; their INT32 argument is the fixed or maximum length. The Go row coder is built from the Go type alone, so a plain string or []byte field is the natural Go representation, and it must keep producing an atomic STRING or BYTES schema field.

  • schema.RegisterPassThroughLogicalType(urn, goType) maps a URN to the Go type of its representation without mapping that Go type back. A schema field with the URN decodes with the plain row encoding of the Go type, and the argument is ignored (the length is not enforced). Any argument matches because the arguments PR falls back to the registration without an argument.
  • The four standard types are registered this way with string and []byte, so a JDBC or SQL row from Java with CHAR, VARCHAR, BINARY or VARBINARY columns maps to string and []byte fields (nullable columns map to pointers).
  • The char, varchar, binary and varbinary case of standard_coders.yaml now runs in the Go regression test.

Tests: ToType of the yaml schema gives *string and *[]byte fields, decoding the yaml example with nulls, and plain string and []byte fields still produce atomic schema fields.


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.

@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-passthrough branch from 1d937c9 to 311a8fe Compare October 7, 2026 22:53
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @lostluck 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.
…gth string and bytes logical types

schema.RegisterPassThroughLogicalType maps a logical type URN to the Go
type of its representation without mapping that Go type back, so a
schema field with the URN decodes with the plain row encoding and the
length argument is ignored. The standard fixed_char, var_char,
fixed_bytes and var_bytes logical types are registered this way, and
their standard_coders.yaml case now runs in the Go regression test.

Part of apache#39684.
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.

1 participant