Merge pull request #23202 from nikitamikhaylov/with_names_use_header_bug

`CSVWithNames` with `input_format_with_names_use_header=0`
This commit is contained in:
Nikita Mikhaylov 2021-04-20 20:00:57 +03:00 committed by GitHub
commit 16e7715039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View File

@ -201,7 +201,10 @@ void CSVRowInputFormat::readPrefix()
return; return;
} }
else else
{
skipRow(in, format_settings.csv, num_columns); skipRow(in, format_settings.csv, num_columns);
setupAllColumnsByTableSchema();
}
} }
else if (!column_mapping->is_set) else if (!column_mapping->is_set)
setupAllColumnsByTableSchema(); setupAllColumnsByTableSchema();

View File

@ -0,0 +1,2 @@
testdata1
testdata2

View File

@ -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} -q "DROP TABLE IF EXISTS \`01818_with_names\`;"
${CLICKHOUSE_CLIENT} -q "CREATE TABLE \`01818_with_names\` (t String) ENGINE = MergeTree ORDER BY t;"
echo -ne "t\ntestdata1\ntestdata2" | ${CLICKHOUSE_CLIENT} --input_format_with_names_use_header 0 --query "INSERT INTO \`01818_with_names\` FORMAT CSVWithNames"
${CLICKHOUSE_CLIENT} -q "SELECT * FROM \`01818_with_names\`;"
${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS \`01818_with_names\`;"