diff --git a/src/Processors/Formats/Impl/TabSeparatedRowInputFormat.cpp b/src/Processors/Formats/Impl/TabSeparatedRowInputFormat.cpp index 2239c8539e3..6b1e9dad8d9 100644 --- a/src/Processors/Formats/Impl/TabSeparatedRowInputFormat.cpp +++ b/src/Processors/Formats/Impl/TabSeparatedRowInputFormat.cpp @@ -411,11 +411,6 @@ static std::pair fileSegmentationEngineTabSeparatedImpl(ReadBuffer continue; } - ++number_of_rows; - if ((number_of_rows >= min_rows) - && ((memory.size() + static_cast(pos - in.position()) >= min_bytes) || (number_of_rows == max_rows))) - need_more_data = false; - if (*pos == '\n') { ++pos; @@ -427,7 +422,14 @@ static std::pair fileSegmentationEngineTabSeparatedImpl(ReadBuffer ++pos; if (loadAtPosition(in, memory, pos) && *pos == '\n') ++pos; + else + continue; } + + ++number_of_rows; + if ((number_of_rows >= min_rows) + && ((memory.size() + static_cast(pos - in.position()) >= min_bytes) || (number_of_rows == max_rows))) + need_more_data = false; } saveUpToPosition(in, memory, pos); diff --git a/tests/queries/0_stateless/02844_tsv_carriage_return_parallel_parsing.reference b/tests/queries/0_stateless/02844_tsv_carriage_return_parallel_parsing.reference new file mode 100644 index 00000000000..749fce669df --- /dev/null +++ b/tests/queries/0_stateless/02844_tsv_carriage_return_parallel_parsing.reference @@ -0,0 +1 @@ +1000000 diff --git a/tests/queries/0_stateless/02844_tsv_carriage_return_parallel_parsing.sh b/tests/queries/0_stateless/02844_tsv_carriage_return_parallel_parsing.sh new file mode 100755 index 00000000000..cfd419d908e --- /dev/null +++ b/tests/queries/0_stateless/02844_tsv_carriage_return_parallel_parsing.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +$CLICKHOUSE_LOCAL -q "select 'Hello\rWorld' from numbers(1000000) format TSVRaw" > $CLICKHOUSE_TEST_UNIQUE_NAME.tsv +$CLICKHOUSE_LOCAL -q "select count() from file('$CLICKHOUSE_TEST_UNIQUE_NAME.tsv')" +rm $CLICKHOUSE_TEST_UNIQUE_NAME.tsv +