1#pragma once
2
3#include <Storages/StorageXDBC.h>
4#include <TableFunctions/ITableFunction.h>
5#include <Poco/Util/AbstractConfiguration.h>
6#include <Common/XDBCBridgeHelper.h>
7#include <Common/config.h>
8
9namespace DB
10{
11/**
12 * Base class for table functions, that works over external bridge
13 * Xdbc (Xdbc connect string, table) - creates a temporary StorageXDBC.
14 */
15class ITableFunctionXDBC : public ITableFunction
16{
17private:
18 StoragePtr executeImpl(const ASTPtr & ast_function, const Context & context, const std::string & table_name) const override;
19
20 /* A factory method to create bridge helper, that will assist in remote interaction */
21 virtual BridgeHelperPtr createBridgeHelper(Context & context,
22 const Poco::Timespan & http_timeout_,
23 const std::string & connection_string_) const = 0;
24};
25
26class TableFunctionJDBC : public ITableFunctionXDBC
27{
28public:
29 static constexpr auto name = "jdbc";
30 std::string getName() const override
31 {
32 return name;
33 }
34
35private:
36 BridgeHelperPtr createBridgeHelper(Context & context,
37 const Poco::Timespan & http_timeout_,
38 const std::string & connection_string_) const override
39 {
40 return std::make_shared<XDBCBridgeHelper<JDBCBridgeMixin>>(context, http_timeout_, connection_string_);
41 }
42};
43
44class TableFunctionODBC : public ITableFunctionXDBC
45{
46public:
47 static constexpr auto name = "odbc";
48 std::string getName() const override
49 {
50 return name;
51 }
52
53private:
54 BridgeHelperPtr createBridgeHelper(Context & context,
55 const Poco::Timespan & http_timeout_,
56 const std::string & connection_string_) const override
57 {
58 return std::make_shared<XDBCBridgeHelper<ODBCBridgeMixin>>(context, http_timeout_, connection_string_);
59 }
60};
61}
62