ClickHouse/dbms/TableFunctions/ITableFunctionXDBC.h

69 lines
2.0 KiB
C++
Raw Normal View History

2018-09-25 00:21:20 +00:00
#pragma once
#include <Storages/StorageXDBC.h>
2018-09-25 00:21:20 +00:00
#include <TableFunctions/ITableFunction.h>
#include <Access/AccessFlags.h>
2018-09-25 00:21:20 +00:00
#include <Poco/Util/AbstractConfiguration.h>
#include <Common/XDBCBridgeHelper.h>
#include <Common/config.h>
2018-09-25 00:21:20 +00:00
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:
2019-07-18 18:29:49 +00:00
StoragePtr executeImpl(const ASTPtr & ast_function, const Context & context, const std::string & table_name) const override;
2018-09-25 00:21:20 +00:00
/* 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;
2020-01-24 16:20:36 +00:00
virtual AccessType getRequiredAccessType() const = 0;
2018-09-25 00:21:20 +00:00
};
2018-09-25 14:29:44 +00:00
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_);
2018-09-25 14:29:44 +00:00
}
2020-01-24 16:20:36 +00:00
AccessType getRequiredAccessType() const override { return AccessType::jdbc; }
2018-09-25 14:29:44 +00:00
};
class TableFunctionODBC : public ITableFunctionXDBC
2018-09-25 14:29:44 +00:00
{
public:
static constexpr auto name = "odbc";
2018-09-25 14:29:44 +00:00
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_);
2018-09-25 14:29:44 +00:00
}
2020-01-24 16:20:36 +00:00
AccessType getRequiredAccessType() const override { return AccessType::odbc; }
2018-09-25 14:29:44 +00:00
};
2018-09-25 00:21:20 +00:00
}