Skip to content

fix: delegate the remaining codec methods in ComposedPhysicalExtensionCodec - #24973

Open
sainad2222 wants to merge 9 commits into
apache:mainfrom
sainad2222:fix/24829-composed-codec-full-delegation
Open

sainad2222 wants to merge 9 commits into
apache:mainfrom
sainad2222:fix/24829-composed-codec-full-delegation

Conversation

@sainad2222

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

See #24829.

What changes are included in this PR?

Delegates the six missing methods to the child codecs.

One wrinkle: the four by-name hooks (udf, udaf, udwf,
higher_order_function) default to Ok(()) meaning "no payload, encode by
name", and decode only consults the registry when no payload is present. Naive
delegation wraps an empty blob and strands those functions, invisible at
position 0, where the tuple prost-encodes to zero bytes. Those four now use a
new encode_protobuf_by_name_aware, which emits a payload only when a codec
actually wrote bytes. try_encode_expr keeps the plain path; its default is an
error rather than Ok(()).

What is the testing strategy for this PR?

Four tests in physical_plan::tests::function_serde; two of them fail against
naive delegation.

Are there any user-facing changes?

try_encode_udf / try_encode_udaf were already delegated but carried the same
empty-payload bug, so they move to the new helper too. Happy to split that out.
No public API signatures changed.

@sainad2222 sainad2222 changed the title fix: delegate the remaining codec methods in ComposedPhysicalExtensio… fix: delegate the remaining codec methods in ComposedPhysicalExtension Sep 6, 2026
@github-actions github-actions Bot added the proto Related to proto crate label Sep 6, 2026
@sainad2222 sainad2222 changed the title fix: delegate the remaining codec methods in ComposedPhysicalExtension fix: delegate the remaining codec methods in ComposedPhysicalExtensionCodec Sep 6, 2026

@ryux1 ryux1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The by-name helper handles empty-success delegation carefully. The newly added expression path still inherits a separate composition bug.

Comment thread datafusion/proto/src/physical_plan/mod.rs Outdated

@ryux1 ryux1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new buffer reset isolates each codec attempt, and the regression covers a codec that writes before rejecting followed by one that succeeds. This addresses my concern. Thanks!

@codecov-commenter

codecov-commenter commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.63184% with 106 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.50%. Comparing base (587e74c) to head (f9aedea).
⚠️ Report is 143 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/proto/src/physical_plan/mod.rs 73.63% 80 Missing and 26 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24973      +/-   ##
==========================================
+ Coverage   81.97%   82.50%   +0.53%     
==========================================
  Files        1137     1140       +3     
  Lines      429922   438917    +8995     
  Branches   429922   438917    +8995     
==========================================
+ Hits       352419   362132    +9713     
+ Misses      56453    54882    -1571     
- Partials    21050    21903     +853     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@timsaucer timsaucer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the core change makes a lot of sense, but I am worried about code drift. I think we can tighten it up a bit. My agent also had a few comments.

🤖 note:

Compatibility. Worth a line in the PR description: for a composed codec where the accepting codec sat at position > 0 and wrote no bytes, the emitted bytes change (tuple → nothing). Old bytes still decode fine under the new code, and those cases were undecodable before an

Comment thread datafusion/proto/src/physical_plan/mod.rs Outdated
Comment thread datafusion/proto/src/physical_plan/mod.rs Outdated
Comment thread datafusion/proto/src/physical_plan/mod.rs Outdated

@timsaucer timsaucer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should fix up the decode by name issue in the previous thread while we're working on this. It's looking good!

@sainad2222
sainad2222 force-pushed the fix/24829-composed-codec-full-delegation branch from f9aedea to 94f2ca8 Compare September 25, 2026 20:11
@sainad2222
sainad2222 force-pushed the fix/24829-composed-codec-full-delegation branch from 94f2ca8 to 2ade206 Compare September 25, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

proto Related to proto crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ComposedPhysicalExtensionCodec implements only 6 of the 12 PhysicalExtensionCodec methods

4 participants