fix: delegate the remaining codec methods in ComposedPhysicalExtensionCodec - #24973
fix: delegate the remaining codec methods in ComposedPhysicalExtensionCodec#24973sainad2222 wants to merge 1 commit into
Conversation
ryux1
left a comment
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
Which issue does this PR close?
ComposedPhysicalExtensionCodecimplements only 6 of the 12PhysicalExtensionCodecmethods #24829.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 toOk(())meaning "no payload, encode byname", 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 codecactually wrote bytes.
try_encode_exprkeeps the plain path; its default is anerror rather than
Ok(()).What is the testing strategy for this PR?
Four tests in
physical_plan::tests::function_serde; two of them fail againstnaive delegation.
Are there any user-facing changes?
try_encode_udf/try_encode_udafwere already delegated but carried the sameempty-payload bug, so they move to the new helper too. Happy to split that out.
No public API signatures changed.