blob: dd4e2dc3d6856069552ada4d81fde5aa29af1c04 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#pragma once
#include <ostream>
#include <optional>
#include <Core/Names.h>
#include <base/types.h>
#include <Parsers/IAST_fwd.h>
namespace DB
{
class ASTIdentifier;
/// Information about table and column names extracted from ASTSelectQuery block. Do not include info from subselects.
struct RequiredSourceColumnsData
{
struct NameInfo
{
std::set<String> aliases;
size_t appears = 0;
void addInclusion(const String & alias)
{
if (!alias.empty())
aliases.insert(alias);
++appears;
}
};
std::unordered_map<String, NameInfo> required_names;
NameSet private_aliases; /// lambda aliases that should not be interpreted as required columns
NameSet complex_aliases; /// aliases to functions results: they are not required cause calculated by query itself
NameSet masked_columns; /// columns names masked by function aliases: we still need them in required columns
NameSet array_join_columns; /// Tech debt: we exclude ArrayJoin columns from general logic cause they have own logic outside
bool has_table_join = false;
bool has_array_join = false;
bool visit_index_hint = false;
bool addColumnAliasIfAny(const IAST & ast);
void addColumnIdentifier(const ASTIdentifier & node);
bool addArrayJoinAliasIfAny(const IAST & ast);
void addArrayJoinIdentifier(const ASTIdentifier & node);
NameSet requiredColumns() const;
size_t nameInclusion(const String & name) const;
};
std::ostream & operator << (std::ostream & os, const RequiredSourceColumnsData & cols);
}
|