ClickHouse/src/TableFunctions/TableFunctionRemote.h

47 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
#include <TableFunctions/ITableFunction.h>
#include <Interpreters/Cluster.h>
#include <Interpreters/StorageID.h>
namespace DB
{
/* remote ('address', db, table) - creates a temporary StorageDistributed.
2017-04-16 15:00:33 +00:00
* To get the table structure, a DESC TABLE request is made to the remote server.
* For example
* SELECT count() FROM remote('example01-01-1', merge, hits) - go to `example01-01-1`, in the merge database, the hits table.
2017-08-08 20:58:18 +00:00
* An expression that generates a set of shards and replicas can also be specified as the host name - see below.
* Also, there is a cluster version of the function: cluster('existing_cluster_name', 'db', 'table')
*/
class TableFunctionRemote : public ITableFunction
{
public:
2019-08-03 11:02:40 +00:00
TableFunctionRemote(const std::string & name_, bool secure_ = false);
std::string getName() const override { return name; }
ColumnsDescription getActualTableStructure(ContextPtr context) const override;
bool needStructureConversion() const override { return false; }
private:
StoragePtr executeImpl(const ASTPtr & ast_function, ContextPtr context, const std::string & table_name, ColumnsDescription cached_columns) const override;
const char * getStorageTypeName() const override { return "Distributed"; }
void parseArguments(const ASTPtr & ast_function, ContextPtr context) override;
std::string name;
bool is_cluster_function;
std::string help_message;
2019-01-17 17:55:44 +00:00
bool secure;
ClusterPtr cluster;
StorageID remote_table_id = StorageID::createEmpty();
ASTPtr remote_table_function_ptr;
2020-12-21 03:19:05 +00:00
ASTPtr sharding_key = nullptr;
};
}