ClickHouse/dbms/include/DB/Dictionaries/ODBCBlockInputStream.h

47 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
#include <DB/Core/Block.h>
#include <DB/DataStreams/IProfilingBlockInputStream.h>
#include <DB/Dictionaries/ExternalResultDescription.h>
#include <Poco/Data/Session.h>
#include <Poco/Data/Statement.h>
#include <Poco/Data/RecordSet.h>
#include <string>
namespace DB
{
/// Allows processing results of a query to ODBC source as a sequence of Blocks, simplifies chaining
class ODBCBlockInputStream final : public IProfilingBlockInputStream
{
public:
ODBCBlockInputStream(
Poco::Data::Session && session, const std::string & query_str, const Block & sample_block,
2016-12-08 02:49:04 +00:00
const std::size_t max_block_size);
String getName() const override { return "ODBC"; }
2016-12-08 02:49:04 +00:00
String getID() const override;
private:
2016-12-08 02:49:04 +00:00
Block readImpl() override;
static void insertDefaultValue(IColumn * const column, const IColumn & sample_column)
{
column->insertFrom(sample_column, 0);
}
Poco::Data::Session session;
Poco::Data::Statement statement;
Poco::Data::RecordSet result;
Poco::Data::RecordSet::Iterator iterator;
const std::size_t max_block_size;
ExternalResultDescription description;
};
}