Fixed comparison of double types with different scales

This commit is contained in:
hezuojiao
2024-07-02 13:05:58 +00:00
committed by ob-robot
parent 657a8a0b0f
commit 1e6b6ac34c
3 changed files with 7 additions and 1 deletions

View File

@ -6472,6 +6472,8 @@ int ObRelationalExprOperator::cg_datum_cmp_expr(const ObRawExpr &raw_expr,
const ObCollationType cs_type = rt_expr.args_[0]->datum_meta_.cs_type_;
if (ObDatumFuncs::is_string_type(input_type1) && ObDatumFuncs::is_string_type(input_type2)) {
CK(rt_expr.args_[0]->datum_meta_.cs_type_ == rt_expr.args_[1]->datum_meta_.cs_type_);
} else if (ob_is_double_tc(input_type1) && ob_is_double_tc(input_type2)) {
CK(rt_expr.args_[0]->datum_meta_.scale_ == rt_expr.args_[1]->datum_meta_.scale_);
}
if (OB_SUCC(ret)) {
rt_expr.eval_func_ = ObExprCmpFuncsHelper::get_eval_expr_cmp_func(

View File

@ -38,7 +38,7 @@ int ObExprPi::calc_result_type0(ObExprResType &type, ObExprTypeCtx &type_ctx) co
{
UNUSED(type_ctx);
type.set_double();
type.set_precision(-1);
type.set_precision(8);
type.set_scale(6);
return OB_SUCCESS;
}

View File

@ -3798,6 +3798,10 @@ int ObRawExprDeduceType::try_add_cast_expr_above_for_deduce_type(ObRawExpr &expr
p += decimal_to_double_precision_inc(child_res_type.get_type(), s);
cast_dst_type.set_scale(s);
cast_dst_type.set_precision(p);
} else if (ObDoubleTC == child_res_type.get_type_class()) {
// child_res_type and cast_dst_type are the same, which is double type cast of the expr
// aligned to scale, accuracy need based on the cast_dst_type set by the expr
// calc_resul_type.
} else if (s != SCALE_UNKNOWN_YET && PRECISION_UNKNOWN_YET != p &&
s <= OB_MAX_DOUBLE_FLOAT_SCALE && p >= s) {
cast_dst_type.set_accuracy(child_res_type.get_calc_accuracy());