Skip to content

Commit 85b16cd

Browse files
type predicate expressions
1 parent 34d821f commit 85b16cd

File tree

4 files changed

+249
-119
lines changed

4 files changed

+249
-119
lines changed

modules/ROOT/pages/expressions/predicates/type-predicate-expressions.adoc

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,119 @@ RETURN val, val IS :: INTEGER AS isInteger
3838
2+d|Rows: 4
3939
|===
4040

41+
[role=label-new-2025.xx]
4142
[[type-predicate-vector]]
42-
== Type predicate expressions and VECTOR values
43+
=== VECTOR values
44+
45+
Whilst it is not possible to store a xref:values-and-types/vector.adoc[`VECTOR`] value without a coordinate type and dimension, it is possible to use the `VECTOR` supertype (encompassing all combinations of `VECTOR<TYPE>(DIMENSION)`) in type predicate expressions.
46+
47+
.Verify a `VECTOR<TYPE>(DIMENSION)` value against the `VECTOR` supertype
48+
[source, cypher]
49+
----
50+
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
51+
RETURN vector IS :: VECTOR AS isVector
52+
----
53+
54+
.Result
55+
[role="queryresult",options="header,footer",cols="1*<m"]
56+
|===
57+
| isVector
58+
59+
| true
60+
61+
1+d|Rows: 1
62+
|===
63+
64+
The same is true for the supertypes `VECTOR<TYPE>` (which encompasses all `VECTOR` values with the same coordinate type regardless of the dimension) and `VECTOR(DIMENSION)` (which encompasses all `VECTOR` values with the same dimension regardless of the coordinate type).
65+
66+
.Verify a `VECTOR<TYPE>(DIMENSION)` value against the `VECTOR<TYPE>` supertype
67+
[source, cypher]
68+
----
69+
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
70+
RETURN vector IS :: VECTOR<INTEGER8> AS isInteger8Vector
71+
----
72+
73+
.Result
74+
[role="queryresult",options="header,footer",cols="1*<m"]
75+
|===
76+
| isInteger8Vector
77+
78+
| true
79+
80+
1+d|Rows: 1
81+
|===
82+
83+
.Verify a `VECTOR<TYPE>(DIMENSION)` value against the `VECTOR(DIMENSION)` supertype
84+
[source, cypher]
85+
----
86+
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
87+
RETURN vector IS :: VECTOR(3) AS isDimension3Vector
88+
----
89+
90+
.Result
91+
[role="queryresult",options="header,footer",cols="1*<m"]
92+
|===
93+
| isDimension3Vector
94+
95+
| true
96+
97+
1+d|Rows: 1
98+
|===
99+
100+
If the coordinate type or dimension in the `VECTOR` does not match what is specified in the type predicate expression, the result will be `false`.
101+
102+
.Verify a `VECTOR<TYPE>(DIMENSION)` value against a `VECTOR` with a different dimension
103+
[source, cypher]
104+
----
105+
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
106+
RETURN vector IS :: VECTOR(5) AS isDimension5Vector
107+
----
108+
109+
.Result
110+
[role="queryresult",options="header,footer",cols="1*<m"]
111+
|===
112+
| isDimension5Vector
113+
114+
| false
115+
116+
1+d|Rows: 1
117+
|===
118+
119+
120+
.Verify a `VECTOR<TYPE>(DIMENSION)` value against a `VECTOR` with a different coordinate type
121+
[source, cypher]
122+
----
123+
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
124+
RETURN vector IS :: VECTOR<INTEGER16> AS isInteger16Vector
125+
----
126+
127+
.Result
128+
[role="queryresult",options="header,footer",cols="1*<m"]
129+
|===
130+
| isInteger16Vector
131+
132+
| false
133+
134+
1+d|Rows: 1
135+
|===
136+
137+
.Verify a `VECTOR<TYPE>(DIMENSION)` value against a `VECTOR` the same coordinate type and dimension
138+
[source, cypher]
139+
----
140+
WITH vector([1, 2, 3], 3, INTEGER8) AS vector
141+
RETURN vector IS :: VECTOR<INTEGER8>(3) AS isVector
142+
----
143+
144+
.Result
145+
[role="queryresult",options="header,footer",cols="1*<m"]
146+
|===
147+
| isVector
148+
149+
| true
150+
151+
1+d|Rows: 1
152+
|===
153+
43154

44155
[[type-predicate-not]]
45156
== Type predicate expressions with NOT

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ For example, `1 > b` and `1 < b` are both `false` when `b` is NaN.
3838
* 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

41-
[NOTE]
42-
See also xref:values-and-types/vector.adoc#ordering-vector[`VECTOR` values -> Ordering `VECTOR` values].
41+
For the ordering of `VECTOR` types, see xref:values-and-types/vector.adoc#ordering-vector[`VECTOR` values -> Ordering `VECTOR` types].
4342

4443
[[value-hierarchy]]
4544
=== Hierarchy of values

modules/ROOT/pages/values-and-types/property-structural-constructed.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Note that closed dynamic types (`INNER_TYPE_1 | INNER_TYPE_2...`) cannot be appe
111111
The `INNER_TYPE` of a `LIST` cannot be a `VECTOR` value.
112112

113113
[[type-normalization]]
114-
== Type Normalization
114+
== Type normalization
115115

116116
Cypher runs a normalization algorithm on all input types, simplifying the given type to a deterministic representation for equivalent types.
117117
Types are simplified to their default name (e.g. `BOOL` is simplified to `BOOLEAN`).
@@ -125,6 +125,8 @@ For example, given the closed dynamic type `BOOL | LIST<INT> | BOOLEAN | LIST<FL
125125
This normalization is run on types used in xref::expressions/predicates/type-predicate-expressions.adoc[type predicate expressions], and in xref::constraints/managing-constraints.adoc#create-property-type-constraints[property type constraints].
126126
Type normalization is also used to ensure the consistency of the output for the xref::functions/scalar.adoc#functions-valueType[valueType()] function.
127127

128+
For the normalization of `VECTOR` types, see xref:values-and-types/vector.adoc#vector-normalization[Vectors -> `VECTOR` type normalization].
129+
128130
[[ordering-of-types]]
129131
=== Ordering of types
130132
The ordering of types is as follows:

0 commit comments

Comments
 (0)