Skip to content

Commit

Permalink
return err
Browse files Browse the repository at this point in the history
  • Loading branch information
jayzhan211 committed Mar 5, 2025
1 parent 5322d53 commit 8a9e5b0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,10 +1822,18 @@ fn unwrap_cast_in_comparison_for_binary<S: SimplifyInfo>(
Expr::TryCast(TryCast { expr, .. }) | Expr::Cast(Cast { expr, .. }),
Expr::Literal(lit_value),
) => {
let expr_type = info.get_data_type(&expr).unwrap();
let Ok(expr_type) = info.get_data_type(&expr) else {
return internal_err!("Can't get the data type of the expr {:?}", &expr);
};
// if the lit_value can be casted to the type of internal_left_expr
// we need to unwrap the cast for cast/try_cast expr, and add cast to the literal
let value = try_cast_literal_to_type(&lit_value, &expr_type).unwrap();
let Some(value) = try_cast_literal_to_type(&lit_value, &expr_type) else {
return internal_err!(
"Can't cast the literal expr {:?} to type {:?}",
&lit_value,
&expr_type
);
};
Ok(Transformed::yes(Expr::BinaryExpr(BinaryExpr {
left: expr,
op,
Expand Down

0 comments on commit 8a9e5b0

Please sign in to comment.