Skip to content

fix(proto): correctly serialize FilterExec empty projection#21873

Closed
Adez017 wants to merge 11 commits intoapache:mainfrom
Adez017:patch-1
Closed

fix(proto): correctly serialize FilterExec empty projection#21873
Adez017 wants to merge 11 commits intoapache:mainfrom
Adez017:patch-1

Conversation

@Adez017
Copy link
Copy Markdown
Contributor

@Adez017 Adez017 commented Apr 27, 2026

Which issue does this PR close?

Rationale for this change

FilterExec supports two semantically different projection states:

  • None → return all columns (full projection)
  • Some(vec![]) → return no columns (empty projection)

However, both cases were being serialized identically as an empty vector in the proto representation. During deserialization, an empty vector was always mapped back to None, meaning an empty projection would silently become a full projection after a serde round-trip.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

No

@github-actions github-actions Bot added the proto Related to proto crate label Apr 27, 2026
)
// After deserializing, check if it equals the full range
let num_fields = schema.fields().len();
let full_projection: Vec<usize> = (0..num_fields).collect();
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.

Currently the code requires a vector allocation to check if the other vector is 0,1,2,3.., but we can do it without allocations using a loop (sample code):

let mut projection = Vec::with_capacity();
let mut is_full_projection =
    filter.projection.len() == input.schema().fields.len();
for (i, idx) in filter.projection.iter().enumerate() {
    let idx = idx as usize;
    is_full_projection &= idx == i;
    projection.push(idx);
}
let projection = if is_full_projection {
    None
} else {
    Some(projection)
};

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.

Thanks for the feedback @askalt !

@Adez017
Copy link
Copy Markdown
Contributor Author

Adez017 commented Apr 28, 2026

Hi @askalt , i'll be opening a fresh new PR as i am gettign some build error with this branch

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.

FilterExec empty projection is changed to full projection after serde

2 participants