findepi commented on code in PR #12177:
URL: https://github.com/apache/datafusion/pull/12177#discussion_r1734120200
##########
datafusion/expr/src/tree_node.rs:
##########
@@ -386,3 +379,48 @@ fn transform_vec<F: FnMut(Expr) ->
Result<Transformed<Expr>>>(
) -> Result<Transformed<Vec<Expr>>> {
ve.into_iter().map_until_stop_and_collect(f)
}
+
+pub fn transform_sort_option_vec<F: FnMut(Expr) -> Result<Transformed<Expr>>>(
+ sorts_option: Option<Vec<Sort>>,
+ f: &mut F,
+) -> Result<Transformed<Option<Vec<Sort>>>> {
+ sorts_option.map_or(Ok(Transformed::no(None)), |sorts| {
+ Ok(transform_sort_vec(sorts, f)?.update_data(Some))
+ })
+}
+
+pub fn transform_sort_vec<F: FnMut(Expr) -> Result<Transformed<Expr>>>(
+ sorts: Vec<Sort>,
+ mut f: &mut F,
+) -> Result<Transformed<Vec<Sort>>> {
+ Ok(sorts
+ .iter()
+ .map(|sort| sort.expr.clone())
+ .map_until_stop_and_collect(&mut f)?
+ .update_data(|transformed_exprs| {
+ replace_sort_expressions(sorts, transformed_exprs)
+ }))
+}
+
+pub fn replace_sort_expressions(sorts: Vec<Sort>, new_expr: Vec<Expr>) ->
Vec<Sort> {
Review Comment:
Good question. This is used in two places. In one we know the list of
expressions is exact size.
the other is `LogicalPlan.with_new_exprs` which does `assert!` on provided
new expr length. so it looks we don't need to be permissive here?
--
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]