#include #include #include #include #include #include namespace DB { namespace ErrorCodes { extern const int BAD_ARGUMENTS; } std::string getClusterName(const IAST & node) { if (const ASTIdentifier * ast_id = typeid_cast(&node)) return ast_id->name; if (const ASTLiteral * ast_lit = typeid_cast(&node)) return ast_lit->value.safeGet(); if (const ASTFunction * ast_func = typeid_cast(&node)) { if (!ast_func->range.first || !ast_func->range.second) throw Exception("Illegal expression instead of cluster name.", ErrorCodes::BAD_ARGUMENTS); return String(ast_func->range.first, ast_func->range.second); } throw Exception("Illegal expression instead of cluster name.", ErrorCodes::BAD_ARGUMENTS); } }