fix: read SetRel.common in set-relation schema inference#218
Merged
tokoko merged 1 commit intoJul 16, 2026
Merged
Conversation
infer_rel_schema's set branch read rel.fetch.common instead of rel.set.common, so a SetRel carrying a RelCommon.Emit output_mapping had its column remapping silently dropped: on a set-typed Rel, rel.fetch is a default-empty FetchRel whose common has no emit_kind, which the emit tail treats as "direct" and returns the first input's schema verbatim. Not reachable through the library's own builders (only select() emits an output_mapping, and on a ProjectRel); this affects externally-authored or deserialized plans passed to inference.
tokoko
approved these changes
Jul 16, 2026
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.
Problem
type_inference.infer_rel_schema'ssetbranch reads thecommonfrom the wrong sub-message:On a set-typed
Rel, protobuf returns a default-emptyFetchRelforrel.fetch, socommonis an emptyRelCommonwhoseemit_kindoneof is unset. The shared emit-application tail then treats it as"direct"and returns the first input's schema verbatim — aSetRelcarrying aRelCommon.Emit(output_mapping) has its column remapping silently dropped, yielding a wrongNamedStruct(wrong column order, or wrong count when the mapping selects a subset).It's a copy-paste from the adjacent
fetchbranch; every other branch readsrel.<its own type>.common.Fix
Read the
SetRel's owncommon. One line, plus a regression test (test_inference_set_emit) that builds aSetRelwith anoutput_mappingthat reorders and drops a column and asserts the remapped schema — it fails before this change and passes after.Scope / reachability
Not reachable through this library's own builders: only
select()emits anoutput_mapping, and it places it on aProjectRel; theset()builder and theunion/intersect/except_DataFrame verbs never setcommonon aSetRel. So the common build-then-infer path is unaffected. The bug manifests for externally-authored / deserialized / hand-built plans passed to the public inference functions — i.e. interop with plans from other engines.Testing
pytest— 512 passed, 30 skipped (unchanged);ruff format --checkandruff checkclean.Fixes #217.
🤖 Generated with AI