yangzhg commented on a change in pull request #8069:
URL: https://github.com/apache/incubator-doris/pull/8069#discussion_r810444156



##########
File path: be/src/vec/data_types/data_type_decimal.h
##########
@@ -330,19 +330,9 @@ convert_to_decimal(const typename FromDataType::FieldType& 
value, UInt32 scale)
         }
 
         auto out = value * ToDataType::get_scale_multiplier(scale);
-        if constexpr (std::is_same_v<ToNativeType, Int128>) {
-            static constexpr __int128 min_int128 = 
__int128(0x8000000000000000ll) << 64;
-            static constexpr __int128 max_int128 =
-                    (__int128(0x7fffffffffffffffll) << 64) + 
0xffffffffffffffffll;
-            if (out <= static_cast<ToNativeType>(min_int128) ||
-                out >= static_cast<ToNativeType>(max_int128)) {
-                LOG(FATAL) << "Decimal convert overflow. Float is out of 
Decimal range";
-            }
-        } else {
-            if (out <= std::numeric_limits<ToNativeType>::min() ||
-                out >= std::numeric_limits<ToNativeType>::max()) {
-                LOG(FATAL) << "Decimal convert overflow. Float is out of 
Decimal range";
-            }
+        if (out <= 
static_cast<FromFieldType>(std::numeric_limits<ToNativeType>::min()) ||
+            out >= 
static_cast<FromFieldType>(std::numeric_limits<ToNativeType>::max())) {
+            LOG(FATAL) << "Decimal convert overflow. Float is out of Decimal 
range";

Review comment:
       numeric_limits can handle int128 min and max




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to