diff --git a/cpp-ch/local-engine/Functions/SparkFunctionCheckDecimalOverflow.cpp b/cpp-ch/local-engine/Functions/SparkFunctionCheckDecimalOverflow.cpp index 6519db3f9820..73fc7b5d4e40 100644 --- a/cpp-ch/local-engine/Functions/SparkFunctionCheckDecimalOverflow.cpp +++ b/cpp-ch/local-engine/Functions/SparkFunctionCheckDecimalOverflow.cpp @@ -178,8 +178,18 @@ class FunctionCheckDecimalOverflow : public IFunction { ToFieldType result; bool success = convertToDecimalImpl(datas[i], precision, scale_from, scale_to, decimal_int_part_max, decimal_int_part_min, result); - vec_to[i] = static_cast(result); - (*vec_null_map_to)[i] = !success; + if constexpr (exception_mode == CheckExceptionMode::Null) + { + vec_to[i] = static_cast(result); + (*vec_null_map_to)[i] = !success; + } + else + { + if (success) + vec_to[i] = static_cast(result); + else + throw Exception(ErrorCodes::DECIMAL_OVERFLOW, "Decimal value is overflow."); + } } if constexpr (exception_mode == CheckExceptionMode::Null)