Skip to content

GH-3039: Keep protobuf oneof fields optional when unwrapping wrappers - #3799

Open
sankalpsthakur wants to merge 1 commit into
apache:masterfrom
sankalpsthakur:cursor/gh-3039-proto-oneof-unwrap-1e52
Open

sankalpsthakur wants to merge 1 commit into
apache:masterfrom
sankalpsthakur:cursor/gh-3039-proto-oneof-unwrap-1e52

Conversation

@sankalpsthakur

Copy link
Copy Markdown

Rationale for this change

When parquet.proto.unwrapProtoWrappers is enabled, ProtoSchemaConverter marks every primitive field REQUIRED. That is invalid for protobuf oneof members: at most one alternative can be written, so the other members are absent. Write validation then fails, and even without validation the schema claims fields a legal oneof record cannot populate.

Fixes #3039.

What changes are included in this PR?

  • Keep oneof members optional when converting protobuf schemas in unwrap mode.
  • Non-oneof primitives still become REQUIRED in unwrap mode, matching existing documented behavior.
  • Add schema conversion tests and a validated writer round-trip for OneOfTestMessage.

Are these changes tested?

Yes. parquet-protobuf module tests, including:

  • ProtoSchemaConverterTest.testProto3ConvertOneOf
  • ProtoSchemaConverterTest.testProto3ConvertOneOfUnwrapped
  • ProtoWriteSupportTest.testMessageOneOfUnwrappedRoundTrip (unwrap + withValidation(true))

Are there any user-facing changes?

Yes. Unwrap-mode schemas for protobuf oneof primitives change from required to optional. Newly written files are valid; previously written unwrap+oneof files with required members remain readable.

Contributor: Sankalp Thakur (sankalpsthakur). Apache ICLA note: this contribution is offered under the Apache License 2.0; please confirm ICLA status against ASF records if required for merge.

Closes #3039

…appers

Unwrap mode was forcing every primitive to REQUIRED, which is invalid for
oneof members because only one alternative can be written. Keep oneof
fields optional and add schema plus validated round-trip coverage.

Co-authored-by: Sankalp Thakur <sankalpsthakur@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProtoSchemaConverter renders invalid schema for oneof in unwrap mode

2 participants