Skip to content

Commit 1d2cf7d

Browse files
Introduce analyze options & add structure to GRPC row answers (#235)
## Release notes: usage and product changes Introduces analyze options, mostly for future use. And structure to GRPC row answers.
1 parent 3fc4c0f commit 1d2cf7d

File tree

12 files changed

+406
-4
lines changed

12 files changed

+406
-4
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
* @haikalpribadi
2-
3-
/dependencies/typedb/ @haikalpribadi @flyingsilverfin
4-
/dependencies/maven/ @haikalpribadi @lolski
1+
* @flyingsilverfin

grpc/java/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ java_grpc_library(
2222
"//proto:options-proto",
2323
"//proto:query-proto",
2424
"//proto:transaction-proto",
25+
"//proto:analyze-proto",
26+
"//proto:analyzed-conjunction-proto",
2527
"//proto:version-proto",
2628
],
2729
# TypeDB Core bundles JARs by maven coordinate, we can remove this when Core is rewritten in Rust

grpc/nodejs/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ ts_grpc_compile(
3838
"//proto:options-proto",
3939
"//proto:query-proto",
4040
"//proto:transaction-proto",
41+
"//proto:analyze-proto",
42+
"//proto:analyzed-conjunction-proto",
4143
"//proto:version-proto",
4244
]
4345
)

grpc/rust/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ rust_tonic_compile(
2525
"//proto:options-proto",
2626
"//proto:query-proto",
2727
"//proto:transaction-proto",
28+
"//proto:analyze-proto",
29+
"//proto:analyzed-conjunction-proto",
2830
"//proto:version-proto",
2931
]
3032
)

grpc/rust/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
fn main() -> std::io::Result<()> {
66
let protos = vec![
7+
"../../proto/analyze.proto",
78
"../../proto/answer.proto",
89
"../../proto/authentication.proto",
910
"../../proto/concept.proto",
1011
"../../proto/connection.proto",
12+
"../../proto/analyzed-conjunction.proto",
1113
"../../proto/database.proto",
1214
"../../proto/error.proto",
1315
"../../proto/migration.proto",

proto/BUILD

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ proto_library(
7979
name = "query-proto",
8080
srcs = ["query.proto"],
8181
deps = [
82+
":analyze-proto",
8283
":answer-proto",
8384
":concept-proto",
8485
":error-proto",
@@ -95,6 +96,7 @@ proto_library(
9596
name = "transaction-proto",
9697
srcs = ["transaction.proto"],
9798
deps = [
99+
":analyze-proto",
98100
":answer-proto",
99101
":concept-proto",
100102
":error-proto",
@@ -103,6 +105,26 @@ proto_library(
103105
]
104106
)
105107

108+
proto_library(
109+
name = "analyze-proto",
110+
srcs = ["analyze.proto"],
111+
deps = [
112+
":analyzed-conjunction-proto",
113+
":concept-proto",
114+
":error-proto",
115+
":options-proto",
116+
],
117+
)
118+
119+
proto_library(
120+
name = "analyzed-conjunction-proto",
121+
srcs = ["analyzed-conjunction.proto"],
122+
deps = [
123+
":answer-proto",
124+
":concept-proto",
125+
],
126+
)
127+
106128
proto_library(
107129
name = "version-proto",
108130
srcs = ["version.proto"],
@@ -114,9 +136,11 @@ proto_library(
114136
filegroup(
115137
name = "proto-raw-buffers",
116138
srcs = [
139+
"analyze.proto",
117140
"answer.proto",
118141
"concept.proto",
119142
"connection.proto",
143+
"analyzed-conjunction.proto",
120144
"options.proto",
121145
"query.proto",
122146
"transaction.proto",

proto/analyze.proto

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
syntax = "proto3";
6+
7+
import "proto/analyzed-conjunction.proto";
8+
import "proto/concept.proto";
9+
import "proto/error.proto";
10+
import "proto/options.proto";
11+
12+
package typedb.protocol;
13+
14+
message Analyze {
15+
16+
message Req {
17+
Options.Analyze options = 1;
18+
string query = 2;
19+
}
20+
21+
message Res {
22+
oneof result {
23+
Error err = 1;
24+
AnalyzedQuery ok = 2;
25+
}
26+
27+
message AnalyzedQuery {
28+
string source = 1;
29+
Pipeline query = 2;
30+
repeated Function preamble = 3;
31+
Fetch fetch = 4;
32+
33+
message Function {
34+
Pipeline body = 1;
35+
repeated AnalyzedConjunction.Variable arguments = 2;
36+
repeated AnalyzedConjunction.VariableAnnotations arguments_annotations = 3;
37+
repeated AnalyzedConjunction.VariableAnnotations return_annotations = 4;
38+
ReturnOperation return_operation = 5;
39+
40+
message ReturnOperation {
41+
oneof return_operation {
42+
ReturnOpStream stream = 1;
43+
ReturnOpSingle single = 2;
44+
ReturnOpCheck check = 3;
45+
ReturnOpReduce reduce = 4;
46+
};
47+
message ReturnOpStream {
48+
repeated AnalyzedConjunction.Variable variables = 1;
49+
}
50+
message ReturnOpSingle {
51+
string selector = 1;
52+
repeated AnalyzedConjunction.Variable variables = 2;
53+
}
54+
message ReturnOpCheck {}
55+
message ReturnOpReduce {
56+
repeated Reducer reducers = 1;
57+
}
58+
}
59+
}
60+
61+
message Pipeline {
62+
repeated AnalyzedConjunction conjunctions = 1;
63+
repeated PipelineStage stages = 2;
64+
map<uint32, VariableInfo> variable_info = 3;
65+
repeated AnalyzedConjunction.Variable outputs = 4;
66+
67+
message VariableInfo {
68+
string name = 1;
69+
}
70+
71+
message PipelineStage {
72+
oneof stage {
73+
Match match = 1;
74+
Insert insert = 2;
75+
Put put = 3;
76+
Update update = 4;
77+
Delete delete = 5;
78+
Select select = 6;
79+
Sort sort = 7;
80+
Require require = 8;
81+
Offset offset = 9;
82+
Limit limit = 10;
83+
Distinct distinct = 11;
84+
Reduce reduce = 12;
85+
}
86+
87+
message Match {
88+
uint32 block = 1;
89+
}
90+
message Insert {
91+
uint32 block = 1;
92+
}
93+
message Put {
94+
uint32 block = 1;
95+
}
96+
message Update {
97+
uint32 block = 1;
98+
}
99+
message Delete {
100+
uint32 block = 1;
101+
repeated AnalyzedConjunction.Variable deleted_variables = 2;
102+
}
103+
104+
message Select {
105+
repeated AnalyzedConjunction.Variable variables = 1;
106+
}
107+
message Sort {
108+
repeated SortVariable sort_variables = 1;
109+
message SortVariable {
110+
AnalyzedConjunction.Variable variable = 1;
111+
SortDirection direction = 2;
112+
enum SortDirection {
113+
ASC = 0;
114+
DESC = 1;
115+
}
116+
}
117+
}
118+
message Require {
119+
repeated AnalyzedConjunction.Variable variables = 1;
120+
}
121+
message Offset {
122+
uint64 offset = 1;
123+
}
124+
message Limit {
125+
uint64 limit = 1;
126+
}
127+
message Distinct {}
128+
message Reduce {
129+
repeated ReduceAssign reducers = 1;
130+
repeated AnalyzedConjunction.Variable groupby = 2;
131+
132+
message ReduceAssign {
133+
AnalyzedConjunction.Variable assigned = 1;
134+
Reducer reducer = 2;
135+
}
136+
}
137+
}
138+
}
139+
140+
message Reducer {
141+
string reducer = 1;
142+
repeated AnalyzedConjunction.Variable variables = 2;
143+
}
144+
145+
message Fetch {
146+
oneof node {
147+
Object object = 1;
148+
Fetch list = 2;
149+
Leaf leaf = 3;
150+
}
151+
message Object {
152+
map<string, Fetch> fetch = 1;
153+
}
154+
message Leaf {
155+
repeated ValueType annotations = 1;
156+
}
157+
}
158+
}
159+
}
160+
}

0 commit comments

Comments
 (0)