Skip to content

Commit f2a254f

Browse files
committed
fixup! fixup! fixup! WIP
1 parent e67b44b commit f2a254f

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

datafusion/expr/src/logical_plan/plan.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ use datafusion_common::{
5454
// backwards compatibility
5555
use crate::display::PgJsonVisitor;
5656
use crate::logical_plan::tree_node::unwrap_arc;
57+
use crate::tree_node::replace_sort_expressions;
5758
pub use datafusion_common::display::{PlanType, StringifiedPlan, ToStringifiedPlan};
5859
pub use datafusion_common::{JoinConstraint, JoinType};
5960

@@ -887,15 +888,15 @@ impl LogicalPlan {
887888
Aggregate::try_new(Arc::new(inputs.swap_remove(0)), expr, agg_expr)
888889
.map(LogicalPlan::Aggregate)
889890
}
890-
LogicalPlan::Sort(Sort { /*fetch,*/ .. }) => {
891-
// TODO FIXME
892-
// LogicalPlan::Sort(Sort { fetch, .. }) => Ok(LogicalPlan::Sort(Sort {
893-
// expr,
894-
// input: Arc::new(inputs.swap_remove(0)),
895-
// fetch: *fetch,
896-
// })),
897-
internal_err!("with_ew_exprs not implemented for Sort")
898-
},
891+
LogicalPlan::Sort(Sort {
892+
expr: sort_expr,
893+
fetch,
894+
..
895+
}) => Ok(LogicalPlan::Sort(Sort {
896+
expr: replace_sort_expressions(sort_expr.clone(), expr),
897+
input: Arc::new(inputs.swap_remove(0)),
898+
fetch: *fetch,
899+
})),
899900
LogicalPlan::Join(Join {
900901
join_type,
901902
join_constraint,

datafusion/expr/src/logical_plan/tree_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ impl LogicalPlan {
491491
.visit_sibling(|| filter.iter().apply_until_stop(f))
492492
}
493493
LogicalPlan::Sort(Sort { expr, .. }) => {
494-
expr.iter().apply_until_stop(|sort| f(&*sort.expr))
494+
expr.iter().apply_until_stop(|sort| f(&sort.expr))
495495
}
496496
LogicalPlan::Extension(extension) => {
497497
// would be nice to avoid this copy -- maybe can

datafusion/expr/src/tree_node.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl TreeNode for Expr {
9797
expr_vec.push(f.as_ref());
9898
}
9999
if let Some(order_by) = order_by {
100-
expr_vec.extend(order_by.into_iter().map(|sort| sort.expr.as_ref()));
100+
expr_vec.extend(order_by.iter().map(|sort| sort.expr.as_ref()));
101101
}
102102
expr_vec
103103
}
@@ -109,7 +109,7 @@ impl TreeNode for Expr {
109109
}) => {
110110
let mut expr_vec = args.iter().collect::<Vec<_>>();
111111
expr_vec.extend(partition_by);
112-
expr_vec.extend(order_by.into_iter().map(|sort| sort.expr.as_ref()));
112+
expr_vec.extend(order_by.iter().map(|sort| sort.expr.as_ref()));
113113
expr_vec
114114
}
115115
Expr::InList(InList { expr, list, .. }) => {

datafusion/optimizer/src/common_subexpr_eliminate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,6 @@ enum ExprMask {
886886
/// - [`Columns`](Expr::Column)
887887
/// - [`ScalarVariable`](Expr::ScalarVariable)
888888
/// - [`Alias`](Expr::Alias)
889-
/// - [`Sort`](Expr::Sort)
890889
/// - [`Wildcard`](Expr::Wildcard)
891890
/// - [`AggregateFunction`](Expr::AggregateFunction)
892891
Normal,

datafusion/sql/src/unparser/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl Unparser<'_> {
253253
};
254254
let order_by: Vec<ast::OrderByExpr> = order_by
255255
.iter()
256-
.map(|expr| sort_to_sql(expr))
256+
.map(sort_to_sql)
257257
.collect::<Result<Vec<_>>>()?;
258258

259259
let start_bound = self.convert_bound(&window_frame.start_bound)?;

datafusion/sql/src/unparser/rewrite.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub(super) fn normalize_union_schema(plan: &LogicalPlan) -> Result<LogicalPlan>
8686
}
8787

8888
/// Rewrite sort expressions that have a UNION plan as their input to remove the table reference.
89-
fn rewrite_sort_expr_for_union(exprs: Vec<SortExpr>) -> Result<Vec<SortExpr>> {
89+
fn rewrite_sort_expr_for_union(_exprs: Vec<SortExpr>) -> Result<Vec<SortExpr>> {
9090
// TODO FIXME
9191
// this impl does't compile
9292
/*

0 commit comments

Comments
 (0)