crepererum commented on code in PR #12178:
URL: https://github.com/apache/datafusion/pull/12178#discussion_r1732575694


##########
datafusion/proto/src/logical_plan/from_proto.rs:
##########
@@ -586,7 +586,10 @@ pub fn parse_expr(
                 parse_exprs(&pb.args, registry, codec)?,
                 pb.distinct,
                 parse_optional_expr(pb.filter.as_deref(), registry, 
codec)?.map(Box::new),
-                parse_vec_expr(&pb.order_by, registry, codec)?,
+                match pb.order_by.len() {
+                    0 => None,
+                    _ => Some(parse_exprs(&pb.order_by, registry, codec)?),
+                },

Review Comment:
   I wonder if in both places, we could use another new helper like
   
   ```rust
   fn optimize_empty_vec<T>(v: Vec<T>) -> Option<Vec<T>> {
       (!v.empty()).then_some(v)
   }
   ```
   
   so the combination would look like this:
   
   ```rust
   optimize_empty_vec(parse_exprs(&pb.order_by, registry, codec)?)
   ```
   
   However, that's a personal preference, mostly based on the fact that naming 
the input (`pb.order_by`) twice, which can easily introduce copy&paste errors.



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