Skip to content

fix: preserve literal metadata and destructure leaf and unary proto hooks - #25382

Draft
peterxcli wants to merge 3 commits into
apache:mainfrom
peterxcli:refactor/leaf-unary-expression-proto-hooks
Draft

peterxcli wants to merge 3 commits into
apache:mainfrom
peterxcli:refactor/leaf-unary-expression-proto-hooks

Conversation

@peterxcli

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #24613. Literal field metadata is lost when physical expressions are serialized.

Rationale for this change

Losing this metadata can strip Arrow extension types and custom metadata from projected columns.

What changes are included in this PR?

Use exhaustive destructuring in all seven leaf and unary expression encoders and decoders. Add a literal protobuf message that carries metadata and regenerate the Rust and JSON bindings.

What is the testing strategy for this PR?

A projection round-trip test covers null and non-null literals through protobuf and JSON and was verified to fail before the fix. Existing tests cover plain literals, and a new test rejects messages missing a value. The extended workspace tests and all-feature Clippy pass.

Are there any user-facing changes?

Literal metadata survives physical plan serialization. Literals with metadata use a new protobuf variant that requires an updated reader.

@github-actions github-actions Bot added physical-expr Changes to the physical-expr crates proto Related to proto crate labels Sep 16, 2026
@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown

Thank you for opening this pull request!

Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).

Details
     Cloning apache/main
    Building datafusion-physical-expr v55.1.0 (current)
       Built [  39.093s] (current)
     Parsing datafusion-physical-expr v55.1.0 (current)
      Parsed [   0.052s] (current)
    Building datafusion-physical-expr v55.1.0 (baseline)
       Built [  29.562s] (baseline)
     Parsing datafusion-physical-expr v55.1.0 (baseline)
      Parsed [   0.054s] (baseline)
    Checking datafusion-physical-expr v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.487s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [  70.376s] datafusion-physical-expr
    Building datafusion-proto v55.1.0 (current)
       Built [  56.903s] (current)
     Parsing datafusion-proto v55.1.0 (current)
      Parsed [   0.020s] (current)
    Building datafusion-proto v55.1.0 (baseline)
       Built [  57.588s] (baseline)
     Parsing datafusion-proto v55.1.0 (baseline)
      Parsed [   0.021s] (baseline)
    Checking datafusion-proto v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.155s] 223 checks: 223 pass, 31 skip
     Summary no semver update required
    Finished [ 117.783s] datafusion-proto
    Building datafusion-proto-models v55.1.0 (current)
       Built [  25.824s] (current)
     Parsing datafusion-proto-models v55.1.0 (current)
      Parsed [   0.145s] (current)
    Building datafusion-proto-models v55.1.0 (baseline)
       Built [  26.805s] (baseline)
     Parsing datafusion-proto-models v55.1.0 (baseline)
      Parsed [   0.146s] (baseline)
    Checking datafusion-proto-models v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   2.532s] 223 checks: 222 pass, 1 fail, 0 warn, 31 skip

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/enum_variant_added.ron

Failed in:
  variant ExprType:LiteralWithMetadata in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1661
  variant ExprType:LiteralWithMetadata in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1661

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [  56.869s] datafusion-proto-models

@github-actions github-actions Bot added the auto detected api change Auto detected API change label Sep 16, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.24138% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.96%. Comparing base (6ff484a) to head (e953405).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/proto-models/src/generated/pbjson.rs 67.60% 12 Missing and 11 partials ⚠️
datafusion/physical-expr/src/expressions/column.rs 64.28% 5 Missing ⚠️
...atafusion/physical-expr/src/expressions/literal.rs 89.47% 0 Missing and 4 partials ⚠️
datafusion/proto/src/physical_plan/from_proto.rs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25382      +/-   ##
==========================================
+ Coverage   81.93%   81.96%   +0.03%     
==========================================
  Files        1136     1136              
  Lines      428859   429270     +411     
  Branches   428859   429270     +411     
==========================================
+ Hits       351376   351870     +494     
+ Misses      56462    56286     -176     
- Partials    21021    21114      +93     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto detected api change Auto detected API change 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.

Destructure proto hooks for leaf and unary physical expressions

2 participants