1 | #include "addTypeConversionToAST.h" |
---|---|
2 | |
3 | #include <Parsers/ASTLiteral.h> |
4 | #include <Parsers/ASTFunction.h> |
5 | #include <Parsers/ASTExpressionList.h> |
6 | #include <Parsers/ASTWithAlias.h> |
7 | |
8 | |
9 | namespace DB |
10 | { |
11 | |
12 | ASTPtr addTypeConversionToAST(ASTPtr && ast, const String & type_name) |
13 | { |
14 | auto func = makeASTFunction("CAST", ast, std::make_shared<ASTLiteral>(type_name)); |
15 | |
16 | if (ASTWithAlias * ast_with_alias = dynamic_cast<ASTWithAlias *>(ast.get())) |
17 | { |
18 | func->alias = ast_with_alias->alias; |
19 | func->prefer_alias_to_column_name = ast_with_alias->prefer_alias_to_column_name; |
20 | ast_with_alias->alias.clear(); |
21 | } |
22 | |
23 | return func; |
24 | } |
25 | |
26 | } |
27 |