diff --git a/dbms/src/Interpreters/ExpressionActions.cpp b/dbms/src/Interpreters/ExpressionActions.cpp index f99dd0d2c9d..e89df35cfdc 100644 --- a/dbms/src/Interpreters/ExpressionActions.cpp +++ b/dbms/src/Interpreters/ExpressionActions.cpp @@ -1006,9 +1006,6 @@ void ExpressionActions::compileFunctions([[maybe_unused]] const NameSet & final_ { switch (actions[i].type) { - case ExpressionAction::ADD_COLUMN: - break; - case ExpressionAction::REMOVE_COLUMN: current_dependents.erase(actions[i].source_name); /// poison every other column used after this point so that inlining chains do not cross it. @@ -1016,22 +1013,22 @@ void ExpressionActions::compileFunctions([[maybe_unused]] const NameSet & final_ dep.second.emplace(); break; - case ExpressionAction::COPY_COLUMN: - current_dependents[actions[i].source_name].emplace(); - break; - case ExpressionAction::PROJECT: current_dependents.clear(); for (const auto & proj : actions[i].projection) current_dependents[proj.first].emplace(); break; + case ExpressionAction::ADD_COLUMN: + case ExpressionAction::COPY_COLUMN: case ExpressionAction::ARRAY_JOIN: case ExpressionAction::JOIN: - /// assume these actions can read everything; all columns not removed before this point are poisoned. - for (size_t j = i; j--;) - current_dependents[actions[j].result_name].emplace(); + { + Names columns = actions[i].getNeededColumns(); + for (const auto & column : columns) + current_dependents[column].emplace(); break; + } case ExpressionAction::APPLY_FUNCTION: {