2016-04-10 04:00:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Block.h>
|
|
|
|
#include <DataStreams/IProfilingBlockInputStream.h>
|
|
|
|
#include <Dictionaries/ExternalResultDescription.h>
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
#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:
|
2017-04-01 07:20:54 +00:00
|
|
|
ODBCBlockInputStream(
|
|
|
|
Poco::Data::Session && session, const std::string & query_str, const Block & sample_block,
|
2017-07-21 06:35:58 +00:00
|
|
|
const size_t max_block_size);
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "ODBC"; }
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getID() const override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
Block readImpl() override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
static void insertDefaultValue(IColumn * const column, const IColumn & sample_column)
|
|
|
|
{
|
|
|
|
column->insertFrom(sample_column, 0);
|
|
|
|
}
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Poco::Data::Session session;
|
|
|
|
Poco::Data::Statement statement;
|
|
|
|
Poco::Data::RecordSet result;
|
|
|
|
Poco::Data::RecordSet::Iterator iterator;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2017-07-21 06:35:58 +00:00
|
|
|
const size_t max_block_size;
|
2017-04-01 07:20:54 +00:00
|
|
|
ExternalResultDescription description;
|
2017-05-15 14:16:10 +00:00
|
|
|
|
|
|
|
Poco::Logger * log;
|
2016-04-10 04:00:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|