2016-04-10 04:00:00 +00:00
|
|
|
#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);
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
String getName() const override { return "ODBC"; }
|
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
String getID() const override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-08 02:49:04 +00:00
|
|
|
Block readImpl() override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|