mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
Make clang-tidy happy
This commit is contained in:
parent
a2eb1fe9be
commit
e60415d07d
@ -327,9 +327,7 @@ void QueryFuzzer::fuzzOrderByList(IAST * ast)
|
||||
// Add element
|
||||
if (fuzz_rand() % 50 == 0)
|
||||
{
|
||||
auto pos = list->children.empty()
|
||||
? list->children.begin()
|
||||
: list->children.begin() + fuzz_rand() % list->children.size();
|
||||
auto * pos = list->children.empty() ? list->children.begin() : list->children.begin() + fuzz_rand() % list->children.size();
|
||||
auto col = getRandomColumnLike();
|
||||
if (col)
|
||||
{
|
||||
@ -373,9 +371,7 @@ void QueryFuzzer::fuzzColumnLikeExpressionList(IAST * ast)
|
||||
// Add element
|
||||
if (fuzz_rand() % 50 == 0)
|
||||
{
|
||||
auto pos = impl->children.empty()
|
||||
? impl->children.begin()
|
||||
: impl->children.begin() + fuzz_rand() % impl->children.size();
|
||||
auto * pos = impl->children.empty() ? impl->children.begin() : impl->children.begin() + fuzz_rand() % impl->children.size();
|
||||
auto col = getRandomColumnLike();
|
||||
if (col)
|
||||
impl->children.insert(pos, col);
|
||||
|
@ -344,11 +344,14 @@ void buildPrimaryKeyConfiguration(
|
||||
|
||||
auto identifier_name = key_names.front();
|
||||
|
||||
auto it = std::find_if(children.begin(), children.end(), [&](const ASTPtr & node)
|
||||
{
|
||||
const ASTDictionaryAttributeDeclaration * dict_attr = node->as<const ASTDictionaryAttributeDeclaration>();
|
||||
return dict_attr->name == identifier_name;
|
||||
});
|
||||
const auto * it = std::find_if(
|
||||
children.begin(),
|
||||
children.end(),
|
||||
[&](const ASTPtr & node)
|
||||
{
|
||||
const ASTDictionaryAttributeDeclaration * dict_attr = node->as<const ASTDictionaryAttributeDeclaration>();
|
||||
return dict_attr->name == identifier_name;
|
||||
});
|
||||
|
||||
if (it == children.end())
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ void ApplyWithGlobalVisitor::visit(ASTPtr & ast)
|
||||
if (auto * ast_with_alias = dynamic_cast<ASTWithAlias *>(child.get()))
|
||||
exprs[ast_with_alias->alias] = child;
|
||||
}
|
||||
for (auto it = node_union->list_of_selects->children.begin() + 1; it != node_union->list_of_selects->children.end(); ++it)
|
||||
for (auto * it = node_union->list_of_selects->children.begin() + 1; it != node_union->list_of_selects->children.end(); ++it)
|
||||
{
|
||||
if (auto * union_child = (*it)->as<ASTSelectWithUnionQuery>())
|
||||
visit(*union_child, exprs, with_expression_list);
|
||||
|
@ -562,7 +562,7 @@ ColumnsDescription InterpreterCreateQuery::getColumnsDescription(
|
||||
|
||||
ColumnsDescription res;
|
||||
auto name_type_it = column_names_and_types.begin();
|
||||
for (auto ast_it = columns_ast.children.begin(); ast_it != columns_ast.children.end(); ++ast_it, ++name_type_it)
|
||||
for (const auto * ast_it = columns_ast.children.begin(); ast_it != columns_ast.children.end(); ++ast_it, ++name_type_it)
|
||||
{
|
||||
ColumnDescription column;
|
||||
|
||||
|
@ -153,7 +153,7 @@ private:
|
||||
data.addTableColumns(identifier.name(), columns);
|
||||
|
||||
// QualifiedAsterisk's transformers start to appear at child 1
|
||||
for (auto it = qualified_asterisk->children.begin() + 1; it != qualified_asterisk->children.end(); ++it)
|
||||
for (auto * it = qualified_asterisk->children.begin() + 1; it != qualified_asterisk->children.end(); ++it)
|
||||
{
|
||||
IASTColumnsTransformer::transform(*it, columns);
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ void LogicalExpressionsOptimizer::cleanupOrExpressions()
|
||||
for (const auto & entry : garbage_map)
|
||||
{
|
||||
const auto * function = entry.first;
|
||||
auto first_erased = entry.second;
|
||||
auto * first_erased = entry.second;
|
||||
|
||||
auto & operands = getFunctionOperands(function);
|
||||
operands.erase(first_erased, operands.end());
|
||||
|
@ -154,7 +154,7 @@ static ColumnsDescription createColumnsDescription(const NamesAndTypesList & col
|
||||
/// but this produce endless recursion in gcc-11, and leads to SIGSEGV
|
||||
/// (see git blame for details).
|
||||
auto column_name_and_type = columns_name_and_type.begin();
|
||||
auto declare_column_ast = columns_definition->children.begin();
|
||||
const auto * declare_column_ast = columns_definition->children.begin();
|
||||
for (; column_name_and_type != columns_name_and_type.end(); column_name_and_type++, declare_column_ast++)
|
||||
{
|
||||
const auto & declare_column = (*declare_column_ast)->as<MySQLParser::ASTDeclareColumn>();
|
||||
|
@ -299,7 +299,7 @@ void TranslateQualifiedNamesMatcher::visit(ASTExpressionList & node, const ASTPt
|
||||
}
|
||||
|
||||
// QualifiedAsterisk's transformers start to appear at child 1
|
||||
for (auto it = qualified_asterisk->children.begin() + 1; it != qualified_asterisk->children.end(); ++it)
|
||||
for (const auto * it = qualified_asterisk->children.begin() + 1; it != qualified_asterisk->children.end(); ++it)
|
||||
{
|
||||
IASTColumnsTransformer::transform(*it, columns);
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ void removeUnneededColumnsFromSelectClause(ASTSelectQuery * select_query, const
|
||||
auto & children = select_query->interpolate()->children;
|
||||
if (!children.empty())
|
||||
{
|
||||
for (auto it = children.begin(); it != children.end();)
|
||||
for (auto * it = children.begin(); it != children.end();)
|
||||
{
|
||||
if (remove_columns.contains((*it)->as<ASTInterpolateElement>()->column))
|
||||
it = select_query->interpolate()->children.erase(it);
|
||||
|
@ -26,10 +26,10 @@ void applyTableOverrideToCreateQuery(const ASTTableOverride & override, ASTCreat
|
||||
if (!create_query->columns_list->columns)
|
||||
create_query->columns_list->set(create_query->columns_list->columns, std::make_shared<ASTExpressionList>());
|
||||
auto & dest_children = create_query->columns_list->columns->children;
|
||||
auto exists = std::find_if(dest_children.begin(), dest_children.end(), [&](ASTPtr node) -> bool
|
||||
{
|
||||
return node->as<ASTColumnDeclaration>()->name == override_column->name;
|
||||
});
|
||||
auto * exists = std::find_if(
|
||||
dest_children.begin(),
|
||||
dest_children.end(),
|
||||
[&](ASTPtr node) -> bool { return node->as<ASTColumnDeclaration>()->name == override_column->name; });
|
||||
/// For columns, only allow adding ALIAS (non-physical) for now.
|
||||
/// TODO: This logic should instead be handled by validation that is
|
||||
/// executed from InterpreterCreateQuery / InterpreterAlterQuery.
|
||||
@ -52,10 +52,10 @@ void applyTableOverrideToCreateQuery(const ASTTableOverride & override, ASTCreat
|
||||
if (!create_query->columns_list->indices)
|
||||
create_query->columns_list->set(create_query->columns_list->indices, std::make_shared<ASTExpressionList>());
|
||||
auto & dest_children = create_query->columns_list->indices->children;
|
||||
auto exists = std::find_if(dest_children.begin(), dest_children.end(), [&](ASTPtr node) -> bool
|
||||
{
|
||||
return node->as<ASTIndexDeclaration>()->name == override_index->name;
|
||||
});
|
||||
auto * exists = std::find_if(
|
||||
dest_children.begin(),
|
||||
dest_children.end(),
|
||||
[&](ASTPtr node) -> bool { return node->as<ASTIndexDeclaration>()->name == override_index->name; });
|
||||
if (exists == dest_children.end())
|
||||
dest_children.emplace_back(override_index_ast);
|
||||
else
|
||||
@ -72,10 +72,10 @@ void applyTableOverrideToCreateQuery(const ASTTableOverride & override, ASTCreat
|
||||
if (!create_query->columns_list->constraints)
|
||||
create_query->columns_list->set(create_query->columns_list->constraints, std::make_shared<ASTExpressionList>());
|
||||
auto & dest_children = create_query->columns_list->constraints->children;
|
||||
auto exists = std::find_if(dest_children.begin(), dest_children.end(), [&](ASTPtr node) -> bool
|
||||
{
|
||||
return node->as<ASTConstraintDeclaration>()->name == override_constraint->name;
|
||||
});
|
||||
auto * exists = std::find_if(
|
||||
dest_children.begin(),
|
||||
dest_children.end(),
|
||||
[&](ASTPtr node) -> bool { return node->as<ASTConstraintDeclaration>()->name == override_constraint->name; });
|
||||
if (exists == dest_children.end())
|
||||
dest_children.emplace_back(override_constraint_ast);
|
||||
else
|
||||
@ -92,10 +92,10 @@ void applyTableOverrideToCreateQuery(const ASTTableOverride & override, ASTCreat
|
||||
if (!create_query->columns_list->projections)
|
||||
create_query->columns_list->set(create_query->columns_list->projections, std::make_shared<ASTExpressionList>());
|
||||
auto & dest_children = create_query->columns_list->projections->children;
|
||||
auto exists = std::find_if(dest_children.begin(), dest_children.end(), [&](ASTPtr node) -> bool
|
||||
{
|
||||
return node->as<ASTProjectionDeclaration>()->name == override_projection->name;
|
||||
});
|
||||
auto * exists = std::find_if(
|
||||
dest_children.begin(),
|
||||
dest_children.end(),
|
||||
[&](ASTPtr node) -> bool { return node->as<ASTProjectionDeclaration>()->name == override_projection->name; });
|
||||
if (exists == dest_children.end())
|
||||
dest_children.emplace_back(override_projection_ast);
|
||||
else
|
||||
|
@ -82,7 +82,7 @@ void ASTColumnsListMatcher::updateTreeHashImpl(SipHash & hash_state) const
|
||||
void ASTColumnsListMatcher::appendColumnName(WriteBuffer & ostr) const
|
||||
{
|
||||
writeCString("COLUMNS(", ostr);
|
||||
for (auto it = column_list->children.begin(); it != column_list->children.end(); ++it)
|
||||
for (auto * it = column_list->children.begin(); it != column_list->children.end(); ++it)
|
||||
{
|
||||
if (it != column_list->children.begin())
|
||||
writeCString(", ", ostr);
|
||||
|
@ -217,7 +217,7 @@ void ASTColumnsExceptTransformer::transform(ASTs & nodes) const
|
||||
for (const auto & child : children)
|
||||
expected_columns.insert(child->as<const ASTIdentifier &>().name());
|
||||
|
||||
for (auto it = nodes.begin(); it != nodes.end();)
|
||||
for (auto * it = nodes.begin(); it != nodes.end();)
|
||||
{
|
||||
if (const auto * id = it->get()->as<ASTIdentifier>())
|
||||
{
|
||||
@ -234,7 +234,7 @@ void ASTColumnsExceptTransformer::transform(ASTs & nodes) const
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto it = nodes.begin(); it != nodes.end();)
|
||||
for (auto * it = nodes.begin(); it != nodes.end();)
|
||||
{
|
||||
if (const auto * id = it->get()->as<ASTIdentifier>())
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ void ASTFunction::appendColumnNameImpl(WriteBuffer & ostr) const
|
||||
if (parameters)
|
||||
{
|
||||
writeChar('(', ostr);
|
||||
for (auto it = parameters->children.begin(); it != parameters->children.end(); ++it)
|
||||
for (auto * it = parameters->children.begin(); it != parameters->children.end(); ++it)
|
||||
{
|
||||
if (it != parameters->children.begin())
|
||||
writeCString(", ", ostr);
|
||||
@ -59,7 +59,7 @@ void ASTFunction::appendColumnNameImpl(WriteBuffer & ostr) const
|
||||
writeChar('(', ostr);
|
||||
if (arguments)
|
||||
{
|
||||
for (auto it = arguments->children.begin(); it != arguments->children.end(); ++it)
|
||||
for (auto * it = arguments->children.begin(); it != arguments->children.end(); ++it)
|
||||
{
|
||||
if (it != arguments->children.begin())
|
||||
writeCString(", ", ostr);
|
||||
|
@ -52,7 +52,7 @@ void ASTTTLElement::formatImpl(const FormatSettings & settings, FormatState & st
|
||||
else if (mode == TTLMode::GROUP_BY)
|
||||
{
|
||||
settings.ostr << " GROUP BY ";
|
||||
for (auto it = group_by_key.begin(); it != group_by_key.end(); ++it)
|
||||
for (const auto * it = group_by_key.begin(); it != group_by_key.end(); ++it)
|
||||
{
|
||||
if (it != group_by_key.begin())
|
||||
settings.ostr << ", ";
|
||||
@ -62,7 +62,7 @@ void ASTTTLElement::formatImpl(const FormatSettings & settings, FormatState & st
|
||||
if (!group_by_assignments.empty())
|
||||
{
|
||||
settings.ostr << " SET ";
|
||||
for (auto it = group_by_assignments.begin(); it != group_by_assignments.end(); ++it)
|
||||
for (const auto * it = group_by_assignments.begin(); it != group_by_assignments.end(); ++it)
|
||||
{
|
||||
if (it != group_by_assignments.begin())
|
||||
settings.ostr << ", ";
|
||||
|
@ -594,7 +594,7 @@ public:
|
||||
|
||||
asts.reserve(asts.size() + n);
|
||||
|
||||
auto start = operands.begin() + operands.size() - n;
|
||||
auto * start = operands.begin() + operands.size() - n;
|
||||
asts.insert(asts.end(), std::make_move_iterator(start), std::make_move_iterator(operands.end()));
|
||||
operands.erase(start, operands.end());
|
||||
|
||||
|
@ -573,20 +573,17 @@ void AlterCommand::apply(StorageInMemoryMetadata & metadata, ContextPtr context)
|
||||
ErrorCodes::ILLEGAL_COLUMN);
|
||||
}
|
||||
|
||||
auto insert_it = constraints.end();
|
||||
auto * insert_it = constraints.end();
|
||||
constraints.emplace(insert_it, constraint_decl);
|
||||
metadata.constraints = ConstraintsDescription(constraints);
|
||||
}
|
||||
else if (type == DROP_CONSTRAINT)
|
||||
{
|
||||
auto constraints = metadata.constraints.getConstraints();
|
||||
auto erase_it = std::find_if(
|
||||
constraints.begin(),
|
||||
constraints.end(),
|
||||
[this](const ASTPtr & constraint_ast)
|
||||
{
|
||||
return constraint_ast->as<ASTConstraintDeclaration &>().name == constraint_name;
|
||||
});
|
||||
auto * erase_it = std::find_if(
|
||||
constraints.begin(),
|
||||
constraints.end(),
|
||||
[this](const ASTPtr & constraint_ast) { return constraint_ast->as<ASTConstraintDeclaration &>().name == constraint_name; });
|
||||
|
||||
if (erase_it == constraints.end())
|
||||
{
|
||||
|
@ -1152,7 +1152,7 @@ StorageS3Configuration StorageS3::getConfiguration(ASTs & engine_args, ContextPt
|
||||
"Storage S3 requires 1 to 5 arguments: url, [access_key_id, secret_access_key], name of used format and [compression_method].",
|
||||
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
||||
|
||||
auto header_it = StorageURL::collectHeaders(engine_args, configuration, local_context);
|
||||
auto * header_it = StorageURL::collectHeaders(engine_args, configuration, local_context);
|
||||
if (header_it != engine_args.end())
|
||||
engine_args.erase(header_it);
|
||||
|
||||
|
@ -979,7 +979,7 @@ ASTs::iterator StorageURL::collectHeaders(
|
||||
{
|
||||
ASTs::iterator headers_it = url_function_args.end();
|
||||
|
||||
for (auto arg_it = url_function_args.begin(); arg_it != url_function_args.end(); ++arg_it)
|
||||
for (auto * arg_it = url_function_args.begin(); arg_it != url_function_args.end(); ++arg_it)
|
||||
{
|
||||
const auto * headers_ast_function = (*arg_it)->as<ASTFunction>();
|
||||
if (headers_ast_function && headers_ast_function->name == "headers")
|
||||
@ -1065,7 +1065,7 @@ URLBasedDataSourceConfiguration StorageURL::getConfiguration(ASTs & args, Contex
|
||||
if (args.empty() || args.size() > 3)
|
||||
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, bad_arguments_error_message);
|
||||
|
||||
auto header_it = collectHeaders(args, configuration, local_context);
|
||||
auto * header_it = collectHeaders(args, configuration, local_context);
|
||||
if (header_it != args.end())
|
||||
args.erase(header_it);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user