Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove parse_vec_expr helper
Browse files Browse the repository at this point in the history
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.
findepi committed Aug 26, 2024
1 parent 945902d commit 4661698
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions datafusion/proto/src/logical_plan/from_proto.rs
Original file line number Diff line number Diff line change
@@ -586,7 +586,11 @@ 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)?,
if pb.order_by.is_empty() {
None
} else {
Some(parse_exprs(&pb.order_by, registry, codec)?)
},
None,
)))
}
@@ -676,16 +680,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,

0 comments on commit 4661698

Please sign in to comment.