mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
Allow to parse +inf #1839
This commit is contained in:
parent
747bb16677
commit
738fef71f4
@ -156,6 +156,9 @@ ReturnType readFloatTextPreciseImpl(T & x, ReadBuffer & buf)
|
||||
{
|
||||
switch (*buf.position())
|
||||
{
|
||||
case '+':
|
||||
continue;
|
||||
|
||||
case '-':
|
||||
{
|
||||
negative = true;
|
||||
@ -335,6 +338,7 @@ ReturnType readFloatTextFastImpl(T & x, ReadBuffer & in)
|
||||
++in.position();
|
||||
}
|
||||
|
||||
|
||||
auto count_after_sign = in.count();
|
||||
|
||||
constexpr int significant_digits = std::numeric_limits<UInt64>::digits10;
|
||||
@ -380,7 +384,7 @@ ReturnType readFloatTextFastImpl(T & x, ReadBuffer & in)
|
||||
if (in.eof())
|
||||
{
|
||||
if constexpr (throw_exception)
|
||||
throw Exception("Cannot read floating point value", ErrorCodes::CANNOT_PARSE_NUMBER);
|
||||
throw Exception("Cannot read floating point value: nothing after exponent", ErrorCodes::CANNOT_PARSE_NUMBER);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -418,11 +422,30 @@ ReturnType readFloatTextFastImpl(T & x, ReadBuffer & in)
|
||||
if (in.eof())
|
||||
{
|
||||
if constexpr (throw_exception)
|
||||
throw Exception("Cannot read floating point value", ErrorCodes::CANNOT_PARSE_NUMBER);
|
||||
throw Exception("Cannot read floating point value: no digits read", ErrorCodes::CANNOT_PARSE_NUMBER);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*in.position() == '+')
|
||||
{
|
||||
++in.position();
|
||||
if (in.eof())
|
||||
{
|
||||
if constexpr (throw_exception)
|
||||
throw Exception("Cannot read floating point value: nothing after plus sign", ErrorCodes::CANNOT_PARSE_NUMBER);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (negative)
|
||||
{
|
||||
if constexpr (throw_exception)
|
||||
throw Exception("Cannot read floating point value: plus after minus sign", ErrorCodes::CANNOT_PARSE_NUMBER);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (*in.position() == 'i' || *in.position() == 'I')
|
||||
{
|
||||
if (assertOrParseInfinity<throw_exception>(in))
|
||||
|
3
tests/queries/0_stateless/01198_plus_inf.reference
Normal file
3
tests/queries/0_stateless/01198_plus_inf.reference
Normal file
@ -0,0 +1,3 @@
|
||||
inf
|
||||
-inf
|
||||
inf
|
3
tests/queries/0_stateless/01198_plus_inf.sql
Normal file
3
tests/queries/0_stateless/01198_plus_inf.sql
Normal file
@ -0,0 +1,3 @@
|
||||
SELECT DISTINCT toFloat64(arrayJoin(['+inf', '+Inf', '+INF', '+infinity', '+Infinity']));
|
||||
SELECT DISTINCT toFloat64(arrayJoin(['-inf', '-Inf', '-INF', '-infinity', '-Infinity']));
|
||||
SELECT DISTINCT toFloat64(arrayJoin(['inf', 'Inf', 'INF', 'infinity', 'Infinity']));
|
Loading…
Reference in New Issue
Block a user