Try fix tests.

This commit is contained in:
Nikolai Kochetov 2020-05-29 19:35:09 +03:00
parent bd814d83de
commit f7e0e87c7d
2 changed files with 6 additions and 2 deletions

View File

@ -450,7 +450,7 @@ BlockIO InterpreterSelectQuery::execute()
{
res.pipeline.addSimpleTransform([&](const Block & header)
{
return std::make_shared<ConvertingTransform>(header, result_header, ConvertingTransform::MatchColumnsMode::Position);
return std::make_shared<ConvertingTransform>(header, result_header, ConvertingTransform::MatchColumnsMode::Name);
});
}

View File

@ -59,7 +59,11 @@ ConvertingTransform::ConvertingTransform(
break;
case MatchColumnsMode::Name:
if (source.has(res_elem.name))
/// It may seem strange, but sometimes block may have columns with the same name.
/// For this specific case, try to get column from the same position if it has correct name first.
if (result_col_num < source.columns() && source.getByPosition(result_col_num).name == res_elem.name)
conversion[result_col_num] = result_col_num;
else if (source.has(res_elem.name))
conversion[result_col_num] = source.getPositionByName(res_elem.name);
else
throw Exception("Cannot find column " + backQuoteIfNeed(res_elem.name) + " in source stream",