Skip to content

Commit cdb8a6c

Browse files
vector ordering table
1 parent 4a9e924 commit cdb8a6c

File tree

1 file changed

+56
-6
lines changed

1 file changed

+56
-6
lines changed

modules/ROOT/pages/values-and-types/ordering-equality-comparison.adoc

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ For example, `1 > b` and `1 < b` are both `false` when `b` is NaN.
3535
* String values are compared for ordering using lexicographic order (e.g. `"x" < "xy"`).
3636
* Boolean values are compared for ordering such that `false < true`.
3737
* When comparing values for ordering, if one of the arguments is `null`, the result is always `null`.
38-
* xref:values-and-types/spatial.adoc[Spatial values] cannot be compared using the operators `\<=`, `<`,`>=`, `>`.
38+
* xref:values-and-types/spatial.adoc[Spatial values] and xref:values-and-types/vector.adoc[`VECTOR`] values cannot be compared using the operators `\<=`, `<`,`>=`, `>`.
3939
To compare spatial values within a specific range, use either the xref:functions/spatial.adoc#functions-withinBBox[`point.withinBBox()`] or the xref:functions/spatial.adoc#functions-point-wgs84-2d[`point()`] function.
4040

4141
[[value-hierarchy]]
@@ -146,11 +146,61 @@ If they have the same time and offset but different named time zones, they are s
146146
Since the length of a day, month, or year varies, Cypher does not define a strict ordering for durations.
147147
As a result, comparing two durations `(e.g, duration1 < duration2)` will always return `null`.
148148

149+
[role=label--new-2025.xx]
149150
[[ordering-vector]]
150-
=== Ordering vector values
151+
=== Vector values
151152

152-
Similar to spatial values, vectors cannot be compared using the operators (<, >, >= and <=)
153+
`VECTOR` values with a defined coordinate type and no dimension are ordered before values with only a defined dimension.
154+
Values with both a defined coordinate type and dimension are ordered according to the ordering of the vector coordinate types, listed in ascending order below:
153155

154-
Vectors of different coordinate type values are ordered by the coordinate type, this means the current order is: INTEGER8, INTEGER16, INTEGER32, INTEGER64, FLOAT32, FLOAT64
155-
Within the same coordinate type, vectors are then ordered by their dimension, with smaller first (e.g Vector(1024) before Vector(2048)).
156-
Vectors of the same coordinate type and dimension are then ordered pairwise (similar to how lists are ordered e.g Vector([1, 2]) is ordered before a Vector([2, 1])).
156+
* `INTEGER8`
157+
* `INTEGER16`
158+
* `INTEGER32`
159+
* `INTEGER64`
160+
* `FLOAT32`
161+
* `FLOAT64`
162+
163+
Within the same coordinate type, `VECTOR` values are ordered by their dimension, with smaller values first.
164+
`VECTOR` values of the same coordinate type and dimension are then ordered pairwise, similar to how `LIST` values are ordered.
165+
166+
.Ordering rules for `VECTOR` values
167+
[cols="3,3,2,6", options="header"]
168+
|===
169+
| A | B | Ordered As | Reason
170+
171+
| `VECTOR<FLOAT32>(12345)`
172+
| `VECTOR<FLOAT32>(123456)`
173+
| A < B
174+
| Same coordinate type, compare by dimension ascending.
175+
176+
| `VECTOR<INTEGER32>(1234)`
177+
| `VECTOR<FLOAT32>(1234)`
178+
| A < B
179+
| Coordinate type order: `INTEGER32` < `FLOAT32`
180+
181+
| `VECTOR<INTEGER8>`
182+
| `VECTOR(3)`
183+
| A < B
184+
| Coordinate type defined and no dimension < dimension defined and no coordinate type
185+
186+
| `VECTOR<INTEGER64>(123456)`
187+
| `VECTOR<FLOAT32>(3)`
188+
| A < B
189+
| Coordinate type order: `INTEGER64` < `FLOAT32`, compare coordinate type first.
190+
191+
| `VECTOR<FLOAT64>(1234)`
192+
| `VECTOR<FLOAT32>(1234)`
193+
| B < A
194+
| Coordinate type order: `FLOAT32` < `FLOAT64`
195+
196+
| `VECTOR<FLOAT32>([1, 2])`
197+
| `VECTOR<FLOAT32>([2, 1])`
198+
| A < B
199+
| Same coordinate type and dimension, pairwise value comparison.
200+
201+
| `VECTOR<INTEGER16>(1234)`
202+
| `LIST<INTEGER>`
203+
| A < B
204+
| `VECTOR` values are ordered before `LIST` values
205+
206+
|===

0 commit comments

Comments
 (0)