mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
Using std::shared_ptr for functions and AST [#METR-21503].
This commit is contained in:
parent
9e553dec0a
commit
e336ba10eb
@ -271,7 +271,7 @@ private:
|
||||
|
||||
if (!sub_select_query.database)
|
||||
{
|
||||
sub_select_query.database = std::make_shared<ASTIdentifier>({}, distributed_storage.getRemoteDatabaseName(),
|
||||
sub_select_query.database = std::make_shared<ASTIdentifier>(StringRange(), distributed_storage.getRemoteDatabaseName(),
|
||||
ASTIdentifier::Database);
|
||||
|
||||
/// Поскольку был создан новый узел для БД, необходимо его вставить в список
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
|
||||
ASTPtr clone() const override
|
||||
{
|
||||
return std::make_shared<ASTEnumElement>({}, name, value);
|
||||
return std::make_shared<ASTEnumElement>(StringRange(), name, value);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -437,7 +437,7 @@ void ExpressionAnalyzer::addExternalStorage(ASTPtr & subquery_or_table_name)
|
||||
|
||||
Names column_names = external_storage->getColumnNamesList();
|
||||
for (const auto & name : column_names)
|
||||
exp_list->children.push_back(std::make_shared<ASTIdentifier>({}, name));
|
||||
exp_list->children.push_back(std::make_shared<ASTIdentifier>(StringRange(), name));
|
||||
|
||||
auto table_func = std::make_shared<ASTFunction>();
|
||||
select->table = table_func;
|
||||
@ -448,13 +448,13 @@ void ExpressionAnalyzer::addExternalStorage(ASTPtr & subquery_or_table_name)
|
||||
table_func->arguments = args;
|
||||
table_func->children.push_back(table_func->arguments);
|
||||
|
||||
auto address_lit = std::make_shared<ASTLiteral>({}, host_port);
|
||||
auto address_lit = std::make_shared<ASTLiteral>(StringRange(), host_port);
|
||||
args->children.push_back(address_lit);
|
||||
|
||||
auto database_lit = std::make_shared<ASTLiteral>({}, database);
|
||||
auto database_lit = std::make_shared<ASTLiteral>(StringRange(), database);
|
||||
args->children.push_back(database_lit);
|
||||
|
||||
auto table_lit = std::make_shared<ASTLiteral>({}, external_table_name);
|
||||
auto table_lit = std::make_shared<ASTLiteral>(StringRange(), external_table_name);
|
||||
args->children.push_back(table_lit);
|
||||
}
|
||||
else
|
||||
@ -768,7 +768,7 @@ static ASTPtr addTypeConversion(ASTLiteral * ast_, const String & type_name)
|
||||
func->arguments = exp_list;
|
||||
func->children.push_back(func->arguments);
|
||||
exp_list->children.emplace_back(ast.release());
|
||||
exp_list->children.emplace_back(std::make_shared<ASTLiteral>({}, type_name));
|
||||
exp_list->children.emplace_back(std::make_shared<ASTLiteral>(StringRange(), type_name));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -195,8 +195,8 @@ static ColumnsAndDefaults parseColumns(
|
||||
const auto data_type_ptr = columns.back().type.get();
|
||||
|
||||
default_expr_list->children.emplace_back(setAlias(
|
||||
makeASTFunction("CAST", std::make_shared<ASTIdentifier>({}, tmp_column_name),
|
||||
std::make_shared<ASTLiteral>({}, data_type_ptr->getName()), final_column_name));
|
||||
makeASTFunction("CAST", std::make_shared<ASTIdentifier>(StringRange(), tmp_column_name),
|
||||
std::make_shared<ASTLiteral>(StringRange(), data_type_ptr->getName()), final_column_name));
|
||||
default_expr_list->children.emplace_back(setAlias(col_decl.default_expression->clone(), tmp_column_name));
|
||||
}
|
||||
else
|
||||
@ -229,7 +229,7 @@ static ColumnsAndDefaults parseColumns(
|
||||
if (explicit_type->getName() != deduced_type->getName())
|
||||
{
|
||||
col_decl_ptr->default_expression = makeASTFunction("CAST", col_decl_ptr->default_expression,
|
||||
std::make_shared<ASTLiteral>({}, explicit_type->getName()));
|
||||
std::make_shared<ASTLiteral>(StringRange(), explicit_type->getName()));
|
||||
|
||||
col_decl_ptr->children.clear();
|
||||
col_decl_ptr->children.push_back(col_decl_ptr->type);
|
||||
|
@ -688,7 +688,7 @@ QueryProcessingStage::Enum InterpreterSelectQuery::executeFetchColumns()
|
||||
if (default_it != std::end(storage->column_defaults) && default_it->second.type == ColumnDefaultType::Alias)
|
||||
required_columns_expr_list->children.emplace_back(setAlias(default_it->second.expression->clone(), column));
|
||||
else
|
||||
required_columns_expr_list->children.emplace_back(std::make_shared<ASTIdentifier>({}, column));
|
||||
required_columns_expr_list->children.emplace_back(std::make_shared<ASTIdentifier>(StringRange(), column));
|
||||
}
|
||||
|
||||
alias_actions = ExpressionAnalyzer{required_columns_expr_list, context, storage, table_column_names}.getActions(true);
|
||||
|
@ -16,7 +16,7 @@ namespace
|
||||
{
|
||||
/// for string literal return its value
|
||||
if (const auto literal = typeid_cast<const ASTLiteral *>(expr.get()))
|
||||
return std::make_shared<ASTIdentifier>({}, safeGet<const String &>(literal->value));
|
||||
return std::make_shared<ASTIdentifier>(StringRange(), safeGet<const String &>(literal->value));
|
||||
|
||||
/// otherwise evaluate the expression
|
||||
Block block{};
|
||||
@ -33,7 +33,7 @@ namespace
|
||||
if (!typeid_cast<const DataTypeString *>(column_name_type.type.get()))
|
||||
throw Exception{"Expression must evaluate to a String"};
|
||||
|
||||
return std::make_shared<ASTIdentifier>({}, column_name_type.column->getDataAt(0).toString());
|
||||
return std::make_shared<ASTIdentifier>(StringRange(), column_name_type.column->getDataAt(0).toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ bool ParserCastExpression::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & ma
|
||||
expr_list_args = std::make_shared<ASTExpressionList>(StringRange{contents_begin, end});
|
||||
first_argument->setAlias({});
|
||||
expr_list_args->children.push_back(first_argument);
|
||||
expr_list_args->children.emplace_back(std::make_shared<ASTLiteral>({}, type));
|
||||
expr_list_args->children.emplace_back(std::make_shared<ASTLiteral>(StringRange(), type));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -239,8 +239,8 @@ void AlterCommands::validate(IStorage * table, const Context & context)
|
||||
const auto column_type_raw_ptr = command.data_type.get();
|
||||
|
||||
default_expr_list->children.emplace_back(setAlias(
|
||||
makeASTFunction("CAST", std::make_shared<ASTIdentifier>({}, tmp_column_name),
|
||||
std::make_shared<ASTLiteral>({}, Field(column_type_raw_ptr->getName()))),
|
||||
makeASTFunction("CAST", std::make_shared<ASTIdentifier>(StringRange(), tmp_column_name),
|
||||
std::make_shared<ASTLiteral>(StringRange(), Field(column_type_raw_ptr->getName()))),
|
||||
final_column_name));
|
||||
|
||||
default_expr_list->children.emplace_back(setAlias(command.default_expression->clone(), tmp_column_name));
|
||||
@ -293,8 +293,8 @@ void AlterCommands::validate(IStorage * table, const Context & context)
|
||||
const auto & column_type_ptr = column_it->type;
|
||||
|
||||
default_expr_list->children.emplace_back(setAlias(
|
||||
makeASTFunction("CAST", std::make_shared<ASTIdentifier>({}, tmp_column_name),
|
||||
std::make_shared<ASTLiteral>({}, Field(column_type_ptr->getName()))),
|
||||
makeASTFunction("CAST", std::make_shared<ASTIdentifier>(StringRange(), tmp_column_name),
|
||||
std::make_shared<ASTLiteral>(StringRange(), Field(column_type_ptr->getName()))),
|
||||
column_name));
|
||||
|
||||
default_expr_list->children.emplace_back(setAlias(col_def.second.expression->clone(), tmp_column_name));
|
||||
@ -339,7 +339,7 @@ void AlterCommands::validate(IStorage * table, const Context & context)
|
||||
}
|
||||
|
||||
command_ptr->default_expression = makeASTFunction("CAST", command_ptr->default_expression->clone(),
|
||||
std::make_shared<ASTLiteral>({}, Field(explicit_type->getName())));
|
||||
std::make_shared<ASTLiteral>(StringRange(), Field(explicit_type->getName())));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user