Skip to content

Commit 06620cc

Browse files
committed
refactor: skip null check for parent and root fields
The null checks prevent arangodb from applying the reduce-extraction-to-projection optimization.
1 parent 1c74caa commit 06620cc

File tree

11 files changed

+232
-103
lines changed

11 files changed

+232
-103
lines changed

spec/regression/root-fields/tests/root-and-parent-with-collect/aql/q.aql

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ RETURN {
1616
IN v_root1.`children`[*].`children`[*][**]
1717
RETURN {
1818
"parent": { __cruddl_runtime_error_code: @var1, __cruddl_runtime_error: @var2 },
19-
"root": (IS_NULL(v_root1) ? null : {
19+
"root": {
2020
"name": v_root1.`name`
21-
})
21+
}
2222
}
2323
),
2424
"extensionGrandchildren": (
2525
FOR v_extensionGrandchild1
2626
IN v_root1.`children`[*].`extension`.`children`[*][**]
2727
RETURN {
2828
"parent": { __cruddl_runtime_error_code: @var3, __cruddl_runtime_error: @var4 },
29-
"root": (IS_NULL(v_root1) ? null : {
29+
"root": {
3030
"name": v_root1.`name`
31-
})
31+
}
3232
}
3333
)
3434
}
@@ -44,13 +44,12 @@ RETURN {
4444
)
4545
)[**]
4646
SORT (v_grandchild2.`obj`.`name`)
47-
LET v_root2 = v_grandchild2.`root`
4847
RETURN {
4948
"name": v_grandchild2.`obj`.`name`,
5049
"parent": { __cruddl_runtime_error_code: @var7, __cruddl_runtime_error: @var8 },
51-
"root": (IS_NULL(v_root2) ? null : {
52-
"name": v_root2.`name`
53-
})
50+
"root": {
51+
"name": v_grandchild2.`root`.`name`
52+
}
5453
}
5554
),
5655
"rootExtensionGrandchildren": (
@@ -64,13 +63,12 @@ RETURN {
6463
)
6564
)[**]
6665
SORT (v_extensionGrandchild2.`obj`.`name`)
67-
LET v_root3 = v_extensionGrandchild2.`root`
6866
RETURN {
6967
"name": v_extensionGrandchild2.`obj`.`name`,
7068
"parent": { __cruddl_runtime_error_code: @var11, __cruddl_runtime_error: @var12 },
71-
"root": (IS_NULL(v_root3) ? null : {
72-
"name": v_root3.`name`
73-
})
69+
"root": {
70+
"name": v_extensionGrandchild2.`root`.`name`
71+
}
7472
}
7573
)
7674
}

spec/regression/root-fields/tests/root-and-parent-with-collect/result.json

Lines changed: 145 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
"column": 17
1717
}
1818
],
19-
"path": ["allRoot2s", 0, "roots", 0, "grandchildren", 0, "parent"],
19+
"path": [
20+
"allRoot2s",
21+
0,
22+
"roots",
23+
0,
24+
"grandchildren",
25+
0,
26+
"parent"
27+
],
2028
"extensions": {
2129
"code": "NOT_SUPPORTED"
2230
}
@@ -29,7 +37,15 @@
2937
"column": 17
3038
}
3139
],
32-
"path": ["allRoot2s", 0, "roots", 1, "grandchildren", 0, "parent"],
40+
"path": [
41+
"allRoot2s",
42+
0,
43+
"roots",
44+
1,
45+
"grandchildren",
46+
0,
47+
"parent"
48+
],
3349
"extensions": {
3450
"code": "NOT_SUPPORTED"
3551
}
@@ -42,7 +58,15 @@
4258
"column": 17
4359
}
4460
],
45-
"path": ["allRoot2s", 0, "roots", 1, "grandchildren", 1, "parent"],
61+
"path": [
62+
"allRoot2s",
63+
0,
64+
"roots",
65+
1,
66+
"grandchildren",
67+
1,
68+
"parent"
69+
],
4670
"extensions": {
4771
"code": "NOT_SUPPORTED"
4872
}
@@ -55,7 +79,15 @@
5579
"column": 17
5680
}
5781
],
58-
"path": ["allRoot2s", 0, "roots", 1, "grandchildren", 2, "parent"],
82+
"path": [
83+
"allRoot2s",
84+
0,
85+
"roots",
86+
1,
87+
"grandchildren",
88+
2,
89+
"parent"
90+
],
5991
"extensions": {
6092
"code": "NOT_SUPPORTED"
6193
}
@@ -68,7 +100,15 @@
68100
"column": 17
69101
}
70102
],
71-
"path": ["allRoot2s", 0, "roots", 1, "grandchildren", 3, "parent"],
103+
"path": [
104+
"allRoot2s",
105+
0,
106+
"roots",
107+
1,
108+
"grandchildren",
109+
3,
110+
"parent"
111+
],
72112
"extensions": {
73113
"code": "NOT_SUPPORTED"
74114
}
@@ -81,7 +121,15 @@
81121
"column": 17
82122
}
83123
],
84-
"path": ["allRoot2s", 0, "roots", 1, "extensionGrandchildren", 0, "parent"],
124+
"path": [
125+
"allRoot2s",
126+
0,
127+
"roots",
128+
1,
129+
"extensionGrandchildren",
130+
0,
131+
"parent"
132+
],
85133
"extensions": {
86134
"code": "NOT_SUPPORTED"
87135
}
@@ -94,7 +142,15 @@
94142
"column": 17
95143
}
96144
],
97-
"path": ["allRoot2s", 0, "roots", 1, "extensionGrandchildren", 1, "parent"],
145+
"path": [
146+
"allRoot2s",
147+
0,
148+
"roots",
149+
1,
150+
"extensionGrandchildren",
151+
1,
152+
"parent"
153+
],
98154
"extensions": {
99155
"code": "NOT_SUPPORTED"
100156
}
@@ -107,7 +163,15 @@
107163
"column": 17
108164
}
109165
],
110-
"path": ["allRoot2s", 0, "roots", 1, "extensionGrandchildren", 2, "parent"],
166+
"path": [
167+
"allRoot2s",
168+
0,
169+
"roots",
170+
1,
171+
"extensionGrandchildren",
172+
2,
173+
"parent"
174+
],
111175
"extensions": {
112176
"code": "NOT_SUPPORTED"
113177
}
@@ -120,7 +184,15 @@
120184
"column": 17
121185
}
122186
],
123-
"path": ["allRoot2s", 0, "roots", 1, "extensionGrandchildren", 3, "parent"],
187+
"path": [
188+
"allRoot2s",
189+
0,
190+
"roots",
191+
1,
192+
"extensionGrandchildren",
193+
3,
194+
"parent"
195+
],
124196
"extensions": {
125197
"code": "NOT_SUPPORTED"
126198
}
@@ -133,7 +205,13 @@
133205
"column": 13
134206
}
135207
],
136-
"path": ["allRoot2s", 0, "rootGrandchildren", 0, "parent"],
208+
"path": [
209+
"allRoot2s",
210+
0,
211+
"rootGrandchildren",
212+
0,
213+
"parent"
214+
],
137215
"extensions": {
138216
"code": "NOT_SUPPORTED"
139217
}
@@ -146,7 +224,13 @@
146224
"column": 13
147225
}
148226
],
149-
"path": ["allRoot2s", 0, "rootGrandchildren", 1, "parent"],
227+
"path": [
228+
"allRoot2s",
229+
0,
230+
"rootGrandchildren",
231+
1,
232+
"parent"
233+
],
150234
"extensions": {
151235
"code": "NOT_SUPPORTED"
152236
}
@@ -159,7 +243,13 @@
159243
"column": 13
160244
}
161245
],
162-
"path": ["allRoot2s", 0, "rootGrandchildren", 2, "parent"],
246+
"path": [
247+
"allRoot2s",
248+
0,
249+
"rootGrandchildren",
250+
2,
251+
"parent"
252+
],
163253
"extensions": {
164254
"code": "NOT_SUPPORTED"
165255
}
@@ -172,7 +262,13 @@
172262
"column": 13
173263
}
174264
],
175-
"path": ["allRoot2s", 0, "rootGrandchildren", 3, "parent"],
265+
"path": [
266+
"allRoot2s",
267+
0,
268+
"rootGrandchildren",
269+
3,
270+
"parent"
271+
],
176272
"extensions": {
177273
"code": "NOT_SUPPORTED"
178274
}
@@ -185,7 +281,13 @@
185281
"column": 13
186282
}
187283
],
188-
"path": ["allRoot2s", 0, "rootGrandchildren", 4, "parent"],
284+
"path": [
285+
"allRoot2s",
286+
0,
287+
"rootGrandchildren",
288+
4,
289+
"parent"
290+
],
189291
"extensions": {
190292
"code": "NOT_SUPPORTED"
191293
}
@@ -198,7 +300,13 @@
198300
"column": 13
199301
}
200302
],
201-
"path": ["allRoot2s", 0, "rootExtensionGrandchildren", 0, "parent"],
303+
"path": [
304+
"allRoot2s",
305+
0,
306+
"rootExtensionGrandchildren",
307+
0,
308+
"parent"
309+
],
202310
"extensions": {
203311
"code": "NOT_SUPPORTED"
204312
}
@@ -211,7 +319,13 @@
211319
"column": 13
212320
}
213321
],
214-
"path": ["allRoot2s", 0, "rootExtensionGrandchildren", 1, "parent"],
322+
"path": [
323+
"allRoot2s",
324+
0,
325+
"rootExtensionGrandchildren",
326+
1,
327+
"parent"
328+
],
215329
"extensions": {
216330
"code": "NOT_SUPPORTED"
217331
}
@@ -224,7 +338,13 @@
224338
"column": 13
225339
}
226340
],
227-
"path": ["allRoot2s", 0, "rootExtensionGrandchildren", 2, "parent"],
341+
"path": [
342+
"allRoot2s",
343+
0,
344+
"rootExtensionGrandchildren",
345+
2,
346+
"parent"
347+
],
228348
"extensions": {
229349
"code": "NOT_SUPPORTED"
230350
}
@@ -237,7 +357,13 @@
237357
"column": 13
238358
}
239359
],
240-
"path": ["allRoot2s", 0, "rootExtensionGrandchildren", 3, "parent"],
360+
"path": [
361+
"allRoot2s",
362+
0,
363+
"rootExtensionGrandchildren",
364+
3,
365+
"parent"
366+
],
241367
"extensions": {
242368
"code": "NOT_SUPPORTED"
243369
}
@@ -385,4 +511,4 @@
385511
]
386512
}
387513
}
388-
}
514+
}

spec/regression/root-fields/tests/root-and-parent-with-intra-root-entity-collect/aql/test.aql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ RETURN {
1111
RETURN {
1212
"name": v_grandchild1.`name`,
1313
"parent": { __cruddl_runtime_error_code: @var1, __cruddl_runtime_error: @var2 },
14-
"root": (IS_NULL(v_root1) ? null : {
14+
"root": {
1515
"name": v_root1.`name`
16-
})
16+
}
1717
}
1818
),
1919
"extensionGrandchildren": (
@@ -22,9 +22,9 @@ RETURN {
2222
RETURN {
2323
"name": v_extensionGrandchild1.`name`,
2424
"parent": { __cruddl_runtime_error_code: @var3, __cruddl_runtime_error: @var4 },
25-
"root": (IS_NULL(v_root1) ? null : {
25+
"root": {
2626
"name": v_root1.`name`
27-
})
27+
}
2828
}
2929
)
3030
}

0 commit comments

Comments
 (0)