@@ -40,11 +40,7 @@ use datafusion_expr::type_coercion::other::{
40
40
} ;
41
41
use datafusion_expr:: type_coercion:: { is_datetime, is_numeric, is_utf8_or_large_utf8} ;
42
42
use datafusion_expr:: utils:: from_plan;
43
- use datafusion_expr:: {
44
- is_false, is_not_false, is_not_true, is_not_unknown, is_true, is_unknown,
45
- type_coercion, AggregateFunction , BuiltinScalarFunction , Expr , LogicalPlan , Operator ,
46
- WindowFrame , WindowFrameBound , WindowFrameUnits ,
47
- } ;
43
+ use datafusion_expr:: { is_false, is_not_false, is_not_true, is_not_unknown, is_true, is_unknown, type_coercion, AggregateFunction , BuiltinScalarFunction , Expr , LogicalPlan , Operator , WindowFrame , WindowFrameBound , WindowFrameUnits , Projection } ;
48
44
use datafusion_expr:: { ExprSchemable , Signature } ;
49
45
50
46
use crate :: analyzer:: AnalyzerRule ;
@@ -109,7 +105,14 @@ fn analyze_internal(
109
105
} )
110
106
. collect :: < Result < Vec < _ > > > ( ) ?;
111
107
112
- from_plan ( plan, & new_expr, & new_inputs)
108
+ // TODO: from_plan can't change the schema, so we need to do this here
109
+ match & plan {
110
+ LogicalPlan :: Projection ( _) => Ok ( LogicalPlan :: Projection ( Projection :: try_new (
111
+ new_expr,
112
+ Arc :: new ( new_inputs[ 0 ] . clone ( ) ) ,
113
+ ) ?) ) ,
114
+ _ => from_plan ( plan, & new_expr, & new_inputs) ,
115
+ }
113
116
}
114
117
115
118
pub ( crate ) struct TypeCoercionRewriter {
0 commit comments