Skip to content

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

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

fix: delegate the remaining codec methods in ComposedPhysicalExtensionCodec#24973
sainad2222 wants to merge 1 commit 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.

buf: &mut Vec<u8>,
ctx: &PhysicalExprEncodeCtx<'_>,
) -> Result<()> {
self.encode_protobuf(buf, |codec, data| codec.try_encode_expr(node, data, ctx))

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.

This newly delegates expression encoding through encode_protobuf, but that helper reuses data without clearing it between codecs (the third defect documented in #24830). If codec 0 writes bytes and then returns Err, codec 1 appends its valid payload and returns Ok; the composed tuple attributes the concatenated, corrupted blob to codec 1. Before this PR expressions were not delegated at all, so the new capability is incorrect for a valid failure pattern. Could encode_protobuf make each attempt buffer-local (or clear data before every attempt), with a regression codec that writes then rejects followed by one that succeeds? The new by-name helper already clears per iteration, so the same invariant should apply here.

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

2 participants