Eliaaazzz opened a new pull request, #40153:
URL: https://github.com/apache/beam/pull/40153
Part of #39684. Depends on #40152 (the first commit); review the last commit.
`schema.LogicalType` had `argT` and `argV` fields that nothing populated,
`reflectTypeToFieldType` left `argument_type` and `argument` unset (the
`TODO(BEAM-9615)` in schema.go), and `fieldTypeToReflectType` ignored them.
This PR wires the argument through:
- `schema.ToLogicalTypeWithArgument` creates a logical type with an
argument. The argument must be a value of a built in Go type with an atomic
schema type other than `[]byte`, which covers the INT32 arguments of the
standard parameterized logical types.
- The registry keys logical types by URN and argument. A schema field with a
URN and argument resolves to the logical type registered for that pair, and
falls back to a logical type registered for the URN without an argument, so
pass through types such as `beam:logical_type:var_char:v1` can be registered
once for any length. Go ignores non atomic arguments. The BYTE schema type is
signed, so a `uint8` argument is converted through `int8`, and a floating point
NaN is rejected at registration because it never compares equal.
- `FromType` emits `argument_type` and `argument` for parameterized logical
types, and top level parameterized logical types carry the argument in a
`beam:schema:go:logical_argument:v1` schema option so `ToType` can recover the
Go type.
- `FromType` returns an error instead of panicking with a nil pointer when a
struct kind logical type with a non row storage type is used as a top level
type.
- `fieldvalue.go` converts atomic values between `reflect.Value` and
`FieldType`/`FieldValue`.
Tests: schema conversion cases for a parameterized field and a parameterized
top level type, `TestToType_LogicalTypeArguments` for matching, missing,
unknown, ignored and non atomic arguments, `TestLogicalTypeArgumentPrecedence`
for two arguments and a fallback under one URN (fields and top level),
registration validation, and round trip tests for the atomic value conversion.
------------------------
Thank you for your contribution! Follow this checklist to help us
incorporate your contribution quickly and easily:
- [x] 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.
- [x] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more
tips on [how to make review process
smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit
[https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more
information about GitHub Actions CI or the [workflows
README](https://github.com/apache/beam/blob/master/.github/workflows/README.md)
to see a list of phrases to trigger workflows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]