You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Adez017 (via GitHub)" <gi...@apache.org> on 2026/04/27 12:00:16 UTC

[PR] fix(proto): correctly serialize `FilterExec` empty projection [datafusion]

Adez017 opened a new pull request, #21873:
URL: https://github.com/apache/datafusion/pull/21873

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   - Closes #21871 
   
   ## 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?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   No
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix(proto): correctly serialize `FilterExec` empty projection [datafusion]

Posted by "Adez017 (via GitHub)" <gi...@apache.org>.
Adez017 commented on PR #21873:
URL: https://github.com/apache/datafusion/pull/21873#issuecomment-4332526705

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix(proto): correctly serialize `FilterExec` empty projection [datafusion]

Posted by "Adez017 (via GitHub)" <gi...@apache.org>.
Adez017 commented on code in PR #21873:
URL: https://github.com/apache/datafusion/pull/21873#discussion_r3147261203


##########
datafusion/proto/src/physical_plan/mod.rs:
##########
@@ -681,16 +681,17 @@ impl protobuf::PhysicalPlanNode {
             })?;
 
         let filter_selectivity = filter.default_filter_selectivity.try_into();
-        let projection = if !filter.projection.is_empty() {
-            Some(
-                filter
-                    .projection
-                    .iter()
-                    .map(|i| *i as usize)
-                    .collect::<Vec<_>>(),
-            )
+        // After deserializing, check if it equals the full range
+        let num_fields = schema.fields().len();
+        let full_projection: Vec<usize> = (0..num_fields).collect();

Review Comment:
   Thanks for the feedback @askalt ! 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix(proto): correctly serialize `FilterExec` empty projection [datafusion]

Posted by "Adez017 (via GitHub)" <gi...@apache.org>.
Adez017 closed pull request #21873: fix(proto): correctly serialize `FilterExec` empty projection
URL: https://github.com/apache/datafusion/pull/21873


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix(proto): correctly serialize `FilterExec` empty projection [datafusion]

Posted by "askalt (via GitHub)" <gi...@apache.org>.
askalt commented on code in PR #21873:
URL: https://github.com/apache/datafusion/pull/21873#discussion_r3147177212


##########
datafusion/proto/src/physical_plan/mod.rs:
##########
@@ -681,16 +681,17 @@ impl protobuf::PhysicalPlanNode {
             })?;
 
         let filter_selectivity = filter.default_filter_selectivity.try_into();
-        let projection = if !filter.projection.is_empty() {
-            Some(
-                filter
-                    .projection
-                    .iter()
-                    .map(|i| *i as usize)
-                    .collect::<Vec<_>>(),
-            )
+        // After deserializing, check if it equals the full range
+        let num_fields = schema.fields().len();
+        let full_projection: Vec<usize> = (0..num_fields).collect();

Review Comment:
   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):
   
   ```rust
   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)
   };
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org