mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <Storages/StorageXDBC.h>
|
|
#include <TableFunctions/ITableFunction.h>
|
|
#include <Access/AccessFlags.h>
|
|
#include <Poco/Util/AbstractConfiguration.h>
|
|
#include <Common/XDBCBridgeHelper.h>
|
|
#include <Common/config.h>
|
|
|
|
namespace DB
|
|
{
|
|
/**
|
|
* Base class for table functions, that works over external bridge
|
|
* Xdbc (Xdbc connect string, table) - creates a temporary StorageXDBC.
|
|
*/
|
|
class ITableFunctionXDBC : public ITableFunction
|
|
{
|
|
private:
|
|
StoragePtr executeImpl(const ASTPtr & ast_function, const Context & context, const std::string & table_name) const override;
|
|
|
|
/* A factory method to create bridge helper, that will assist in remote interaction */
|
|
virtual BridgeHelperPtr createBridgeHelper(Context & context,
|
|
const Poco::Timespan & http_timeout_,
|
|
const std::string & connection_string_) const = 0;
|
|
|
|
virtual AccessType getRequiredAccessType() const = 0;
|
|
};
|
|
|
|
class TableFunctionJDBC : public ITableFunctionXDBC
|
|
{
|
|
public:
|
|
static constexpr auto name = "jdbc";
|
|
std::string getName() const override
|
|
{
|
|
return name;
|
|
}
|
|
|
|
private:
|
|
BridgeHelperPtr createBridgeHelper(Context & context,
|
|
const Poco::Timespan & http_timeout_,
|
|
const std::string & connection_string_) const override
|
|
{
|
|
return std::make_shared<XDBCBridgeHelper<JDBCBridgeMixin>>(context, http_timeout_, connection_string_);
|
|
}
|
|
|
|
AccessType getRequiredAccessType() const override { return AccessType::jdbc; }
|
|
};
|
|
|
|
class TableFunctionODBC : public ITableFunctionXDBC
|
|
{
|
|
public:
|
|
static constexpr auto name = "odbc";
|
|
std::string getName() const override
|
|
{
|
|
return name;
|
|
}
|
|
|
|
private:
|
|
BridgeHelperPtr createBridgeHelper(Context & context,
|
|
const Poco::Timespan & http_timeout_,
|
|
const std::string & connection_string_) const override
|
|
{
|
|
return std::make_shared<XDBCBridgeHelper<ODBCBridgeMixin>>(context, http_timeout_, connection_string_);
|
|
}
|
|
|
|
AccessType getRequiredAccessType() const override { return AccessType::odbc; }
|
|
};
|
|
}
|