Skip to content

Commit

Permalink
Fix parse float string to int (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyang-li authored and kyligence-git committed Nov 21, 2023
1 parent 67a9845 commit b8ba0ae
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Functions/FunctionsConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,26 @@ struct ConvertThroughParsing
}
}

/// Special case, that allows to parse string like 12.34 as (U)Int8|16|32|64|128|256.
else if constexpr (
std::is_same_v<ToDataType, DataTypeUInt16> || std::is_same_v<ToDataType, DataTypeUInt32>
|| std::is_same_v<ToDataType, DataTypeUInt64> || std::is_same_v<ToDataType, DataTypeUInt128>
|| std::is_same_v<ToDataType, DataTypeUInt256> || std::is_same_v<ToDataType, DataTypeInt8>
|| std::is_same_v<ToDataType, DataTypeInt16> || std::is_same_v<ToDataType, DataTypeInt32>
|| std::is_same_v<ToDataType, DataTypeInt64> || std::is_same_v<ToDataType, DataTypeInt128>
|| std::is_same_v<ToDataType, DataTypeInt256>)
{
if (!in.eof() && (*in.position() == '.'))
{
++in.position();
while (!in.eof() && isNumericASCII(*in.position()))
++in.position();

if (in.eof())
return true;
}
}

return false;
}

Expand Down

0 comments on commit b8ba0ae

Please sign in to comment.