Skip to content

refactor(proto): delegate deprecated ProjectionExec serde shims to new hooks#23731

Open
adriangb wants to merge 2 commits into
apache:mainfrom
pydantic:projection-exec-deprecated-delegate
Open

refactor(proto): delegate deprecated ProjectionExec serde shims to new hooks#23731
adriangb wants to merge 2 commits into
apache:mainfrom
pydantic:projection-exec-deprecated-delegate

Conversation

@adriangb

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

#23495 landed the deprecated ProjectionExec compatibility shims
(try_from_projection_exec / try_into_projection_physical_plan) with their
original bodies fully duplicated in datafusion-proto, even though the same
wire-format logic now lives in ProjectionExec::try_to_proto / try_from_proto
(the #22419 hook pattern). This PR makes those deprecated shims delegate to
the new hooks so the wire format is single-sourced in datafusion-physical-plan
rather than duplicated. This matches the FilterExec delegate style in #23708.
No wire-format change.

What changes are included in this PR?

  • Replace the body of try_from_projection_exec with a thin shim that builds an
    ExecutionPlanEncodeCtx from the codec + proto_converter (via
    ConverterPlanEncoder) and delegates to ProjectionExec::try_to_proto.
  • Replace the body of try_into_projection_physical_plan with a thin shim that
    builds an ExecutionPlanDecodeCtx (via ConverterPlanDecoder) and delegates
    to ProjectionExec::try_from_proto; the now-unused projection param is
    renamed to _projection.
  • Drop the now-unused ProjectionExpr import.

The #[deprecated(...)] attributes and signatures are otherwise unchanged, and
the live dispatch arms and the ProjectionExec hook impls are untouched.

Are these changes tested?

Yes — the existing roundtrip_physical_plan projection/filter roundtrip tests
exercise this path and pass (roundtrip_projection_source,
roundtrip_filter_with_fetch, roundtrip_filter_with_not_and_in_list, and the
full 203-test roundtrip suite). cargo clippy -p datafusion-proto --all-features -- -D warnings is clean.

Are there any user-facing changes?

No. The methods remain #[deprecated] with identical signatures and wire
format; only their internals change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01U9qX6kekbJGpmTSxvrU8e5

…w hooks

The deprecated `try_from_projection_exec` / `try_into_projection_physical_plan`
compatibility methods (kept from apache#23495) duplicated the wire-format logic that
now lives in `ProjectionExec::try_to_proto` / `try_from_proto`. Replace their
bodies with thin shims that build an `ExecutionPlanEncodeCtx` / `DecodeCtx` from
the codec + converter and delegate to the hook, so the format is single-sourced.
No wire-format or behavior change. Matches the delegate style used by FilterExec
in apache#23708.

Part of apache#23494.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U9qX6kekbJGpmTSxvrU8e5
@adriangb

Copy link
Copy Markdown
Contributor Author

@kumarUjjawal can you take a look please?

@codecov-commenter

codecov-commenter commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.75000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.72%. Comparing base (5b65e70) to head (581e7c8).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/proto/src/physical_plan/mod.rs 68.75% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23731      +/-   ##
==========================================
+ Coverage   80.70%   80.72%   +0.01%     
==========================================
  Files        1089     1089              
  Lines      368137   368253     +116     
  Branches   368137   368253     +116     
==========================================
+ Hits       297121   297255     +134     
+ Misses      53311    53281      -30     
- Partials    17705    17717      +12     

☔ 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.

@Phoenix500526 Phoenix500526 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.

LGTM

proto_converter,
};
let decode_ctx = ExecutionPlanDecodeCtx::new(&decoder);
ProjectionExec::try_from_proto(self.node(), &decode_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.

We used to decode the supplied projection and now we ignore it and decodes self.node(). Wouldn't a caller get the wrong plan or a wrong-variant error? Was this intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great catch!

`try_from_proto` reads the enclosing `PhysicalPlanNode`, so delegating
with `self.node()` changed the deprecated shim's contract: an
out-of-tree caller passing a `ProjectionExecNode` unrelated to `self`
would get a wrong-variant error instead of the decoded argument.

Re-wrap the argument in a `PhysicalPlanNode` before delegating, and add
a regression test that calls the shim with a `self` of a different plan
variant.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FiNDkYXSeuTbCxUPDnu6dB

@kumarUjjawal kumarUjjawal 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.

Thanks @adriangb Looks good

@adriangb
adriangb enabled auto-merge July 21, 2026 06:30
@adriangb

Copy link
Copy Markdown
Contributor Author

Thank you for the reviews!

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.

4 participants