[Bug](decimal) fix mod function (#19925)
Bug: select id, kdcml * ktint, kdcml / ktint, kdcml % ktint from expr_test order by id; +------+-------------------+-------------------+-----------------------+ | id | kdcml * ktint | kdcml / ktint | kdcml % ktint | +------+-------------------+-------------------+-----------------------+ | NULL | NULL | NULL | NULL | | 1 | 24.395 | 24.395 | -4702111234474983.74 | | 2 | 68.968 | 17.242 | -4702111234474983.74 | | 3 | 146.268 | 16.252 | -4702111234474983.74 | | 4 | 275.772 | 17.235 | -4702111234474983.74 | | 5 | 487.470 | 19.498 | -4702111234474983.74 | | 6 | 827.244 | 22.979 | -4702111234474983.74 | | 7 | 1364.860 | 27.854 | -4702111234474983.74 | | 8 | 2205.928 | 34.467 | -4702111234474983.74 | | 9 | 3509.595 | 43.328 | -4702111234474983.74 | | 10 | 5514.790 | 55.147 | -4702111234474983.74 | | 11 | 8578.988 | 70.900 | -4702111234474983.74 | | 12 | 13235.484 | 91.913 | -4702111234474983.74 | | 13 | 24.395 | 24.395 | -4702111234474983.74 | | 14 | 68.968 | 17.242 | -4702111234474983.74 | | 15 | 146.268 | 16.252 | -4702111234474983.74 | | 16 | 275.772 | 17.235 | -4702111234474983.74 | | 17 | 487.470 | 19.498 | -4702111234474983.74 | | 18 | 827.244 | 22.979 | -4702111234474983.74 | | 19 | 1364.860 | 27.854 | -4702111234474983.74 | | 20 | 2205.928 | 34.467 | -4702111234474983.74 | | 21 | 3509.595 | 43.328 | -4702111234474983.74 | | 22 | 5514.790 | 55.147 | -4702111234474983.74 | | 23 | 8578.988 | 70.900 | -4702111234474983.74 | | 24 | 13235.484 | 91.913 | -4702111234474983.74 |
This commit is contained in:
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user