1#pragma once
2
3#include <string>
4#include <Core/Block.h>
5#include <DataStreams/IBlockInputStream.h>
6#include <Poco/Data/RecordSet.h>
7#include <Poco/Data/Session.h>
8#include <Poco/Data/Statement.h>
9#include <Core/ExternalResultDescription.h>
10
11
12namespace DB
13{
14/// Allows processing results of a query to ODBC source as a sequence of Blocks, simplifies chaining
15class ODBCBlockInputStream final : public IBlockInputStream
16{
17public:
18 ODBCBlockInputStream(
19 Poco::Data::Session && session_, const std::string & query_str, const Block & sample_block, const UInt64 max_block_size_);
20
21 String getName() const override { return "ODBC"; }
22
23 Block getHeader() const override { return description.sample_block.cloneEmpty(); }
24
25private:
26 Block readImpl() override;
27
28 Poco::Data::Session session;
29 Poco::Data::Statement statement;
30 Poco::Data::RecordSet result;
31 Poco::Data::RecordSet::Iterator iterator;
32
33 const UInt64 max_block_size;
34 ExternalResultDescription description;
35
36 Poco::Logger * log;
37};
38
39}
40