Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: guo-shaoge <[email protected]>
  • Loading branch information
guo-shaoge committed Feb 10, 2025
1 parent 1a9c7d8 commit fc61386
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dbms/src/Functions/FunctionsRound.h
Original file line number Diff line number Diff line change
Expand Up @@ -1265,10 +1265,10 @@ struct TiDBRoundPrecisionInferer
PrecType new_prec = std::min(decimal_max_prec, int_prec + int_prec_increment + new_scale);
if (new_prec == 0)
{
// new_prec can be zero when the prec is eq to scale for truncate:
// new_prec can be zero when the prec is eq to scale and frac is le to zero for truncate:
// select truncate(0.22, 0) from t_col_decimal_2_2;
// Not possible for round, because int_prec_increment is 1 for round.
RUNTIME_CHECK(is_tidb_truncate && prec == scale);
RUNTIME_CHECK(is_tidb_truncate && is_const_frac && frac <= 0 && prec == scale);
new_prec = 1;
}
return std::make_tuple(new_prec, new_scale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ try
ASSERT_COLUMN_EQ(
createColumn<Nullable<Decimal32>>(std::make_tuple(1, 0), {"0"}),
this->execute(column({3, 3}, {"0.025"}), createConstColumn<Int64>(1, 0)));
ASSERT_COLUMN_EQ(
createColumn<Nullable<Decimal32>>(std::make_tuple(1, 0), {"0"}),
this->execute(column({3, 3}, {"0.025"}), createConstColumn<Int64>(1, -1)));
}
CATCH
} // namespace tests
Expand Down

0 comments on commit fc61386

Please sign in to comment.