Skip to content

Port NotExpr proto hooks#22463

Open
Herrtian wants to merge 4 commits into
apache:mainfrom
Herrtian:port-notexpr-proto-hooks
Open

Port NotExpr proto hooks#22463
Herrtian wants to merge 4 commits into
apache:mainfrom
Herrtian:port-notexpr-proto-hooks

Conversation

@Herrtian
Copy link
Copy Markdown

@Herrtian Herrtian commented May 22, 2026

Which issue does this PR close?

Rationale for this change

NotExpr still used the central physical expression protobuf downcast path. Moving it to the expression-level proto hook keeps it aligned with the newer serialization pattern and reduces the special-case branching in the shared conversion code.

What changes are included in this PR?

  • Move NotExpr protobuf serialization into its try_to_proto hook.
  • Add NotExpr::try_from_proto and route decode through it.
  • Remove the old central to_proto downcast branch for NotExpr.

Are these changes tested?

Yes. I ran:

  • cargo fmt --all -- --check
  • cargo check -p datafusion-physical-expr --features proto
  • cargo check -p datafusion-proto
  • cargo test -p datafusion-proto --test proto_integration roundtrip_filter_with_not
  • git diff --check

Are there any user-facing changes?

No. This is an internal proto serialization refactor and should not change query behavior or public APIs.

@github-actions github-actions Bot added physical-expr Changes to the physical-expr crates proto Related to proto crate labels May 22, 2026
@kumarUjjawal
Copy link
Copy Markdown
Contributor

@Herrtian Thank you for picking this up. Can you please update the PR body with more details. Use the pr template for this.

@Herrtian
Copy link
Copy Markdown
Author

Updated the PR body to use the template.

@kumarUjjawal
Copy link
Copy Markdown
Contributor

@Herrtian we should add a direct test for the new hook code itself, especially the bad-input case like a missing child expression.

@Herrtian
Copy link
Copy Markdown
Author

Added a direct missing-child test for the NotExpr proto hook.

Checked with:

  • cargo test -p datafusion-physical-expr --features proto test_from_proto_missing_child
  • cargo fmt --check
  • git diff --check


let protobuf::PhysicalNot { expr } = match &node.expr_type {
Some(protobuf::physical_expr_node::ExprType::NotExpr(e)) => e.as_ref(),
_ => return internal_err!("PhysicalExprNode is not a NotExpr"),
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.

should surface both expr_id and the actual expr_type variant the decoder received.

_ => return internal_err!("PhysicalExprNode is not a NotExpr"),
};
let expr = expr.as_deref().ok_or_else(|| {
datafusion_common::DataFusionError::Internal(
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 should use internal_datafusion_err!

@Herrtian
Copy link
Copy Markdown
Author

Addressed the review comments: the missing-child path now uses internal_datafusion_err! and includes the expr_id plus NotExpr type in the error.

Checked with:

  • cargo test -p datafusion-physical-expr --features proto test_from_proto_missing_child
  • cargo fmt --check
  • git diff --check

Herrtian added 4 commits May 25, 2026 16:22
Signed-off-by: Herrtian <70463940+Herrtian@users.noreply.github.com>
Signed-off-by: Herrtian <70463940+Herrtian@users.noreply.github.com>
@Herrtian Herrtian force-pushed the port-notexpr-proto-hooks branch from d7ad593 to 33a90db Compare May 25, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-expr Changes to the physical-expr crates proto Related to proto crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port NotExpr to use try_to_proto / try_from_proto

2 participants