You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2019/12/04 05:11:45 UTC

[GitHub] [incubator-doris] yangzhg removed a comment on issue #2142: 'nan' result didn't merge

yangzhg removed a comment on issue #2142: 'nan'  result didn't merge
URL: https://github.com/apache/incubator-doris/issues/2142#issuecomment-561471885
 
 
   这个现象的原因是在 be 和fe 的代码中我们对于 数字和字符串的算数运算处理逻辑导致的,在字符串和数字做算数运算时 字符串会默认cast 成 double 类型。不同的数据库对于这个问题的处理也不同,比如postgres 不支持这种操作,mysql 支持,mysql 的逻辑是匹配字符串前缀 转换成数字,前缀没有数字则是0 比如 `1 + '1' = 2`, `1 + '1a' = 2` , `1 + 'a' = 1` , `1 + 'a1' = 2` , 我们部分兼容了mysql 的操作,但是字符串转数字 只支持完整的字符串格式, 和类似NAN 这种 其他情况会 报错, 使整个表达式值变为 null,例如  `1 + '1' = 2`, `1 + '1a' = null`  `1 + 'nan' = nan` 具体细节见代码  `be/src/util/string_parser.hpp`, 
   但是现在 由于doris 有一定的用户量,所以无论是改成 mysql 兼容还是 postgres 兼容 都会引起对现在的已有用户的不兼容现象,因此 这个问题暂时保持现状,不做处理,等待以后在处理
   
   
   The reason for this case is that in the code of be and fe, our logic of arithmetic operation for  numbers and strings is caused. When performing arithmetic operations on strings and numbers, strings are cast to double by default. Different databases deal with this problem differently. For example, postgres does not support this operation. MySQL supports it. The logic of mysql is to match the string prefix to a number. If the prefix is not a number, it is 0. For example, 1 + '1' = 2, 1 + '1a' = 2, 1 + 'a' = 1, 1 + 'a1' = 2, we are partially compatible with mysql operations, but string to number only supports the full string format, and other similar to NAN and other The situation will report an error, making the entire expression value null, such as 1 + '1' = 2, 1 + '1a' = null 1 + 'nan' = nan. For details, see the code be / src / util / string_parser.hpp,
   But now that doris has a certain number of users, no matter whether it is mysql compatible or postgres compatible, it will cause incompatibility to existing users. Therefore, this issue will remain the status quo for the time being, do not deal with it, and wait for the future
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org