Skip to content

Apache DataFusion SQL Query Engine

Remove dead code in `UnwrapCastExprRewriter` that may mask errors (#3703)

Andrew Lamb4dd4d43abc12
diff --git a/datafusion/optimizer/src/unwrap_cast_in_comparison.rs b/datafusion/optimizer/src/unwrap_cast_in_comparison.rs
index 542c29bd77..8392e28a91 100644
--- a/datafusion/optimizer/src/unwrap_cast_in_comparison.rs
+++ b/datafusion/optimizer/src/unwrap_cast_in_comparison.rs
@@ -155,15 +155,9 @@ impl ExprRewriter for UnwrapCastExprRewriter {
Expr::BinaryExpr { left, op, right } => {
let left = left.as_ref().clone();
let right = right.as_ref().clone();
- let left_type = left.get_type(&self.schema);
- let right_type = right.get_type(&self.schema);
- // can't get the data type, just return the expr
- if left_type.is_err() || right_type.is_err() {
- return Ok(expr.clone());
- }
+ let left_type = left.get_type(&self.schema)?;
+ let right_type = right.get_type(&self.schema)?;
// Because the plan has been done the type coercion, the left and right must be equal
- let left_type = left_type?;
- let right_type = right_type?;
if is_support_data_type(&left_type)
&& is_support_data_type(&right_type)
&& is_comparison_op(op)