This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new a616e8895b Remove `parse_vec_expr` helper (#12178)
a616e8895b is described below

commit a616e8895bdde48153d70ba32281d5174d172cea
Author: Piotr Findeisen <[email protected]>
AuthorDate: Tue Aug 27 15:24:11 2024 +0200

    Remove `parse_vec_expr` helper (#12178)
    
    * Remove `parse_vec_expr` helper
    
    Behavior of `parse_vec_expr` and `parse_exprs` is almost similar -- both
    take a collection of expressions to parse. The only difference is that
    `parse_vec_expr` returns `Option::None` when collections is empty, but
    this difference in behavior does not correspond to difference in
    function names. Since the function is used once only, remove it instead
    of coming up with a fancy name.
    
    * empty
---
 datafusion/proto/src/logical_plan/from_proto.rs | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/datafusion/proto/src/logical_plan/from_proto.rs 
b/datafusion/proto/src/logical_plan/from_proto.rs
index b74237b528..acda1298dd 100644
--- a/datafusion/proto/src/logical_plan/from_proto.rs
+++ b/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)?),
+                },
                 None,
             )))
         }
@@ -676,16 +679,6 @@ pub fn from_proto_binary_op(op: &str) -> Result<Operator, 
Error> {
     }
 }
 
-fn parse_vec_expr(
-    p: &[protobuf::LogicalExprNode],
-    registry: &dyn FunctionRegistry,
-    codec: &dyn LogicalExtensionCodec,
-) -> Result<Option<Vec<Expr>>, Error> {
-    let res = parse_exprs(p, registry, codec)?;
-    // Convert empty vector to None.
-    Ok((!res.is_empty()).then_some(res))
-}
-
 fn parse_optional_expr(
     p: Option<&protobuf::LogicalExprNode>,
     registry: &dyn FunctionRegistry,


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

Reply via email to