1#pragma once
2
3#include <Parsers/IAST.h>
4#include <Interpreters/IJoin.h>
5#include <Interpreters/PreparedSets.h>
6#include <Interpreters/ExpressionActions.h>
7
8
9namespace DB
10{
11
12class InterpreterSelectWithUnionQuery;
13
14
15/// Information on what to do when executing a subquery in the [GLOBAL] IN/JOIN section.
16struct SubqueryForSet
17{
18 /// The source is obtained using the InterpreterSelectQuery subquery.
19 BlockInputStreamPtr source;
20
21 /// If set, build it from result.
22 SetPtr set;
23 JoinPtr join;
24 /// Apply this actions to joined block.
25 ExpressionActionsPtr joined_block_actions;
26 Block sample_block; /// source->getHeader() + column renames
27
28 /// If set, put the result into the table.
29 /// This is a temporary table for transferring to remote servers for distributed query processing.
30 StoragePtr table;
31
32 void makeSource(std::shared_ptr<InterpreterSelectWithUnionQuery> & interpreter,
33 NamesWithAliases && joined_block_aliases_);
34
35 void setJoinActions(ExpressionActionsPtr actions);
36
37 bool insertJoinedBlock(Block & block);
38 void setTotals();
39
40private:
41 NamesWithAliases joined_block_aliases; /// Rename column from joined block from this list.
42
43 void renameColumns(Block & block);
44};
45
46/// ID of subquery -> what to do with it.
47using SubqueriesForSets = std::unordered_map<String, SubqueryForSet>;
48
49}
50