[function](cast)Make string casting to integers more like MySQL's beh… (#41541)
…avior (#38847) https://github.com/apache/doris/pull/38847 ## Proposed changes There are two issues here. First, the results of casting are inconsistent between FE and BE . ``` FE mysql [(none)]>select cast('3.000' as int); +----------------------+ | cast('3.000' as INT) | +----------------------+ | 3 | +----------------------+ mysql [(none)]>set debug_skip_fold_constant = true; BE mysql [(none)]>select cast('3.000' as int); +----------------------+ | cast('3.000' as INT) | +----------------------+ | NULL | +----------------------+ ``` The second issue is that casting on BE converts '3.0' to null. Here, the casting logic for FE and BE has been unified <!--Describe your changes.--> ## Proposed changes Issue Number: close #xxx <!--Describe your changes.--> --------- Co-authored-by: Xinyi Zou <zouxinyi02@gmail.com>
This commit is contained in:
@ -98,6 +98,13 @@ int64_t ParseUtil::parse_mem_spec(const std::string& mem_spec_str, int64_t paren
|
||||
if (result != StringParser::PARSE_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto limit_val_double =
|
||||
StringParser::string_to_float<double>(mem_spec_str.data(), number_str_len, &result);
|
||||
if (result == StringParser::PARSE_SUCCESS && limit_val_double != limit_val) {
|
||||
return -1; // mem_spec_str is double.
|
||||
}
|
||||
|
||||
bytes = limit_val;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user