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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to