2018-09-25 14:29:44 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Storages/StorageURL.h>
|
2021-03-12 21:12:34 +00:00
|
|
|
#include <Bridge/XDBCBridgeHelper.h>
|
2018-09-25 14:29:44 +00:00
|
|
|
|
2021-09-28 22:17:26 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
|
|
|
class Logger;
|
|
|
|
}
|
2019-08-24 21:20:20 +00:00
|
|
|
|
2018-09-25 14:29:44 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2019-08-24 21:20:20 +00:00
|
|
|
|
2018-09-25 14:29:44 +00:00
|
|
|
/** Implements storage in the XDBC database.
|
|
|
|
* Use ENGINE = xdbc(connection_string, table_name)
|
|
|
|
* Example ENGINE = odbc('dsn=test', table)
|
|
|
|
* Read only.
|
|
|
|
*/
|
2019-08-24 21:20:20 +00:00
|
|
|
class StorageXDBC : public IStorageURLBase
|
|
|
|
{
|
|
|
|
public:
|
2020-08-03 13:54:14 +00:00
|
|
|
Pipe read(
|
2020-06-15 19:08:58 +00:00
|
|
|
const Names & column_names,
|
2021-07-09 03:15:41 +00:00
|
|
|
const StorageSnapshotPtr & storage_snapshot,
|
2020-09-20 17:52:17 +00:00
|
|
|
SelectQueryInfo & query_info,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr context,
|
2020-06-15 19:08:58 +00:00
|
|
|
QueryProcessingStage::Enum processed_stage,
|
|
|
|
size_t max_block_size,
|
|
|
|
unsigned num_streams) override;
|
2018-09-25 14:29:44 +00:00
|
|
|
|
2020-06-16 14:25:08 +00:00
|
|
|
StorageXDBC(
|
|
|
|
const StorageID & table_id_,
|
|
|
|
const std::string & remote_database_name,
|
|
|
|
const std::string & remote_table_name,
|
2022-02-12 10:50:05 +00:00
|
|
|
ColumnsDescription columns_,
|
|
|
|
ConstraintsDescription constraints_,
|
2021-04-23 12:18:23 +00:00
|
|
|
const String & comment,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr context_,
|
2020-06-17 16:39:58 +00:00
|
|
|
BridgeHelperPtr bridge_helper_);
|
2018-09-25 14:29:44 +00:00
|
|
|
|
2021-07-23 14:25:35 +00:00
|
|
|
SinkToStoragePtr write(const ASTPtr & query, const StorageMetadataPtr & /*metadata_snapshot*/, ContextPtr context) override;
|
2020-04-28 00:56:44 +00:00
|
|
|
|
2020-10-14 12:19:29 +00:00
|
|
|
std::string getName() const override;
|
2019-08-24 21:20:20 +00:00
|
|
|
private:
|
|
|
|
BridgeHelperPtr bridge_helper;
|
|
|
|
std::string remote_database_name;
|
|
|
|
std::string remote_table_name;
|
2018-09-25 14:29:44 +00:00
|
|
|
|
2019-08-24 21:20:20 +00:00
|
|
|
Poco::Logger * log;
|
2018-09-25 14:29:44 +00:00
|
|
|
|
2019-08-24 21:20:20 +00:00
|
|
|
std::string getReadMethod() const override;
|
2018-09-25 14:29:44 +00:00
|
|
|
|
2020-06-16 14:25:08 +00:00
|
|
|
std::vector<std::pair<std::string, std::string>> getReadURIParams(
|
|
|
|
const Names & column_names,
|
2021-07-09 03:15:41 +00:00
|
|
|
const StorageSnapshotPtr & storage_snapshot,
|
2020-06-16 14:25:08 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr context,
|
2020-06-16 14:25:08 +00:00
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
size_t max_block_size) const override;
|
2018-09-25 14:29:44 +00:00
|
|
|
|
2020-06-16 14:25:08 +00:00
|
|
|
std::function<void(std::ostream &)> getReadPOSTDataCallback(
|
|
|
|
const Names & column_names,
|
2022-02-28 13:29:05 +00:00
|
|
|
const ColumnsDescription & columns_description,
|
2020-06-16 14:25:08 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr context,
|
2020-06-16 14:25:08 +00:00
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
size_t max_block_size) const override;
|
2018-09-25 14:29:44 +00:00
|
|
|
|
2021-07-09 03:15:41 +00:00
|
|
|
Block getHeaderBlock(const Names & column_names, const StorageSnapshotPtr & storage_snapshot) const override;
|
2022-02-28 13:29:05 +00:00
|
|
|
|
|
|
|
bool isColumnOriented() const override;
|
2019-08-24 21:20:20 +00:00
|
|
|
};
|
2018-09-25 14:29:44 +00:00
|
|
|
|
|
|
|
}
|