2014-03-04 11:26:55 +00:00
|
|
|
#pragma once
|
2014-06-12 04:04:47 +00:00
|
|
|
|
2017-02-02 22:08:19 +00:00
|
|
|
#include <Poco/Logger.h>
|
2019-01-23 14:48:50 +00:00
|
|
|
#include <DataStreams/IBlockInputStream.h>
|
2017-05-23 20:04:42 +00:00
|
|
|
#include <Interpreters/ExpressionAnalyzer.h> /// SubqueriesForSets
|
2014-06-12 04:04:47 +00:00
|
|
|
|
2014-03-04 11:26:55 +00:00
|
|
|
|
2017-02-07 15:38:57 +00:00
|
|
|
namespace Poco { class Logger; }
|
|
|
|
|
2014-03-04 11:26:55 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-05-13 22:19:04 +00:00
|
|
|
/** Returns the data from the stream of blocks without changes, but
|
|
|
|
* in the `readPrefix` function or before reading the first block
|
|
|
|
* initializes all the passed sets.
|
2014-03-04 11:26:55 +00:00
|
|
|
*/
|
2019-01-23 14:48:50 +00:00
|
|
|
class CreatingSetsBlockInputStream : public IBlockInputStream
|
2014-03-04 11:26:55 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
CreatingSetsBlockInputStream(
|
2017-09-08 03:47:27 +00:00
|
|
|
const BlockInputStreamPtr & input,
|
2017-04-01 07:20:54 +00:00
|
|
|
const SubqueriesForSets & subqueries_for_sets_,
|
2018-04-19 21:34:04 +00:00
|
|
|
const SizeLimits & network_transfer_limits);
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
String getName() const override { return "CreatingSets"; }
|
|
|
|
|
2018-02-18 03:23:48 +00:00
|
|
|
Block getHeader() const override { return children.back()->getHeader(); }
|
2018-01-06 18:10:44 +00:00
|
|
|
|
2017-05-13 22:19:04 +00:00
|
|
|
/// Takes `totals` only from the main source, not from subquery sources.
|
2018-02-23 10:43:24 +00:00
|
|
|
Block getTotals() override;
|
2015-04-16 09:55:24 +00:00
|
|
|
|
2014-03-04 11:26:55 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
Block readImpl() override;
|
|
|
|
void readPrefixImpl() override;
|
2014-03-04 11:26:55 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
SubqueriesForSets subqueries_for_sets;
|
|
|
|
bool created = false;
|
2014-03-04 11:26:55 +00:00
|
|
|
|
2018-03-11 00:15:26 +00:00
|
|
|
SizeLimits network_transfer_limits;
|
2014-07-06 19:48:39 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t rows_to_transfer = 0;
|
|
|
|
size_t bytes_to_transfer = 0;
|
2014-07-06 19:48:39 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
using Logger = Poco::Logger;
|
|
|
|
Logger * log = &Logger::get("CreatingSetsBlockInputStream");
|
2014-03-04 11:26:55 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void createAll();
|
|
|
|
void createOne(SubqueryForSet & subquery);
|
2014-03-04 11:26:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|