Skip to content

Commit

Permalink
fix(common): decimal round digits test (#8568)
Browse files Browse the repository at this point in the history
Co-authored-by: Noel Kwan <[email protected]>
  • Loading branch information
odysa and kwannoel authored Mar 16, 2023
1 parent 88550e4 commit 30a8946
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/expr/src/vector_op/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ mod tests {
do_test("84818.33333333333333333333333", 4, "84818.3333");
do_test("84818.15", 1, "84818.2");
do_test("21.372736", -1, "0");
// Maximum of 28 digits
do_test("0", 340, &format!("0.{}", "0".repeat(28)));
// When digit extends past original scale, it should just return original scale.
// Intuitively, it does not make sense after rounding `0` it becomes `0.000`. Precision
// should always be less or equal, not more.
do_test("0", 340, "0");
}

#[test]
Expand Down

0 comments on commit 30a8946

Please sign in to comment.