mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 20:32:43 +00:00
fix
This commit is contained in:
parent
201f021db1
commit
6d5e97d9d9
@ -11,6 +11,7 @@
|
||||
|
||||
#include <Poco/Logger.h>
|
||||
#include <Common/logger_useful.h>
|
||||
#include "Parsers/ExpressionListParsers.h"
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -149,9 +150,10 @@ private:
|
||||
template <bool need_filter>
|
||||
static void setUsed(IColumn::Filter & filter [[maybe_unused]], size_t pos [[maybe_unused]]);
|
||||
|
||||
template <typename AddedColumns>
|
||||
template <typename AddedColumns, typename Selector>
|
||||
static ColumnPtr buildAdditionalFilter(
|
||||
size_t left_start_row,
|
||||
const Selector & selector,
|
||||
const std::vector<const RowRef *> & selected_rows,
|
||||
const std::vector<size_t> & row_replicate_offset,
|
||||
AddedColumns & added_columns);
|
||||
|
@ -358,6 +358,12 @@ size_t HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::joinRightColumnsSwitchMu
|
||||
if (added_columns.additional_filter_expression)
|
||||
{
|
||||
const bool mark_per_row_used = join_features.right || join_features.full || mapv.size() > 1;
|
||||
LOG_DEBUG(
|
||||
&Poco::Logger::get("debug"),
|
||||
"__PRETTY_FUNCTION__={}, __LINE__={}, mark_per_row_used={}",
|
||||
__PRETTY_FUNCTION__,
|
||||
__LINE__,
|
||||
mark_per_row_used);
|
||||
return joinRightColumnsWithAddtitionalFilter<KeyGetter, Map>(
|
||||
std::forward<std::vector<KeyGetter>>(key_getter_vector),
|
||||
mapv,
|
||||
@ -554,9 +560,10 @@ void HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::setUsed(IColumn::Filter &
|
||||
}
|
||||
|
||||
template <JoinKind KIND, JoinStrictness STRICTNESS, typename MapsTemplate>
|
||||
template <typename AddedColumns>
|
||||
template <typename AddedColumns, typename Selector>
|
||||
ColumnPtr HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::buildAdditionalFilter(
|
||||
size_t left_start_row,
|
||||
const Selector & selector,
|
||||
const std::vector<const RowRef *> & selected_rows,
|
||||
const std::vector<size_t> & row_replicate_offset,
|
||||
AddedColumns & added_columns)
|
||||
@ -569,12 +576,14 @@ ColumnPtr HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::buildAdditionalFilter
|
||||
result_column = ColumnUInt8::create();
|
||||
break;
|
||||
}
|
||||
LOG_DEBUG(&Poco::Logger::get("debug"), "__PRETTY_FUNCTION__={}, __LINE__={}", __PRETTY_FUNCTION__, __LINE__);
|
||||
const Block & sample_right_block = *((*selected_rows.begin())->block);
|
||||
if (!sample_right_block || !added_columns.additional_filter_expression)
|
||||
{
|
||||
auto filter = ColumnUInt8::create();
|
||||
filter->insertMany(1, selected_rows.size());
|
||||
result_column = std::move(filter);
|
||||
LOG_DEBUG(&Poco::Logger::get("debug"), "__PRETTY_FUNCTION__={}, __LINE__={}", __PRETTY_FUNCTION__, __LINE__);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -584,6 +593,7 @@ ColumnPtr HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::buildAdditionalFilter
|
||||
Block block;
|
||||
added_columns.additional_filter_expression->execute(block);
|
||||
result_column = block.getByPosition(0).column->cloneResized(selected_rows.size());
|
||||
LOG_DEBUG(&Poco::Logger::get("debug"), "__PRETTY_FUNCTION__={}, __LINE__={}", __PRETTY_FUNCTION__, __LINE__);
|
||||
break;
|
||||
}
|
||||
NameSet required_column_names;
|
||||
@ -600,6 +610,14 @@ ColumnPtr HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::buildAdditionalFilter
|
||||
for (const auto & selected_row : selected_rows)
|
||||
{
|
||||
const auto & src_col = selected_row->block->getByPosition(right_col_pos);
|
||||
if (executed_block.columns() == 0)
|
||||
LOG_DEBUG(
|
||||
&Poco::Logger::get("debug"),
|
||||
"__PRETTY_FUNCTION__={}, __LINE__={}, src_col.name={}, selected_row->row_num={}",
|
||||
__PRETTY_FUNCTION__,
|
||||
__LINE__,
|
||||
src_col.name,
|
||||
selected_row->row_num);
|
||||
new_col->insertFrom(*src_col.column, selected_row->row_num);
|
||||
}
|
||||
executed_block.insert({std::move(new_col), col.type, col.name});
|
||||
@ -619,7 +637,9 @@ ColumnPtr HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::buildAdditionalFilter
|
||||
const size_t & left_offset = row_replicate_offset[i];
|
||||
size_t rows = left_offset - prev_left_offset;
|
||||
if (rows)
|
||||
new_col->insertManyFrom(*src_col->column, left_start_row + i - 1, rows);
|
||||
{
|
||||
new_col->insertManyFrom(*src_col->column, selector[left_start_row + i - 1], rows);
|
||||
}
|
||||
prev_left_offset = left_offset;
|
||||
}
|
||||
executed_block.insert({std::move(new_col), src_col->type, col_name});
|
||||
@ -902,7 +922,7 @@ size_t HashJoinMethods<KIND, STRICTNESS, MapsTemplate>::joinRightColumnsWithAddt
|
||||
it,
|
||||
left_start_row);
|
||||
}
|
||||
auto filter_col = buildAdditionalFilter(left_start_row, selected_rows, row_replicate_offset, added_columns);
|
||||
auto filter_col = buildAdditionalFilter(left_start_row, selector, selected_rows, row_replicate_offset, added_columns);
|
||||
copy_final_matched_rows(left_start_row, filter_col);
|
||||
|
||||
if constexpr (join_features.need_replication)
|
||||
|
Loading…
Reference in New Issue
Block a user