1#pragma once
2
3#include <Parsers/IAST.h>
4#include <DataStreams/IBlockInputStream.h>
5#include <cstddef>
6#include <memory>
7
8
9namespace DB
10{
11
12struct BlockIO;
13class Context;
14
15/** Prepares an input stream which produce data containing in INSERT query
16 * Head of inserting data could be stored in INSERT ast directly
17 * Remaining (tail) data could be stored in input_buffer_tail_part
18 */
19class InputStreamFromASTInsertQuery : public IBlockInputStream
20{
21public:
22 InputStreamFromASTInsertQuery(const ASTPtr & ast,
23 ReadBuffer * input_buffer_tail_part,
24 const Block & header,
25 const Context & context,
26 const ASTPtr & input_function);
27
28 Block readImpl() override { return res_stream->read(); }
29 void readPrefixImpl() override { return res_stream->readPrefix(); }
30 void readSuffixImpl() override { return res_stream->readSuffix(); }
31
32 String getName() const override { return "InputStreamFromASTInsertQuery"; }
33
34 Block getHeader() const override { return res_stream->getHeader(); }
35
36private:
37 std::unique_ptr<ReadBuffer> input_buffer_ast_part;
38 std::unique_ptr<ReadBuffer> input_buffer_contacenated;
39
40 BlockInputStreamPtr res_stream;
41};
42
43}
44