Check if query_info can be removed when building filter dag.

This commit is contained in:
Amos Bird 2024-02-17 00:36:34 +08:00
parent 07c828ece9
commit 001596ea0e
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 5 additions and 23 deletions

View File

@ -1318,12 +1318,11 @@ ReadFromMergeTree::AnalysisResultPtr ReadFromMergeTree::selectRangesToRead(
} }
static ActionsDAGPtr buildFilterDAG( static ActionsDAGPtr buildFilterDAG(
const ContextPtr & context, const ContextPtr & /* context */,
const PrewhereInfoPtr & prewhere_info, const PrewhereInfoPtr & prewhere_info,
const ActionDAGNodes & added_filter_nodes, const ActionDAGNodes & added_filter_nodes,
const SelectQueryInfo & query_info) const SelectQueryInfo & /* query_info */)
{ {
const auto & settings = context->getSettingsRef();
ActionsDAG::NodeRawConstPtrs nodes; ActionsDAG::NodeRawConstPtrs nodes;
if (prewhere_info) if (prewhere_info)
@ -1343,19 +1342,7 @@ static ActionsDAGPtr buildFilterDAG(
for (const auto & node : added_filter_nodes.nodes) for (const auto & node : added_filter_nodes.nodes)
nodes.push_back(node); nodes.push_back(node);
std::unordered_map<std::string, ColumnWithTypeAndName> node_name_to_input_node_column; return ActionsDAG::buildFilterActionsDAG(nodes);
if (settings.allow_experimental_analyzer && query_info.planner_context)
{
const auto & table_expression_data = query_info.planner_context->getTableExpressionDataOrThrow(query_info.table_expression);
for (const auto & [column_identifier, column_name] : table_expression_data.getColumnIdentifierToColumnName())
{
const auto & column = table_expression_data.getColumnOrThrow(column_name);
node_name_to_input_node_column.emplace(column_identifier, ColumnWithTypeAndName(column.type, column_name));
}
}
return ActionsDAG::buildFilterActionsDAG(nodes, node_name_to_input_node_column);
} }
static void buildIndexes( static void buildIndexes(

View File

@ -506,8 +506,7 @@ Pipe ReadFromSystemNumbersStep::makePipe()
ActionsDAGPtr ReadFromSystemNumbersStep::buildFilterDAG() ActionsDAGPtr ReadFromSystemNumbersStep::buildFilterDAG()
{ {
std::unordered_map<std::string, ColumnWithTypeAndName> node_name_to_input_node_column; return ActionsDAG::buildFilterActionsDAG(filter_nodes.nodes);
return ActionsDAG::buildFilterActionsDAG(filter_nodes.nodes, node_name_to_input_node_column);
} }
void ReadFromSystemNumbersStep::checkLimits(size_t rows) void ReadFromSystemNumbersStep::checkLimits(size_t rows)

View File

@ -18,11 +18,7 @@ protected:
void setKeyConditionImpl(const ActionsDAG::NodeRawConstPtrs & nodes, ContextPtr context, const Block & keys) void setKeyConditionImpl(const ActionsDAG::NodeRawConstPtrs & nodes, ContextPtr context, const Block & keys)
{ {
std::unordered_map<std::string, DB::ColumnWithTypeAndName> node_name_to_input_column; auto filter_actions_dag = ActionsDAG::buildFilterActionsDAG(nodes);
for (const auto & column : keys.getColumnsWithTypeAndName())
node_name_to_input_column.insert({column.name, column});
auto filter_actions_dag = ActionsDAG::buildFilterActionsDAG(nodes, node_name_to_input_column);
key_condition = std::make_shared<const KeyCondition>( key_condition = std::make_shared<const KeyCondition>(
filter_actions_dag, filter_actions_dag,
context, context,