Merge pull request #47410 from Avogar/fix-csv-big-numbers-inference

Fix big numbers inference in CSV
This commit is contained in:
Kruglov Pavel 2023-03-10 16:52:27 +01:00 committed by GitHub
commit 8c37540288
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -984,13 +984,16 @@ DataTypePtr tryInferNumberFromString(std::string_view field, const FormatSetting
if (tryReadIntText(tmp_int, buf) && buf.eof())
return std::make_shared<DataTypeInt64>();
/// We can safely get back to the start of buffer, because we read from a string and we didn't reach eof.
buf.position() = buf.buffer().begin();
/// In case of Int64 overflow, try to infer UInt64
UInt64 tmp_uint;
if (tryReadIntText(tmp_uint, buf) && buf.eof())
return std::make_shared<DataTypeUInt64>();
}
/// We cam safely get back to the start of buffer, because we read from a string and we didn't reach eof.
/// We can safely get back to the start of buffer, because we read from a string and we didn't reach eof.
buf.position() = buf.buffer().begin();
Float64 tmp;

View File

@ -0,0 +1,4 @@
c1 Nullable(Float64)
100000000000000000000
c1 Nullable(Float64)
-100000000000000000000

View File

@ -0,0 +1,5 @@
desc format('CSV', '100000000000000000000');
select * from format('CSV', '100000000000000000000');
desc format('CSV', '-100000000000000000000');
select * from format('CSV', '-100000000000000000000');