mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
28 lines
754 B
C++
28 lines
754 B
C++
|
#include <Storages/extractKeyExpressionList.h>
|
||
|
#include <Parsers/ASTFunction.h>
|
||
|
#include <Parsers/ASTExpressionList.h>
|
||
|
|
||
|
namespace DB
|
||
|
{
|
||
|
ASTPtr extractKeyExpressionList(const ASTPtr & node)
|
||
|
{
|
||
|
if (!node)
|
||
|
return std::make_shared<ASTExpressionList>();
|
||
|
|
||
|
const auto * expr_func = node->as<ASTFunction>();
|
||
|
|
||
|
if (expr_func && expr_func->name == "tuple")
|
||
|
{
|
||
|
/// Primary key is specified in tuple, extract its arguments.
|
||
|
return expr_func->arguments->clone();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
/// Primary key consists of one column.
|
||
|
auto res = std::make_shared<ASTExpressionList>();
|
||
|
res->children.push_back(node);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
}
|