2020-04-28 00:56:44 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/Block.h>
|
|
|
|
#include <DataStreams/IBlockOutputStream.h>
|
|
|
|
#include <Core/ExternalResultDescription.h>
|
2020-05-14 21:51:07 +00:00
|
|
|
#include <Parsers/IdentifierQuotingStyle.h>
|
2021-04-11 06:13:11 +00:00
|
|
|
#include <Interpreters/Context_fwd.h>
|
2021-05-07 10:37:11 +00:00
|
|
|
#include "ODBCConnectionFactory.h"
|
2021-03-22 11:40:29 +00:00
|
|
|
|
2020-04-28 00:56:44 +00:00
|
|
|
|
2020-05-05 23:42:44 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2021-03-22 11:40:29 +00:00
|
|
|
|
2020-05-05 23:42:44 +00:00
|
|
|
class ODBCBlockOutputStream : public IBlockOutputStream
|
|
|
|
{
|
2021-08-24 12:29:42 +00:00
|
|
|
using ValueType = ExternalResultDescription::ValueType;
|
2021-03-22 11:40:29 +00:00
|
|
|
|
2020-04-28 00:56:44 +00:00
|
|
|
public:
|
2021-03-22 11:40:29 +00:00
|
|
|
ODBCBlockOutputStream(
|
2021-05-07 11:18:49 +00:00
|
|
|
nanodbc::ConnectionHolderPtr connection_,
|
2021-03-22 11:40:29 +00:00
|
|
|
const std::string & remote_database_name_,
|
|
|
|
const std::string & remote_table_name_,
|
|
|
|
const Block & sample_block_,
|
2021-04-11 06:13:11 +00:00
|
|
|
ContextPtr local_context_,
|
2021-03-22 11:40:29 +00:00
|
|
|
IdentifierQuotingStyle quoting);
|
2020-04-28 00:56:44 +00:00
|
|
|
|
|
|
|
Block getHeader() const override;
|
|
|
|
void write(const Block & block) override;
|
|
|
|
|
|
|
|
private:
|
2021-03-22 11:40:29 +00:00
|
|
|
Poco::Logger * log;
|
|
|
|
|
2021-06-07 18:09:16 +00:00
|
|
|
nanodbc::ConnectionHolderPtr connection_holder;
|
2020-04-28 00:56:44 +00:00
|
|
|
std::string db_name;
|
|
|
|
std::string table_name;
|
|
|
|
Block sample_block;
|
2021-04-11 06:13:11 +00:00
|
|
|
ContextPtr local_context;
|
2020-05-14 21:51:07 +00:00
|
|
|
IdentifierQuotingStyle quoting;
|
2020-04-28 00:56:44 +00:00
|
|
|
|
|
|
|
ExternalResultDescription description;
|
|
|
|
};
|
|
|
|
|
2020-05-13 18:30:26 +00:00
|
|
|
}
|