Skip to content

Commit 8f1afe8

Browse files
Add test for stages
1 parent 52f968b commit 8f1afe8

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

query/analyze/structure.feature

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,58 @@ Feature: Basic Analyze queries
184184
])
185185
"""
186186
Given transaction closes
187+
188+
189+
Scenario: All stages in a pipeline are present in the structure
190+
Given connection open read transaction for database: typedb
191+
When get answers of typeql analyze query
192+
"""
193+
match
194+
$p isa person;
195+
$q isa person;
196+
$n isa name == "John";
197+
insert
198+
$p has $n;
199+
delete
200+
has $n of $p;
201+
$q;
202+
update
203+
$p has $n;
204+
put
205+
$p has $n;
206+
distinct;
207+
match
208+
try { $p has ref $ref; };
209+
require $ref;
210+
select $ref, $n;
211+
reduce $ref_sum = sum($ref) groupby $n;
212+
sort $n desc;
213+
offset 1;
214+
limit 1;
215+
"""
216+
Then analyzed query pipeline structure is:
217+
"""
218+
Pipeline([
219+
Match(
220+
[Isa($p, person), Isa($q, person), Isa($n, name), Comparison($n, "John", ==)]
221+
),
222+
Insert([Has($p, $n)]),
223+
Delete([$q], [Has($p, $n)]),
224+
Update([Has($p, $n)]),
225+
Put([Has($p, $n)]),
226+
Distinct(),
227+
Match([
228+
Try([Has($p, $ref), Isa($ref, ref)])
229+
]),
230+
Require([$ref]),
231+
Select([$ref,$n]),
232+
Reduce(
233+
[ReduceAssign($ref_sum, Reducer(sum, [$ref]))],
234+
[$n]
235+
),
236+
Sort([desc($n)]),
237+
Offset(1),
238+
Limit(1)
239+
])
240+
"""
241+
Given transaction closes

0 commit comments

Comments
 (0)