Update src/Formats/ReadSchemaUtils.cpp

This commit is contained in:
Kruglov Pavel 2023-04-11 14:18:16 +02:00 committed by GitHub
parent b869572a54
commit f087f0e877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -203,6 +203,7 @@ ColumnsDescription readSchemaFromFormat(
ErrorCodes::BAD_ARGUMENTS, ErrorCodes::BAD_ARGUMENTS,
"{} file format doesn't support schema inference. You must specify the structure manually", "{} file format doesn't support schema inference. You must specify the structure manually",
format_name); format_name);
/// Some formats like CSVWithNames can contain empty column names. We don't support empty column names and futher processing can fail with an exception. Let's just remove columns with empty names from the structure.
names_and_types.erase( names_and_types.erase(
std::remove_if(names_and_types.begin(), names_and_types.end(), [](const NameAndTypePair & pair) { return pair.name.empty(); }), std::remove_if(names_and_types.begin(), names_and_types.end(), [](const NameAndTypePair & pair) { return pair.name.empty(); }),
names_and_types.end()); names_and_types.end());