Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix float parsing in Values #7870

Merged
merged 1 commit into from Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions dbms/src/IO/PeekableReadBuffer.cpp
Expand Up @@ -19,19 +19,16 @@ bool PeekableReadBuffer::peekNext()
{
checkStateCorrect();

size_t bytes_read = 0;
Position copy_from = pos;
size_t bytes_to_copy = sub_buf.available();
if (useSubbufferOnly())
{
/// Don't have to copy all data from sub-buffer if there is no data in own memory (checkpoint and pos are in sub-buffer)
if (checkpoint)
copy_from = checkpoint;
bytes_read = copy_from - sub_buf.buffer().begin();
bytes_to_copy = sub_buf.buffer().end() - copy_from;
if (!bytes_to_copy)
{
bytes += bytes_read;
sub_buf.position() = copy_from;

/// Both checkpoint and pos are at the end of sub-buffer. Just load next part of data.
Expand All @@ -50,7 +47,6 @@ bool PeekableReadBuffer::peekNext()

if (useSubbufferOnly())
{
bytes += bytes_read;
sub_buf.position() = copy_from;
}

Expand Down Expand Up @@ -198,7 +194,6 @@ void PeekableReadBuffer::resizeOwnMemoryIfNecessary(size_t bytes_to_append)
/// Move unread data to the beginning of own memory instead of resize own memory
peeked_size -= offset;
memmove(memory.data(), memory.data() + offset, peeked_size);
bytes += offset;

if (need_update_checkpoint)
checkpoint -= offset;
Expand Down
@@ -0,0 +1 @@
-160.32605 37.705841
16 changes: 16 additions & 0 deletions dbms/tests/queries/0_stateless/01034_values_parse_float_bug.sh
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh


${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS values_floats"

${CLICKHOUSE_CLIENT} --query="CREATE TABLE values_floats (a Float32, b Float64) ENGINE = Memory"

${CLICKHOUSE_CLIENT} --query="SELECT '(-160.32605134916085,37.70584056842162),' FROM numbers(1000000)" | ${CLICKHOUSE_CLIENT} --query="INSERT INTO values_floats FORMAT Values"

${CLICKHOUSE_CLIENT} --query="SELECT DISTINCT round(a, 6), round(b, 6) FROM values_floats"

${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS values_floats"