diff --git a/be/src/vec/functions/function_binary_arithmetic.h b/be/src/vec/functions/function_binary_arithmetic.h index e95a6adc1f..8db58b072f 100644 --- a/be/src/vec/functions/function_binary_arithmetic.h +++ b/be/src/vec/functions/function_binary_arithmetic.h @@ -262,6 +262,10 @@ struct DecimalBinaryOperation { for (size_t i = 0; i < size; ++i) { null_map[i] = apply_op_safely(a[i], b[i], c[i].value); } + } else { + for (size_t i = 0; i < size; ++i) { + c[i] = apply(a[i], b[i], null_map[i]); + } } } diff --git a/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out b/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out index 7f29407e10..381a4612bb 100644 --- a/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out +++ b/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out @@ -53,3 +53,9 @@ 3 724.291976000 724.291976000 4 688.890183155 688.890183155 +-- !select -- +92594283.129196000 1 0.129196000 0.129196000 +107684988.257976000 3 0.257976000 0.257976000 +76891560.464178000 5 0.464178000 0.464178000 +277170831.851350000 7 0.851350000 0.851350000 + diff --git a/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy b/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy index b077e4c362..1d7fbb39b0 100644 --- a/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy +++ b/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy @@ -87,4 +87,26 @@ suite("test_arithmetic_expressions") { qt_select """ select id, fz/fm as dec,fzv3/fm as decv3 from ${table2} ORDER BY id; """ sql "drop table if exists ${table2}" + + def table3 = "test_mod_expressions" + + sql "drop table if exists ${table3}" + sql """ create table ${table3} ( + id smallint, + v1 decimalv3(27,9), + v2 decimalv3(9,0), + v3 int ) + DISTRIBUTED BY HASH(`id`) BUCKETS auto + PROPERTIES + ( + "replication_num" = "1" + ); """ + + sql """ insert into ${table3} values (1,92594283.129196000,1,1); """ + sql """ insert into ${table3} values (2,107684988.257976000,3,3); """ + sql """ insert into ${table3} values (3,76891560.464178000,5,5); """ + sql """ insert into ${table3} values (4,277170831.851350000,7,7); """ + + qt_select """ select v1, v2, v1 % v2, v1 % v3 from ${table3} ORDER BY id; """ + sql "drop table if exists ${table3}" }