Skip to content

Commit 1ce18fd

Browse files
committed
revert type coercion
1 parent 78d36f3 commit 1ce18fd

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

datafusion/optimizer/src/analyzer/type_coercion.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ use datafusion_expr::type_coercion::other::{
4040
};
4141
use datafusion_expr::type_coercion::{is_datetime, is_numeric, is_utf8_or_large_utf8};
4242
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};
4844
use datafusion_expr::{ExprSchemable, Signature};
4945

5046
use crate::analyzer::AnalyzerRule;
@@ -109,7 +105,14 @@ fn analyze_internal(
109105
})
110106
.collect::<Result<Vec<_>>>()?;
111107

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+
}
113116
}
114117

115118
pub(crate) struct TypeCoercionRewriter {

0 commit comments

Comments
 (0)