Fix more tests

This commit is contained in:
Amos Bird 2024-02-19 15:43:49 +08:00
parent 2b214aebd8
commit 49352732cc
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
2 changed files with 15 additions and 3 deletions

View File

@ -1430,12 +1430,24 @@ void ReadFromMergeTree::applyFilters()
{
if (!indexes)
{
/// Analyzer generates unique ColumnIdentifiers like __table1.__partition_id in filter nodes,
/// while key analysis still requires unqualified column names.
std::unordered_map<std::string, ColumnWithTypeAndName> node_name_to_input_node_column;
if (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));
}
}
/// NOTE: Currently we store two DAGs for analysis:
/// (1) SourceStepWithFilter::filter_nodes, (2) query_info.filter_actions_dag. Make sure there are consistent.
/// TODO: Get rid of filter_actions_dag in query_info after we move analysis of
/// parallel replicas and unused shards into optimization, similar to projection analysis.
query_info.filter_actions_dag = ActionsDAG::buildFilterActionsDAG(filter_nodes.nodes);
LOG_DEBUG(&::Poco::Logger::get("amosbird"), "filter_nodes.nodes.size() = {}", filter_nodes.nodes.size());
query_info.filter_actions_dag = ActionsDAG::buildFilterActionsDAG(filter_nodes.nodes, node_name_to_input_node_column);
buildIndexes(
indexes,

View File

@ -565,7 +565,7 @@ static const ActionsDAG::Node & cloneASTWithInversionPushDown(
if (const auto * column_const = typeid_cast<const ColumnConst *>(node.column.get()))
/// Re-generate column name for constant.
/// DAG form query (with enabled analyzer) uses suffixes for constants, like 1_UInt8.
/// DAG from PK does not use it. This is breakig match by column name sometimes.
/// DAG from PK does not use it. This breaks matching by column name sometimes.
/// Ideally, we should not compare manes, but DAG subtrees instead.
name = ASTLiteral(column_const->getDataColumn()[0]).getColumnName();
else