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
|
|
|
|
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,
|
|
|
|
const StorageMetadataPtr & /*metadata_snapshot*/,
|
2020-09-20 17:52:17 +00:00
|
|
|
SelectQueryInfo & query_info,
|
2020-06-15 19:08:58 +00:00
|
|
|
const Context & context,
|
|
|
|
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,
|
|
|
|
const ColumnsDescription & columns_,
|
2020-06-17 16:39:58 +00:00
|
|
|
const Context & context_,
|
|
|
|
BridgeHelperPtr bridge_helper_);
|
2018-09-25 14:29:44 +00:00
|
|
|
|
2020-06-15 19:08:58 +00:00
|
|
|
BlockOutputStreamPtr write(const ASTPtr & query, const StorageMetadataPtr & /*metadata_snapshot*/, const Context & 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:
|
2018-09-25 14:29:44 +00:00
|
|
|
|
2019-08-24 21:20:20 +00:00
|
|
|
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,
|
2020-06-17 16:39:58 +00:00
|
|
|
const StorageMetadataPtr & metadata_snapshot,
|
2020-06-16 14:25:08 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
|
|
|
const Context & context,
|
|
|
|
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,
|
2020-06-17 16:39:58 +00:00
|
|
|
const StorageMetadataPtr & metadata_snapshot,
|
2020-06-16 14:25:08 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
|
|
|
const Context & context,
|
|
|
|
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
|
|
|
Block getHeaderBlock(const Names & column_names, const StorageMetadataPtr & metadata_snapshot) const override;
|
2019-08-24 21:20:20 +00:00
|
|
|
};
|
2018-09-25 14:29:44 +00:00
|
|
|
|
|
|
|
}
|