forked from ServiceNow/picard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpicard.thrift
103 lines (81 loc) · 2.25 KB
/
picard.thrift
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
typedef string ColumnId
typedef string TableId
enum ColumnType {
BOOLEAN = 1,
TEXT = 2,
NUMBER = 3,
TIME = 4,
OTHERS = 5,
}
typedef string DBId
typedef i64 Token
typedef list<Token> InputIds
typedef i64 BatchId
struct SQLSchema {
1: map<ColumnId,string> columnNames,
2: map<ColumnId,ColumnType> columnTypes,
3: map<TableId,string> tableNames,
4: map<ColumnId,TableId> columnToTable,
5: map<TableId,list<ColumnId>> tableToColumns,
6: map<ColumnId,ColumnId> foreignKeys,
7: list<ColumnId> primaryKeys,
}
exception RegisterSQLSchemaException {
1: DBId dbId,
2: string message,
}
exception RegisterTokenizerException {
1: string message,
}
struct TokenizerNotRegisteredException {
1: string message,
}
struct TokenizerPrefixException {
1: string message,
}
struct ModeException {
1: string message,
}
union FeedFatalException {
1: TokenizerNotRegisteredException tokenizerNotRegisteredException,
2: TokenizerPrefixException tokenizerPrefixException,
3: ModeException modeException
}
exception FeedException {
1: FeedFatalException feedFatalException,
}
struct FeedParseFailure {
1: string input,
2: list<string> contexts,
3: string description,
}
struct FeedTimeoutFailure {
1: string message,
}
struct FeedPartialSuccess {}
struct FeedCompleteSuccess {
1: string leftover,
}
union FeedResult {
1: FeedParseFailure feedParseFailure,
2: FeedTimeoutFailure feedTimeoutFailure,
3: FeedPartialSuccess feedPartialSuccess,
4: FeedCompleteSuccess feedCompleteSuccess,
}
struct BatchFeedResult {
1: BatchId batchId,
2: Token topToken,
3: FeedResult feedResult,
}
enum Mode {
LEXING = 1,
PARSING_WITHOUT_GUARDS = 2,
PARSING_WITH_GUARDS = 3,
PARSING_WITH_GUARDS_AND_TYPE_CHECKING = 4,
}
service Picard {
void registerSQLSchema(1:DBId dbId, 2:SQLSchema sqlSchema) throws (1:RegisterSQLSchemaException fail),
void registerTokenizer(1:string jsonConfig) throws (1:RegisterTokenizerException fail),
FeedResult feed(1:InputIds inputIds, 2:Token token, 3:Mode mode) throws (1:FeedException fail),
list<BatchFeedResult> batchFeed(1:list<InputIds> inputIds, 2:list<list<Token>> topTokens, 3:Mode mode) throws (1:FeedException fail),
}