Skip to content

Commit

Permalink
Fix parse float string to int (#465)
Browse files Browse the repository at this point in the history
(cherry picked from commit ef563d5)
(cherry picked from commit de5c058)
(cherry picked from commit 40f162d)
(cherry picked from commit 8d6cd72)
(cherry picked from commit e77b814)
(cherry picked from commit ee780a2)
(cherry picked from commit 8ee9aa3)
(cherry picked from commit bbf5425)
(cherry picked from commit fe1279c)
(cherry picked from commit 230964a)
(cherry picked from commit 0c191a5)
  • Loading branch information
taiyang-li authored and baibaichen committed Mar 18, 2024
1 parent 243b0fd commit 5cb4c58
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Functions/FunctionsConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,25 @@ 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 5cb4c58

Please sign in to comment.