#pragma once #include #include namespace DB { /// TODO: Quite messy. class ASTQueryWithOnCluster { public: using Pos = IParser::Pos; /// Should be parsed from ON CLUSTER clause String cluster; /// new_database should be used by queries taht refer to default db /// and default_database is specified for remote server virtual ASTPtr getRewrittenASTWithoutOnCluster(const std::string & new_database = {}) const = 0; /// Returns a query prepared for execution on remote server std::string getRewrittenQueryWithoutOnCluster(const std::string & new_database = {}) const; void formatOnCluster(const IAST::FormatSettings & settings) const; /// Parses " CLUSTER [cluster|'cluster'] " clause static bool parse(Pos & pos, Pos end, std::string & cluster_str, Pos & max_parsed_pos, Expected & expected); virtual ~ASTQueryWithOnCluster() = default; }; }