Removed prewhere_info.alias_actions

This commit is contained in:
Alexander Gololobov 2022-05-30 19:58:23 +02:00
parent 6db44f633f
commit e2dd6f6249
10 changed files with 7 additions and 77 deletions

View File

@ -1970,7 +1970,6 @@ void ExpressionAnalysisResult::checkActions() const
};
check_actions(prewhere_info->prewhere_actions);
check_actions(prewhere_info->alias_actions);
}
}

View File

@ -1625,15 +1625,6 @@ void InterpreterSelectQuery::addEmptySourceToQueryPlan(
{
auto & prewhere_info = *prewhere_info_ptr;
if (prewhere_info.alias_actions)
{
pipe.addSimpleTransform([&](const Block & header)
{
return std::make_shared<ExpressionTransform>(header,
std::make_shared<ExpressionActions>(prewhere_info.alias_actions));
});
}
if (prewhere_info.row_level_filter)
{
pipe.addSimpleTransform([&](const Block & header)
@ -1873,19 +1864,6 @@ void InterpreterSelectQuery::addPrewhereAliasActions()
for (const auto & name : required_columns)
prewhere_info->prewhere_actions->tryRestoreColumn(name);
auto analyzed_result
= TreeRewriter(context).analyze(required_columns_from_prewhere_expr, metadata_snapshot->getColumns().getAllPhysical());
prewhere_info->alias_actions
= ExpressionAnalyzer(required_columns_from_prewhere_expr, analyzed_result, context).getActionsDAG(true, false);
/// Add (physical?) columns required by alias actions.
auto required_columns_from_alias = prewhere_info->alias_actions->getRequiredColumns();
Block prewhere_actions_result = prewhere_info->prewhere_actions->getResultColumns();
for (auto & column : required_columns_from_alias)
if (!prewhere_actions_result.has(column.name))
if (required_columns.end() == std::find(required_columns.begin(), required_columns.end(), column.name))
required_columns.push_back(column.name);
/// Add physical columns required by prewhere actions.
for (const auto & column : required_columns_from_prewhere)
if (!required_aliases_from_prewhere.contains(column))

View File

@ -231,11 +231,6 @@ std::string PrewhereInfo::dump() const
WriteBufferFromOwnString ss;
ss << "PrewhereDagInfo\n";
if (alias_actions)
{
ss << "alias_actions " << alias_actions->dumpDAG() << "\n";
}
if (prewhere_actions)
{
ss << "prewhere_actions " << prewhere_actions->dumpDAG() << "\n";

View File

@ -72,8 +72,6 @@ MergeTreeBaseSelectProcessor::MergeTreeBaseSelectProcessor(
if (prewhere_info)
{
prewhere_actions = std::make_unique<PrewhereExprInfo>();
if (prewhere_info->alias_actions)
prewhere_actions->alias_actions = std::make_shared<ExpressionActions>(prewhere_info->alias_actions, actions_settings);
if (prewhere_info->row_level_filter)
prewhere_actions->row_level_filter = std::make_shared<ExpressionActions>(prewhere_info->row_level_filter, actions_settings);
@ -556,9 +554,6 @@ Block MergeTreeBaseSelectProcessor::transformHeader(
{
if (prewhere_info)
{
if (prewhere_info->alias_actions)
block = prewhere_info->alias_actions->updateHeader(std::move(block));
if (prewhere_info->row_level_filter)
{
block = prewhere_info->row_level_filter->updateHeader(std::move(block));

View File

@ -280,10 +280,6 @@ MergeTreeReadTaskColumns getReadTaskColumns(
storage, storage_snapshot, data_part, with_subcolumns, column_names).empty();
if (prewhere_info)
{
if (prewhere_info->alias_actions)
pre_column_names = prewhere_info->alias_actions->getRequiredColumnsNames();
else
{
pre_column_names = prewhere_info->prewhere_actions->getRequiredColumnsNames();
@ -297,7 +293,6 @@ MergeTreeReadTaskColumns getReadTaskColumns(
pre_column_names.push_back(name);
}
}
}
if (pre_column_names.empty())
pre_column_names.push_back(column_names[0]);

View File

@ -5439,17 +5439,6 @@ std::optional<ProjectionCandidate> MergeTreeData::getQueryProcessingStageWithAgg
candidate.prewhere_info->row_level_filter = row_level_filter_actions;
}
if (candidate.prewhere_info->alias_actions)
{
auto alias_actions = candidate.prewhere_info->alias_actions->clone();
// alias_action should not add missing keys.
auto new_prewhere_required_columns
= alias_actions->foldActionsByProjection(prewhere_required_columns, projection.sample_block_for_keys, {}, false);
if (new_prewhere_required_columns.empty() && !prewhere_required_columns.empty())
return false;
prewhere_required_columns = std::move(new_prewhere_required_columns);
candidate.prewhere_info->alias_actions = alias_actions;
}
required_columns.insert(prewhere_required_columns.begin(), prewhere_required_columns.end());
}
@ -5619,8 +5608,6 @@ std::optional<ProjectionCandidate> MergeTreeData::getQueryProcessingStageWithAgg
if (minmax_count_projection_candidate->prewhere_info)
{
const auto & prewhere_info = minmax_count_projection_candidate->prewhere_info;
if (prewhere_info->alias_actions)
ExpressionActions(prewhere_info->alias_actions, actions_settings).execute(query_info.minmax_count_projection_block);
if (prewhere_info->row_level_filter)
{

View File

@ -564,9 +564,6 @@ MergeTreeRangeReader::MergeTreeRangeReader(
if (prewhere_info)
{
if (prewhere_info->alias_actions)
prewhere_info->alias_actions->execute(sample_block, true);
if (prewhere_info->row_level_filter)
{
prewhere_info->row_level_filter->execute(sample_block, true);
@ -1029,9 +1026,6 @@ void MergeTreeRangeReader::executePrewhereActionsAndFilterColumns(ReadResult & r
++pos;
}
if (prewhere_info->alias_actions)
prewhere_info->alias_actions->execute(block);
/// Columns might be projected out. We need to store them here so that default columns can be evaluated later.
result.block_before_prewhere = block;

View File

@ -21,8 +21,6 @@ using ExpressionActionsPtr = std::shared_ptr<ExpressionActions>;
/// The same as PrewhereInfo, but with ExpressionActions instead of ActionsDAG
struct PrewhereExprInfo
{
/// Actions which are executed in order to alias columns are used for prewhere actions.
ExpressionActionsPtr alias_actions;
/// Actions for row level security filter. Applied separately before prewhere_actions.
/// This actions are separate because prewhere condition should not be executed over filtered rows.
ExpressionActionsPtr row_level_filter;

View File

@ -48,8 +48,6 @@ using SubqueriesForSets = std::unordered_map<String, SubqueryForSet>;
struct PrewhereInfo
{
/// Actions which are executed in order to alias columns are used for prewhere actions.
ActionsDAGPtr alias_actions;
/// Actions for row level security filter. Applied separately before prewhere_actions.
/// This actions are separate because prewhere condition should not be executed over filtered rows.
ActionsDAGPtr row_level_filter;

View File

@ -383,15 +383,6 @@ void StorageBuffer::read(
if (query_info.prewhere_info)
{
auto actions_settings = ExpressionActionsSettings::fromContext(local_context);
if (query_info.prewhere_info->alias_actions)
{
pipe_from_buffers.addSimpleTransform([&](const Block & header)
{
return std::make_shared<ExpressionTransform>(
header,
std::make_shared<ExpressionActions>(query_info.prewhere_info->alias_actions, actions_settings));
});
}
if (query_info.prewhere_info->row_level_filter)
{