doris-1.2.2 表字段类型DECIMALV3(4,2),进行比较大小时隐式转换造成数据未匹配的问题

Viewed 44

表情况描述:

总条数:8万条,满足where条件的数据:8万条。

1.结果只有200条
select count(1)from test.tmp_test
where time ='2024-03-01 00:00:00' and a >=0 and b<= 100;

2.结果有8万条
select count(1)from test.tmp_test
where time ='2024-03-01 00:00:00' and a >=0 and b<= round(100);

3.结果有8万条
select count(1)from test.tmp_test
where time ='2024-03-01 00:00:00' and a >=0 and round(b,2)<= 100;

4.结果 rn1有8万条,rn2有8万条
select count(1),count(case when b<= 100 then 1 else null end) rn1,
count(case when round(b,2)<= 100 then 1 else null end) rn2
from test.tmp_test
where time ='2024-03-01 00:00:00' and a >=0 ;

问题:

  1. 参照查询1,2,3,是否所有的比较运算符之后的 都会隐式转换?如果是的话,是不是所有比较运算符后的都要加类型转换函数?
  2. 参照查询1和4,是不是只有where条件中的比较运算符会隐式转换?
1 Answers

在1.2.x版本上,decimal的精度还有一些bug没有解决,到2.x版本上才算彻底解决了。这里where语句中是有可能做隐式转换的,所以在1.2上面最好手动地cast一下,让两个值类型一致。