ClickHouse/src/TableFunctions/ITableFunctionXDBC.h

66 lines
1.9 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 <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;
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
const char * getStorageTypeName() const override { return "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
const char * getStorageTypeName() const override { return "ODBC"; }
2018-09-25 14:29:44 +00:00
};
2018-09-25 00:21:20 +00:00
}