【已解决】doris2.0.4对小数类型DECIMAL(38, 8)字段值进行计算报错"Arithmetic overflow"

Viewed 100

本地doris版本 Doris version doris-2.0.4-rc06-7834fe1
操作步骤如下:
1、创建表 test_a
CREATE TABLE test_a (
id BIGINT (20) NULL COMMENT '主键',
decimal_t_38 DECIMAL (38, 8) NULL COMMENT 'decimalt38'
) ENGINE = OLAP UNIQUE KEY (id) COMMENT 'test_a' DISTRIBUTED BY HASH (id) BUCKETS 100 PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"is_being_synced" = "false",
"storage_format" = "V2",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false"
);

2、插入表数据
insert into test_a(id,decimal_t_38) values(1,999999999999999999999999999999.99999999)

3、执行查询SQL
a、select 1 + 999999999999999999999999999999.99999999 from test_a
b、select 1 + decimal_t_38 from test_a
c、SELECT
PERCENTILE( decimal_t_38 ,0.5)
FROM test_a

4、报异常:

[SELECT - 0 row(s), 0.098 secs] [Error Code: 1105, SQL State: HY000] errCode = 2, detailMessage = (10.10.14.223)[CANCELLED][E-124][E-124] Arithmetic overflow

0#  doris::Exception::Exception(int, std::basic_string_view<char, std::char_traits<char> >) at /var/local/ldb-toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:173
1#  doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >::FieldType doris::vectorized::convert_decimals<doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >, doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >, false, true>(doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >::FieldType const&, unsigned int, unsigned int, doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >::FieldType const&, doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >::FieldType const&) at /opt/src/be/src/vec/data_types/data_type_decimal.h:0
2#  std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<std::__detail::__variant::__deduce_visit_result<void> (*)(doris::vectorized::ConvertImpl<doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >, doris::vectorized::DataTypeNumber<long>, doris::vectorized::NameToInt64>::execute<void*>(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long, bool, void*)::{lambda(auto:1, auto:2)#1}&&, std::variant<std::integral_constant<bool, false>, std::integral_constant<bool, true> >&&, std::variant<std::integral_constant<bool, false>, std::integral_constant<bool, true> >&&)>, std::integer_sequence<unsigned long, 0ul, 1ul> >::__visit_invoke(doris::vectorized::ConvertImpl<doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >, doris::vectorized::DataTypeNumber<long>, doris::vectorized::NameToInt64>::execute<void*>(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long, bool, void*)::{lambda(auto:1, auto:2)#1}&&, std::variant<std::integral_constant<bool, false>, std::integral_constant<bool, true> >&&, std::variant<std::integral_constant<bool, false>, std::integral_constant<bool, true> >&&) at /opt/src/be/src/vec/functions/function_cast.h:342
3#  doris::Status doris::vectorized::ConvertImpl<doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >, doris::vectorized::DataTypeNumber<long>, doris::vectorized::NameToInt64>::execute<void*>(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long, bool, void*) at /var/local/ldb-toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/variant:0
4#  bool doris::vectorized::FunctionConvert<doris::vectorized::DataTypeNumber<long>, doris::vectorized::NameToInt64, doris::vectorized::ToNumberMonotonicity<long> >::execute_impl(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long)::{lambda(auto:1 const&)#1}::operator()<doris::vectorized::TypePair<doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >, doris::vectorized::DataTypeNumber<long> > >(doris::vectorized::TypePair<doris::vectorized::DataTypeDecimal<doris::vectorized::Decimal<doris::vectorized::Int128I> >, doris::vectorized::DataTypeNumber<long> > const&) const at /opt/src/be/src/vec/functions/function_cast.h:1213
5#  bool doris::vectorized::call_on_index_and_data_type<doris::vectorized::DataTypeNumber<long>, doris::vectorized::FunctionConvert<doris::vectorized::DataTypeNumber<long>, doris::vectorized::NameToInt64, doris::vectorized::ToNumberMonotonicity<long> >::execute_impl(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long)::{lambda(auto:1 const&)#1}&>(doris::vectorized::TypeIndex, doris::vectorized::FunctionConvert<doris::vectorized::DataTypeNumber<long>, doris::vectorized::NameToInt64, doris::vectorized::ToNumberMonotonicity<long> >::execute_impl(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long)::{lambda(auto:1 const&)#1}&) at /opt/src/be/src/vec/core/call_on_type_index.h:235
6#  doris::vectorized::FunctionConvert<doris::vectorized::DataTypeNumber<long>, doris::vectorized::NameToInt64, doris::vectorized::ToNumberMonotonicity<long> >::execute_impl(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long) at /opt/src/be/src/vec/functions/function_cast.h:1220
7#  non-virtual thunk to doris::vectorized::FunctionConvert<doris::vectorized::DataTypeNumber<long>, doris::vectorized::NameToInt64, doris::vectorized::ToNumberMonotonicity<long> >::execute_impl(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long) at /opt/src/be/src/vec/functions/function_cast.h:0
8#  doris::vectorized::PreparedFunctionImpl::execute_without_low_cardinality_columns(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long, bool) at /opt/src/be/src/vec/functions/function.cpp:0
9#  doris::vectorized::PreparedFunctionImpl::execute(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long, bool) at /opt/src/be/src/vec/functions/function.cpp:274
10# std::_Function_handler<doris::Status (doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long), doris::vectorized::FunctionCast::create_wrapper<doris::vectorized::DataTypeNumber<long> >(std::shared_ptr<doris::vectorized::IDataType const> const&, doris::vectorized::DataTypeNumber<long> const*, bool) const::{lambda(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long)#1}>::_M_invoke(std::_Any_data const&, doris::FunctionContext*&&, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long&&, unsigned long&&) at /opt/src/be/src/vec/functions/function_cast.h:1656
11# doris::vectorized::FunctionCast::prepare_remove_nullable(doris::FunctionContext*, std::shared_ptr<doris::vectorized::IDataType const> const&, std::shared_ptr<doris::vectorized::IDataType const> const&, bool) const::{lambda(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long)#1}::operator()(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long) const at /var/local/ldb-toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_vector.h:335
12# std::_Function_handler<doris::Status (doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long), doris::vectorized::FunctionCast::prepare_remove_nullable(doris::FunctionContext*, std::shared_ptr<doris::vectorized::IDataType const> const&, std::shared_ptr<doris::vectorized::IDataType const> const&, bool) const::{lambda(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long)#1}>::_M_invoke(std::_Any_data const&, doris::FunctionContext*&&, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long&&, unsigned long&&) at /var/local/ldb-toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:291
13# doris::vectorized::PreparedFunctionCast::execute_impl(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long) at /var/local/ldb-toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_vector.h:335
14# doris::vectorized::PreparedFunctionImpl::execute_without_low_cardinality_columns(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long, bool) at /opt/src/be/src/vec/functions/function.cpp:0
15# doris::vectorized::PreparedFunctionImpl::execute(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long, bool) at /opt/src/be/src/vec/functions/function.cpp:274
16# doris::vectorized::IFunctionBase::execute(doris::FunctionContext*, doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long, bool) at /opt/src/be/src/vec/functions/function.h:183
17# doris::vectorized::VCastExpr::execute(doris::vectorized::VExprContext*, doris::vectorized::Block*, int*) at /opt/src/be/src/vec/exprs/vcast_expr.cpp:110
18# doris::vectorized::VExprContext::execute(doris::vectorized::Block*, int*) at /opt/src/be/src/common/status.h:354
19# doris::vectorized::AggFnEvaluator::_calc_argument_columns(doris::vectorized::Block*) at /opt/src/be/src/common/status.h:442
20# doris::vectorized::AggFnEvaluator::execute_single_add(doris::vectorized::Block*, char*, doris::vectorized::Arena*) at /opt/src/be/src/common/status.h:442
21# doris::vectorized::AggregationNode::_execute_without_key(doris::vectorized::Block*) at /opt/src/be/src/common/status.h:442
22# std::_Function_handler<doris::Status (doris::vectorized::Block*), std::_Bind_result<doris::Status, doris::Status (doris::vectorized::AggregationNode::*(doris::vectorized::AggregationNode*, std::_Placeholder<1>))(doris::vectorized::Block*)> >::_M_invoke(std::_Any_data const&, doris::vectorized::Block*&&) at /var/local/ldb-toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:291
23# doris::vectorized::AggregationNode::sink(doris::RuntimeState*, doris::vectorized::Block*, bool) at /opt/src/be/src/common/status.h:442
24# doris::pipeline::StreamingOperator<doris::pipeline::AggSinkOperatorBuilder>::sink(doris::RuntimeState*, doris::vectorized::Block*, doris::pipeline::SourceState) at /opt/src/be/src/pipeline/exec/operator.h:347
25# doris::pipeline::PipelineTask::execute(bool*) at /opt/src/be/src/common/status.h:437
26# doris::pipeline::TaskScheduler::_do_work(unsigned long) at /opt/src/be/src/common/status.h:354
27# doris::ThreadPool::dispatch_thread() at /opt/src/be/src/util/threadpool.cpp:0
28# doris::Thread::supervise_thread(void*) at /var/local/ldb-toolchain/bin/../usr/include/pthread.h:562
29# start_thread
30# __clone


0#  doris::vectorized::VCastExpr::execute(doris::vectorized::VExprContext*, doris::vectorized::Block*, int*) at /opt/src/be/src/common/status.h:354
1#  doris::vectorized::VExprContext::execute(doris::vectorized::Block*, int*) at /opt/src/be/src/common/status.h:354
2#  doris::vectorized::AggFnEvaluator::_calc_argument_columns(doris::vectorized::Block*) at /opt/src/be/src/common/status.h:442
3#  doris::vectorized::AggFnEvaluator::execute_single_add(doris::vectorized::Block*, char*, doris::vectorized::Arena*) at /opt/src/be/src/common/status.h:442
4#  doris::vectorized::AggregationNode::_execute_without_key(doris::vectorized::Block*) at /opt/src/be/src/common/status.h:442
5#  std::_Function_handler<doris::Status (doris::vectorized::Block*), std::_Bind_result<doris::Status, doris::Status (doris::vectorized::AggregationNode::*(doris::vectorized::AggregationNode*, std::_Placeholder<1>))(doris::vectorized::Block*)> >::_M_invoke(std::_Any_data const&, doris::vectorized::Block*&&) at /var/local/ldb-toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:291
6#  doris::vectorized::AggregationNode::sink(doris::RuntimeState*, doris::vectorized::Block*, bool) at /opt/src/be/src/common/status.h:442
7#  doris::pipeline::StreamingOperator<doris::pipeline::AggSinkOperatorBuilder>::sink(doris::RuntimeState*, doris::vectorized::Block*, doris::pipeline::SourceState) at /opt/src/be/src/pipeline/exec/operator.h:347
8#  doris::pipeline::PipelineTask::execute(bool*) at /opt/src/be/src/common/status.h:437
9#  doris::pipeline::TaskScheduler::_do_work(unsigned long) at /opt/src/be/src/common/status.h:354
10# doris::ThreadPool::dispatch_thread() at /opt/src/be/src/util/threadpool.cpp:0
11# doris::Thread::supervise_thread(void*) at /var/local/ldb-toolchain/bin/../usr/include/pthread.h:562
12# start_thread
13# __clone
1 Answers