Merge pull request #57183 from bigo-sg/opt_array_join

Trivial improvement on array join
This commit is contained in:
Raúl Marín 2023-11-28 12:21:00 +01:00 committed by GitHub
commit 335e7bf7ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -206,10 +206,19 @@ Block ArrayJoinResultIterator::next()
bool is_left = array_join->is_left; bool is_left = array_join->is_left;
auto cut_any_col = any_array->cut(current_row, next_row - current_row); auto cut_any_col = any_array->cut(current_row, next_row - current_row);
const auto * cut_any_array = typeid_cast<const ColumnArray *>(cut_any_col.get()); const auto * cut_any_array = typeid_cast<const ColumnArray *>(cut_any_col.get());
for (size_t i = 0; i < num_columns; ++i) for (size_t i = 0; i < num_columns; ++i)
{ {
ColumnWithTypeAndName current = block.safeGetByPosition(i); ColumnWithTypeAndName current = block.safeGetByPosition(i);
current.column = current.column->cut(current_row, next_row - current_row);
/// Reuse cut_any_col if possible to avoid unnecessary cut.
if (!is_unaligned && !is_left && current.name == *columns.begin())
{
current.column = cut_any_col;
current.type = getArrayJoinDataType(current.type);
}
else
current.column = current.column->cut(current_row, next_row - current_row);
if (columns.contains(current.name)) if (columns.contains(current.name))
{ {