@@ -24,6 +24,7 @@ use datafusion_common::{
24
24
tree_node:: { Transformed , TransformedResult , TreeNode } ,
25
25
Result ,
26
26
} ;
27
+ use datafusion_expr:: tree_node:: transform_sort_vec;
27
28
use datafusion_expr:: { Expr , LogicalPlan , Projection , Sort , SortExpr } ;
28
29
use sqlparser:: ast:: Ident ;
29
30
@@ -86,11 +87,8 @@ pub(super) fn normalize_union_schema(plan: &LogicalPlan) -> Result<LogicalPlan>
86
87
}
87
88
88
89
/// 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 > > {
90
- // TODO FIXME
91
- // this impl does't compile
92
- /*
93
- let sort_exprs = transform_sort_vec(exprs, |expr| {
90
+ fn rewrite_sort_expr_for_union ( exprs : Vec < SortExpr > ) -> Result < Vec < SortExpr > > {
91
+ let sort_exprs = transform_sort_vec ( exprs, & mut |expr| {
94
92
expr. transform_up ( |expr| {
95
93
if let Expr :: Column ( mut col) = expr {
96
94
col. relation = None ;
@@ -103,31 +101,6 @@ fn rewrite_sort_expr_for_union(_exprs: Vec<SortExpr>) -> Result<Vec<SortExpr>> {
103
101
. data ( ) ?;
104
102
105
103
Ok ( sort_exprs)
106
- */
107
-
108
- /*
109
- original code:
110
-
111
- fn rewrite_sort_expr_for_union(exprs: Vec<Expr>) -> Result<Vec<Expr>> {
112
- let sort_exprs: Vec<Expr> = exprs
113
- .into_iter()
114
- .map_until_stop_and_collect(|expr| {
115
- expr.transform_up(|expr| {
116
- if let Expr::Column(mut col) = expr {
117
- col.relation = None;
118
- Ok(Transformed::yes(Expr::Column(col)))
119
- } else {
120
- Ok(Transformed::no(expr))
121
- }
122
- })
123
- })
124
- .data()?;
125
-
126
- Ok(sort_exprs)
127
- }
128
- */
129
-
130
- panic ! ( "rewrite_sort_expr_for_union to be implemented" ) ;
131
104
}
132
105
133
106
// Rewrite logic plan for query that order by columns are not in projections
0 commit comments