mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #40909 from ClickHouse/Avogar-patch-1
Make better exception message in schema inference
This commit is contained in:
commit
110be0688e
@ -113,6 +113,11 @@ NamesAndTypesList IRowSchemaReader::readSchema()
|
||||
"Most likely setting input_format_max_rows_to_read_for_schema_inference is set to 0");
|
||||
|
||||
DataTypes data_types = readRowAndGetDataTypes();
|
||||
|
||||
/// Check that we read at list one column.
|
||||
if (data_types.empty())
|
||||
throw Exception(ErrorCodes::EMPTY_DATA_PASSED, "Cannot read rows from the data");
|
||||
|
||||
/// If column names weren't set, use default names 'c1', 'c2', ...
|
||||
if (column_names.empty())
|
||||
{
|
||||
@ -122,9 +127,11 @@ NamesAndTypesList IRowSchemaReader::readSchema()
|
||||
}
|
||||
/// If column names were set, check that the number of names match the number of types.
|
||||
else if (column_names.size() != data_types.size())
|
||||
{
|
||||
throw Exception(
|
||||
ErrorCodes::INCORRECT_DATA,
|
||||
"The number of column names {} differs with the number of types {}", column_names.size(), data_types.size());
|
||||
}
|
||||
|
||||
for (size_t i = 0; i != column_names.size(); ++i)
|
||||
{
|
||||
@ -155,10 +162,6 @@ NamesAndTypesList IRowSchemaReader::readSchema()
|
||||
}
|
||||
}
|
||||
|
||||
/// Check that we read at list one column.
|
||||
if (data_types.empty())
|
||||
throw Exception(ErrorCodes::EMPTY_DATA_PASSED, "Cannot read rows from the data");
|
||||
|
||||
NamesAndTypesList result;
|
||||
for (size_t i = 0; i != data_types.size(); ++i)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user