diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp index 038d52d63c2..27d866c976a 100644 --- a/src/Interpreters/InterpreterSelectQuery.cpp +++ b/src/Interpreters/InterpreterSelectQuery.cpp @@ -891,11 +891,11 @@ static SortDescription getSortDescription(const ASTSelectQuery & query, const Bl collator = std::make_shared(order_by_elem.collation->as().value.get()); if (order_by_elem.with_fill) { - auto column = result_block.findByName(name); + const auto *column = result_block.findByName(name); if (!column) column = source_block.findByName(name); if (!column) - for (auto &[alias, ast] : aliases) + for (const auto &[alias, ast] : aliases) if (name == ast->getColumnName()) if ((column = result_block.findByName(alias))) break;