| 15 | } |
| 16 | |
| 17 | boost::intrusive_ptr<ASTDataType> dataTypeToAST(const DataTypePtr & data_type) |
| 18 | { |
| 19 | ParserDataType parser; |
| 20 | auto ast = parseQuery(parser, data_type->getName(), 0, DBMS_DEFAULT_MAX_PARSER_DEPTH, DBMS_DEFAULT_MAX_PARSER_BACKTRACKS); |
| 21 | |
| 22 | /// The dynamic cast is required here because ParserDataType can return |
| 23 | /// instance of a derived class, for example ASTTupleDataType. |
| 24 | auto ast_data_type = boost::dynamic_pointer_cast<ASTDataType>(ast); |
| 25 | if (!ast_data_type) |
| 26 | throw Exception(ErrorCodes::LOGICAL_ERROR, |
| 27 | "dataTypeToAST: unexpected AST node type for '{}'", data_type->getName()); |
| 28 | |
| 29 | return ast_data_type; |
| 30 | } |
| 31 | |
| 32 | } |