mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Modify visitor
This commit is contained in:
parent
84884df595
commit
e84e05d849
@ -5,6 +5,7 @@
|
||||
#include <stack>
|
||||
|
||||
#include <Parsers/ASTFunction.h>
|
||||
#include <Parsers/ASTColumnDeclaration.h>
|
||||
#include <Parsers/ASTCreateFunctionQuery.h>
|
||||
#include <Parsers/ASTExpressionList.h>
|
||||
#include <Parsers/ASTIdentifier.h>
|
||||
|
@ -4,7 +4,9 @@
|
||||
#include <vector>
|
||||
#include <Common/typeid_cast.h>
|
||||
#include <Common/checkStackSize.h>
|
||||
#include <Parsers/IAST_fwd.h>
|
||||
#include <Parsers/DumpASTNode.h>
|
||||
#include <Parsers/ASTColumnDeclaration.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -80,7 +82,7 @@ private:
|
||||
template <bool with_dump>
|
||||
void visitChildren(T & ast)
|
||||
{
|
||||
for (auto & child : ast->children)
|
||||
const auto visit_child = [&](auto & child)
|
||||
{
|
||||
bool need_visit_child = false;
|
||||
if constexpr (need_child_accept_data)
|
||||
@ -90,6 +92,23 @@ private:
|
||||
|
||||
if (need_visit_child)
|
||||
visitImpl<with_dump>(child);
|
||||
};
|
||||
|
||||
for (auto & child : ast->children)
|
||||
{
|
||||
visit_child(child);
|
||||
}
|
||||
|
||||
if constexpr (std::same_as<T, ASTPtr>)
|
||||
{
|
||||
if (auto * col_decl = ast->template as<ASTColumnDeclaration>())
|
||||
{
|
||||
if (col_decl->default_expression)
|
||||
visit_child(col_decl->default_expression);
|
||||
|
||||
if (col_decl->default_expression)
|
||||
visit_child(col_decl->default_expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -470,7 +470,7 @@ ColumnsDescription InterpreterCreateQuery::getColumnsDescription(
|
||||
|
||||
for (const auto & ast : columns_ast.children)
|
||||
{
|
||||
auto & col_decl = ast->as<ASTColumnDeclaration &>();
|
||||
const auto & col_decl = ast->as<ASTColumnDeclaration &>();
|
||||
|
||||
if (col_decl.collation && !context_->getSettingsRef().compatibility_ignore_collation_in_create_table)
|
||||
{
|
||||
@ -523,13 +523,6 @@ ColumnsDescription InterpreterCreateQuery::getColumnsDescription(
|
||||
/// add column to postprocessing if there is a default_expression specified
|
||||
if (col_decl.default_expression)
|
||||
{
|
||||
// substitute possible UDFs with their definitions
|
||||
if (!UserDefinedSQLFunctionFactory::instance().empty())
|
||||
{
|
||||
UserDefinedSQLFunctionVisitor::Data data_user_defined_functions_visitor;
|
||||
UserDefinedSQLFunctionVisitor(data_user_defined_functions_visitor).visit(col_decl.default_expression);
|
||||
}
|
||||
|
||||
/** For columns with explicitly-specified type create two expressions:
|
||||
* 1. default_expression aliased as column name with _tmp suffix
|
||||
* 2. conversion of expression (1) to explicitly-specified type alias as column name
|
||||
@ -1166,6 +1159,13 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
|
||||
visitor.visit(*create.columns_list);
|
||||
}
|
||||
|
||||
// substitute possible UDFs with their definitions
|
||||
if (!UserDefinedSQLFunctionFactory::instance().empty())
|
||||
{
|
||||
UserDefinedSQLFunctionVisitor::Data data_user_defined_functions_visitor;
|
||||
UserDefinedSQLFunctionVisitor(data_user_defined_functions_visitor).visit(query_ptr);
|
||||
}
|
||||
|
||||
/// Set and retrieve list of columns, indices and constraints. Set table engine if needed. Rewrite query in canonical way.
|
||||
TableProperties properties = getTablePropertiesAndNormalizeCreateQuery(create);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user