mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 20:42:04 +00:00
32 lines
1005 B
C++
32 lines
1005 B
C++
#include <Parsers/ASTExpressionList.h>
|
|
#include <Parsers/ParserCreateQuery.h>
|
|
#include <Parsers/parseQuery.h>
|
|
#include <Interpreters/InterpreterCreateQuery.h>
|
|
#include <Interpreters/Context.h>
|
|
#include <TableFunctions/parseColumnsListForTableFunction.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int LOGICAL_ERROR;
|
|
}
|
|
|
|
ColumnsDescription parseColumnsListFromString(const std::string & structure, const Context & context)
|
|
{
|
|
ParserColumnDeclarationList parser;
|
|
const Settings & settings = context.getSettingsRef();
|
|
|
|
ASTPtr columns_list_raw = parseQuery(parser, structure, "columns declaration list", settings.max_query_size, settings.max_parser_depth);
|
|
|
|
auto * columns_list = dynamic_cast<ASTExpressionList *>(columns_list_raw.get());
|
|
if (!columns_list)
|
|
throw Exception("Could not cast AST to ASTExpressionList", ErrorCodes::LOGICAL_ERROR);
|
|
|
|
return InterpreterCreateQuery::getColumnsDescription(*columns_list, context, !settings.allow_suspicious_codecs);
|
|
}
|
|
|
|
}
|