From 7a23d8292f92bbb33a435bf794fc78e95b9919eb Mon Sep 17 00:00:00 2001 From: Nikita Mikhaylov Date: Fri, 16 Apr 2021 20:24:33 +0300 Subject: [PATCH] done --- src/Processors/Formats/Impl/CSVRowInputFormat.cpp | 3 +++ ...8_input_format_with_names_use_header.reference | 2 ++ .../01818_input_format_with_names_use_header.sh | 15 +++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 tests/queries/0_stateless/01818_input_format_with_names_use_header.reference create mode 100755 tests/queries/0_stateless/01818_input_format_with_names_use_header.sh diff --git a/src/Processors/Formats/Impl/CSVRowInputFormat.cpp b/src/Processors/Formats/Impl/CSVRowInputFormat.cpp index 00381ab96d0..4ccc0db4cfe 100644 --- a/src/Processors/Formats/Impl/CSVRowInputFormat.cpp +++ b/src/Processors/Formats/Impl/CSVRowInputFormat.cpp @@ -201,7 +201,10 @@ void CSVRowInputFormat::readPrefix() return; } else + { skipRow(in, format_settings.csv, num_columns); + setupAllColumnsByTableSchema(); + } } else if (!column_mapping->is_set) setupAllColumnsByTableSchema(); diff --git a/tests/queries/0_stateless/01818_input_format_with_names_use_header.reference b/tests/queries/0_stateless/01818_input_format_with_names_use_header.reference new file mode 100644 index 00000000000..b7b577c4685 --- /dev/null +++ b/tests/queries/0_stateless/01818_input_format_with_names_use_header.reference @@ -0,0 +1,2 @@ +testdata1 +testdata2 diff --git a/tests/queries/0_stateless/01818_input_format_with_names_use_header.sh b/tests/queries/0_stateless/01818_input_format_with_names_use_header.sh new file mode 100755 index 00000000000..f4b2aa692ba --- /dev/null +++ b/tests/queries/0_stateless/01818_input_format_with_names_use_header.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +${CLICKHOUSE_CLIENT_BINARY} -q "DROP TABLE IF EXISTS 01818_with_names;" + +${CLICKHOUSE_CLIENT_BINARY} -q "CREATE TABLE 01818_with_names (t String) ENGINE = MergeTree ORDER BY t;" + +echo -ne "t\ntestdata1\ntestdata2" | ${CLICKHOUSE_CLIENT_BINARY} --input_format_with_names_use_header 0 --query "INSERT INTO 01818_with_names FORMAT CSVWithNames" + +${CLICKHOUSE_CLIENT_BINARY} -q "SELECT * FROM 01818_with_names;" + +${CLICKHOUSE_CLIENT_BINARY} -q "DROP TABLE IF EXISTS 01818_with_names;"