feat(core): handle RelCommon data for every relation type - #1069
Open
nielspardon wants to merge 1 commit into
Open
feat(core): handle RelCommon data for every relation type#1069nielspardon wants to merge 1 commit into
nielspardon wants to merge 1 commit into
Conversation
`Hint` was wired into most but not all relations, and each of the ~31 `newXxx`
methods in `ProtoRelConverter` repeated the same four `RelCommon` setters by
hand. Two had drifted: `Cross` dropped its hint and `TopN` dropped its rel
anchor when converting from proto.
The proto -> POJO direction is now centralised in
`ProtoRelConverter.applyRelCommon`, mirroring `RelProtoConverter.common` on the
way out, so the emit mapping, common extension, hint and rel anchor are applied
in one place. This needs type-agnostic `withRemap` / `withCommonExtension` /
`withHint` copy methods on `Rel` alongside the existing `withRelAnchor`; they
are useful for plan rewriting in their own right. `applyRelCommon` copies a
field only when it differs, so it stays a no-op for a `common { direct {} }`
message - including for custom, non-Immutables relations, which inherit `Rel`'s
throwing defaults.
Two data-loss bugs surfaced along the way:
- `RelProtoConverter.common` never wrote `RelCommon.Hint.advanced_extension`,
so `Hint.getExtension()` was silently dropped on every relation even though
the inbound direction read it back.
- `UpdateRel` has no `common` field (spec v0.99.0), but the `RelCommon`
accessors live on `Rel`, so a `NamedUpdate` can hold them - and an emit
mapping changes `getRecordType()`. Serialising one produced a plan whose
schema disagreed with the POJO. `visit(NamedUpdate)` now rejects it instead
of dropping it silently. This is a behaviour change: it makes
`SubstraitBuilder.namedUpdate(..., Rel.Remap)` fail at serialisation rather
than emit a plan that cannot be re-imported.
`RelCommonRoundtripTest` covers one sample of every `RelVisitor` relation type
and fails when a new relation has no sample. It is keyed on POJO types rather
than proto `oneof` cases, so a new sub-case mapping onto an existing POJO type
still needs care - noted in AGENTS.md.
Closes substrait-io#297
nielspardon
marked this pull request as ready for review
August 6, 2026 07:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hintwas wired into most but not all relations, and each of the ~31newXxxmethods inProtoRelConverterrepeated the same fourRelCommonsetters by hand. Two had drifted:Crossdropped its hint andTopNdropped its rel anchor when converting from proto.The proto → POJO direction is now centralised in
ProtoRelConverter.applyRelCommon, mirroringRelProtoConverter.commonon the way out, so the emit mapping, common extension, hint and rel anchor are applied in one place. This needs type-agnosticwithRemap/withCommonExtension/withHintcopy methods onRelalongside the existingwithRelAnchor; they are useful for plan rewriting in their own right.applyRelCommoncopies a field only when it differs, so it stays a no-op for acommon { direct {} }message — including for custom, non-Immutables relations, which inheritRel's throwing defaults.Two data-loss bugs surfaced along the way:
RelProtoConverter.commonnever wroteRelCommon.Hint.advanced_extension, soHint.getExtension()was silently dropped on every relation even though the inbound direction read it back.UpdateRelhas nocommonfield (spec v0.99.0), but theRelCommonaccessors live onRel, so aNamedUpdatecan hold them — and an emit mapping changesgetRecordType(). Serialising one produced a plan whose schema disagreed with the POJO.visit(NamedUpdate)now rejects it instead of dropping it silently. This is a behaviour change: it makesSubstraitBuilder.namedUpdate(..., Rel.Remap)fail at serialisation rather than emit a plan that cannot be re-imported.RelCommonRoundtripTestcovers one sample of everyRelVisitorrelation type and fails when a new relation has no sample. It is keyed on POJO types rather than protooneofcases, so a new sub-case mapping onto an existing POJO type still needs care — noted in AGENTS.md.Closes #297
🤖 Generated with AI