Skip to content

Commit 03f2eb0

Browse files
authored
(DOCSP-25293): note behavior when using missing array (#2045)
* note behavior when using missing array * Copy review
1 parent d5aa999 commit 03f2eb0

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

source/reference/operator/aggregation/arrayElemAt.txt

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@ Definition
2727
<aggregation-expressions>` that resolves to an array.
2828

2929
The ``<idx>`` expression can be any valid :ref:`expression
30-
<aggregation-expressions>` that resolves to an integer:
31-
32-
- If the ``<idx>`` expression resolves to zero or a positive integer,
33-
:expression:`$arrayElemAt` returns the element at the ``idx``
34-
position, counting from the start of the array.
35-
36-
- If the ``<idx>`` expression resolves to a negative integer,
37-
:expression:`$arrayElemAt` returns the element at the ``idx``
38-
position, counting from the end of the array.
39-
40-
If ``idx`` exceeds the array bounds, :expression:`$arrayElemAt` does
41-
not return a result.
30+
<aggregation-expressions>` that resolves to an integer.
4231

4332
For more information on expressions, see
4433
:ref:`aggregation-expressions`.
4534

4635
Behavior
4736
--------
4837

49-
For more information on expressions, see
50-
:ref:`aggregation-expressions`.
38+
- If the ``<idx>`` expression resolves to zero or a positive integer,
39+
:expression:`$arrayElemAt` returns the element at the ``idx``
40+
position, counting from the start of the array.
41+
42+
- If the ``<idx>`` expression resolves to a negative integer,
43+
:expression:`$arrayElemAt` returns the element at the ``idx``
44+
position, counting from the end of the array.
45+
46+
- If ``idx`` exceeds the array bounds, :expression:`$arrayElemAt` does
47+
not return a result.
48+
49+
- If the ``<array>`` expression resolves to an undefined array,
50+
:expression:`$arrayElemAt` returns ``null``.
5151

5252
.. list-table::
5353
:header-rows: 1
@@ -65,6 +65,9 @@ For more information on expressions, see
6565
* - ``{ $arrayElemAt: [ [ 1, 2, 3 ], 15 ] }``
6666
-
6767

68+
* - ``{ $arrayElemAt: [ "$undefinedField", 0 ] }``
69+
- ``null``
70+
6871
Example
6972
-------
7073

0 commit comments

Comments
 (0)