From 8410ff0f500f29ed1b5ccf93ac2ca598774242f6 Mon Sep 17 00:00:00 2001 From: Zhi Qi Date: Fri, 10 Mar 2023 16:57:25 +0800 Subject: [PATCH 1/2] fast fix --- dbms/src/Functions/divide.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/src/Functions/divide.cpp b/dbms/src/Functions/divide.cpp index 132f6fae623..a0ba895b78b 100644 --- a/dbms/src/Functions/divide.cpp +++ b/dbms/src/Functions/divide.cpp @@ -65,7 +65,7 @@ struct TiDBDivideFloatingImpl /// ref https://github.com/pingcap/tiflash/issues/6462 /// For division of Decimal/Decimal or Int/Decimal or Decimal/Int, we should round the result to make compatible with TiDB. /// basically refer to https://stackoverflow.com/a/71634489 - if constexpr (std::is_integral_v || std::is_same_v) + if constexpr (std::is_integral_v || std::is_same_v || std::is_same_v) { /// 1. do division first, get the quotient and mod, todo:(perf) find a unified `divmod` function to speed up this. Result quotient = x / d; From 8fb514848469c955f6146c8d1c6dd035b41a7b4f Mon Sep 17 00:00:00 2001 From: Zhi Qi Date: Fri, 10 Mar 2023 17:15:44 +0800 Subject: [PATCH 2/2] unit test --- dbms/src/Functions/tests/gtest_arithmetic_functions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dbms/src/Functions/tests/gtest_arithmetic_functions.cpp b/dbms/src/Functions/tests/gtest_arithmetic_functions.cpp index 4ba24d677f3..4fdfdb3fb15 100644 --- a/dbms/src/Functions/tests/gtest_arithmetic_functions.cpp +++ b/dbms/src/Functions/tests/gtest_arithmetic_functions.cpp @@ -154,6 +154,7 @@ try doTiDBDivideDecimalRoundInternalTest(); doTiDBDivideDecimalRoundInternalTest(); doTiDBDivideDecimalRoundInternalTest(); + doTiDBDivideDecimalRoundInternalTest(); } CATCH