blob: 1bc2c0ecf4e55a3fd67f4fc69810d5f71c73e401 (
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
|
#pragma once
#include <yql/essentials/sql/v1/complete/core/input.h>
#include <yql/essentials/sql/v1/complete/name/service/name_service.h>
#include <yql/essentials/sql/v1/lexer/lexer.h>
#include <library/cpp/threading/future/future.h>
#include <util/generic/string.h>
#include <util/generic/vector.h>
namespace NSQLComplete {
struct TCompletedToken {
TStringBuf Content;
size_t SourcePosition;
};
enum class ECandidateKind {
Keyword,
PragmaName,
TypeName,
FunctionName,
HintName,
FolderName,
TableName,
ClusterName,
UnknownName,
};
struct TCandidate {
ECandidateKind Kind;
TString Content;
friend bool operator==(const TCandidate& lhs, const TCandidate& rhs) = default;
};
struct TCompletion {
TCompletedToken CompletedToken;
TVector<TCandidate> Candidates;
};
class ISqlCompletionEngine {
public:
using TPtr = THolder<ISqlCompletionEngine>;
struct TConfiguration {
size_t Limit = 256;
};
virtual ~ISqlCompletionEngine() = default;
virtual TCompletion Complete(TCompletionInput input) = 0; // TODO(YQL-19747): migrate YDB CLI to CompleteAsync
virtual NThreading::TFuture<TCompletion> CompleteAsync(TCompletionInput input) = 0;
};
using TLexerSupplier = std::function<NSQLTranslation::ILexer::TPtr(bool ansi)>;
ISqlCompletionEngine::TPtr MakeSqlCompletionEngine(
TLexerSupplier lexer,
INameService::TPtr names,
ISqlCompletionEngine::TConfiguration configuration = {});
} // namespace NSQLComplete
|