blob: 5fdbcc55a8aa44d816a5f8781a9ad7d0438a4773 (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#pragma once
#include <yql/essentials/sql/v1/ide/completion/core/environment.h>
#include <yql/essentials/sql/v1/ide/completion/core/input.h>
#include <yql/essentials/sql/v1/ide/completion/core/name.h>
#include <util/generic/ptr.h>
#include <util/generic/maybe.h>
#include <util/generic/string.h>
#include <util/generic/vector.h>
#include <util/generic/hash.h>
#include <util/generic/hash_set.h>
namespace NSQLComplete {
struct TClusterContext {
TString Provider;
TString Name;
friend bool operator==(const TClusterContext& lhs, const TClusterContext& rhs) = default;
};
struct TFunctionContext {
TString Name;
size_t ArgumentNumber = 0;
TMaybe<TString> Arg0 = Nothing();
TMaybe<TString> Arg1 = Nothing();
TMaybe<TClusterContext> Cluster = Nothing();
friend bool operator==(const TFunctionContext& lhs, const TFunctionContext& rhs) = default;
};
// TODO(YQL-19747): Try to refactor to use Map/Set data structures
struct TColumnContext {
TVector<TAliased<TTableId>> Tables;
TVector<TColumnId> Columns;
THashMap<TString, THashSet<TString>> WithoutByTableAlias;
[[nodiscard]] bool IsAsterisk() const;
TColumnContext ExtractAliased(TMaybe<TStringBuf> alias);
TColumnContext Renamed(TStringBuf alias) &&;
friend bool operator==(const TColumnContext& lhs, const TColumnContext& rhs) = default;
friend TColumnContext operator|(TColumnContext lhs, TColumnContext rhs);
static TColumnContext Asterisk();
};
struct TGlobalContext {
TMaybe<TClusterContext> Use;
TVector<TString> Names;
TMaybe<TFunctionContext> EnclosingFunction;
TMaybe<TColumnContext> Column;
};
// TODO(YQL-19747): Make it thread-safe to make ISqlCompletionEngine thread-safe.
class IGlobalAnalysis {
public:
using TPtr = THolder<IGlobalAnalysis>;
virtual ~IGlobalAnalysis() = default;
virtual TGlobalContext Analyze(TCompletionInput input, TEnvironment env) = 0;
};
IGlobalAnalysis::TPtr MakeGlobalAnalysis();
} // namespace NSQLComplete
|