ClickHouse/programs/odbc-bridge/ODBCSink.h

46 lines
1.0 KiB
C++
Raw Normal View History

2020-04-28 00:56:44 +00:00
#pragma once
#include <Core/Block.h>
2021-10-11 16:11:50 +00:00
#include <Processors/ISink.h>
2020-04-28 00:56:44 +00:00
#include <Core/ExternalResultDescription.h>
2020-05-14 21:51:07 +00:00
#include <Parsers/IdentifierQuotingStyle.h>
#include <Interpreters/Context_fwd.h>
#include "ODBCPooledConnectionFactory.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
2021-10-11 16:11:50 +00:00
class ODBCSink final : public ISink
2020-05-05 23:42:44 +00:00
{
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-10-11 16:11:50 +00:00
ODBCSink(
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_,
ContextPtr local_context_,
2021-03-22 11:40:29 +00:00
IdentifierQuotingStyle quoting);
2020-04-28 00:56:44 +00:00
2021-10-11 16:11:50 +00:00
String getName() const override { return "ODBCSink"; }
protected:
void consume(Chunk chunk) override;
2020-04-28 00:56:44 +00:00
private:
2024-01-23 17:04:50 +00:00
LoggerPtr log;
2021-03-22 11:40:29 +00:00
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;
ContextPtr local_context;
2020-05-14 21:51:07 +00:00
IdentifierQuotingStyle quoting;
2020-04-28 00:56:44 +00:00
ExternalResultDescription description;
};
}