mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Merge pull request #22527 from ClickHouse/fix-missing-nl-parse-tsv
Fix deserialization of empty string without newline at end of TSV format
This commit is contained in:
commit
143f4b59a0
@ -224,12 +224,9 @@ ReturnType SerializationNullable::deserializeTextEscapedImpl(IColumn & column, R
|
|||||||
{
|
{
|
||||||
/// Little tricky, because we cannot discriminate null from first character.
|
/// Little tricky, because we cannot discriminate null from first character.
|
||||||
|
|
||||||
if (istr.eof())
|
if (istr.eof() || *istr.position() != '\\') /// Some data types can deserialize absence of data (e.g. empty string), so eof is ok.
|
||||||
throw ParsingException("Unexpected end of stream, while parsing value of Nullable type", ErrorCodes::CANNOT_READ_ALL_DATA);
|
|
||||||
|
|
||||||
/// This is not null, surely.
|
|
||||||
if (*istr.position() != '\\')
|
|
||||||
{
|
{
|
||||||
|
/// This is not null, surely.
|
||||||
return safeDeserialize<ReturnType>(column, *nested,
|
return safeDeserialize<ReturnType>(column, *nested,
|
||||||
[] { return false; },
|
[] { return false; },
|
||||||
[&nested, &istr, &settings] (IColumn & nested_column) { nested->deserializeTextEscaped(nested_column, istr, settings); });
|
[&nested, &istr, &settings] (IColumn & nested_column) { nested->deserializeTextEscaped(nested_column, istr, settings); });
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
12
tests/queries/0_stateless/01786_nullable_string_tsv_at_eof.sh
Executable file
12
tests/queries/0_stateless/01786_nullable_string_tsv_at_eof.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
# shellcheck source=../shell_config.sh
|
||||||
|
. "$CUR_DIR"/../shell_config.sh
|
||||||
|
|
||||||
|
printf '1\t' | $CLICKHOUSE_LOCAL --query="SELECT * FROM table" --structure='a String, b String'
|
||||||
|
printf '1\t' | $CLICKHOUSE_LOCAL --input_format_null_as_default 0 --query="SELECT * FROM table" --structure='a String, b String'
|
||||||
|
printf '1\t' | $CLICKHOUSE_LOCAL --input_format_null_as_default 1 --query="SELECT * FROM table" --structure='a String, b String'
|
||||||
|
printf '1\t' | $CLICKHOUSE_LOCAL --query="SELECT * FROM table" --structure='a String, b Nullable(String)'
|
||||||
|
printf '1\t' | $CLICKHOUSE_LOCAL --input_format_null_as_default 0 --query="SELECT * FROM table" --structure='a String, b Nullable(String)'
|
||||||
|
printf '1\t' | $CLICKHOUSE_LOCAL --input_format_null_as_default 1 --query="SELECT * FROM table" --structure='a Nullable(String), b Nullable(String)'
|
Loading…
Reference in New Issue
Block a user