Skip to content

Commit ad3da12

Browse files
Add reserved procedures/functions namespaces and naming rules (#320)
1 parent 4fd136c commit ad3da12

File tree

3 files changed

+135
-1
lines changed

3 files changed

+135
-1
lines changed

modules/ROOT/pages/extending-neo4j/aggregation-functions.adoc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ An aggregator class contains one method annotated with `@UserAggregationUpdate`
3232
The method annotated with `@UserAggregationUpdate` will be called multiple times and enables the class to aggregate data.
3333
When the aggregation is done, the method annotated with `@UserAggregationResult` will be called once and the result of the aggregation will be returned.
3434

35+
Particular things to note:
36+
37+
* All functions are annotated with `@UserAggregationFunction`.
38+
* The aggregation function name must be namespaced and is not allowed in reserved namespaces.
39+
* If a user-defined aggregation function is registered with the same name as a built-in function in a deprecated namespace, the built-in function is shadowed.
40+
3541
See xref:extending-neo4j/values-and-types.adoc[] for details on values and types.
3642

3743
For more details, see the Neo4j Javadocs for link:{org-neo4j-procedure-UserAggregationFunction}[`org.neo4j.procedure.UserAggregationFunction`^].
@@ -132,3 +138,53 @@ public class LongestStringTest
132138
}
133139
----
134140

141+
142+
[[reserved-function-namespaces]]
143+
== Reserved function namespaces
144+
145+
146+
List of reserved function namespaces and names::
147+
148+
* *
149+
* date
150+
* date.realtime
151+
* date.statement
152+
* date.transaction
153+
* date.truncate
154+
* datetime
155+
* datetime.fromepoch
156+
* datetime.fromepochmillis
157+
* datetime.realtime
158+
* datetime.statement
159+
* datetime.transaction
160+
* datetime.truncate
161+
* db.nameFromElementId
162+
* duration
163+
* duration.between
164+
* duration.inDays
165+
* duration.inMonths
166+
* duration.inSeconds
167+
* graph.byElementId
168+
* graph.byName
169+
* graph.names
170+
* graph.propertiesByName
171+
* localdatetime
172+
* localdatetime.realtime
173+
* localdatetime.statement
174+
* localdatetime.transaction
175+
* localdatetime.truncate
176+
* localtime
177+
* localtime.realtime
178+
* localtime.statement
179+
* localtime.transaction
180+
* localtime.truncate
181+
* point.distance
182+
* point.withinBBox
183+
* time
184+
* time.realtime
185+
* time.statement
186+
* time.transaction
187+
* time.truncate
188+
* vector.similarity.cosine
189+
* vector.similarity.euclidean
190+

modules/ROOT/pages/extending-neo4j/functions.adoc

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ RETURN org.neo4j.examples.join(collect(p.names))
3030
User-defined functions are created similarly to how procedures are created.
3131
But unlike procedures, they are annotated with `@UserFunction` and return a single value instead of a stream of values.
3232

33+
Particular things to note:
34+
35+
* All functions are annotated with `@UserFunction`.
36+
* The function name must be namespaced and is not allowed in reserved namespaces.
37+
* If a function is registered with the same name as a built-in function in a deprecated namespace, the built-in function is shadowed.
38+
3339
See xref:extending-neo4j/values-and-types.adoc[] for details on values and types.
3440

3541
For more details, see the link:{org-neo4j-procedure-UserFunction}[Neo4j Javadocs for `org.neo4j.procedure.UserFunction`^].
@@ -120,3 +126,52 @@ public class JoinTest {
120126
}
121127
----
122128

129+
130+
[[reserved-function-namespaces]]
131+
== Reserved function namespaces
132+
133+
List of reserved function namespaces::
134+
135+
* *
136+
* date
137+
* date.realtime
138+
* date.statement
139+
* date.transaction
140+
* date.truncate
141+
* datetime
142+
* datetime.fromepoch
143+
* datetime.fromepochmillis
144+
* datetime.realtime
145+
* datetime.statement
146+
* datetime.transaction
147+
* datetime.truncate
148+
* db.nameFromElementId
149+
* duration
150+
* duration.between
151+
* duration.inDays
152+
* duration.inMonths
153+
* duration.inSeconds
154+
* graph.byElementId
155+
* graph.byName
156+
* graph.names
157+
* graph.propertiesByName
158+
* localdatetime
159+
* localdatetime.realtime
160+
* localdatetime.statement
161+
* localdatetime.transaction
162+
* localdatetime.truncate
163+
* localtime
164+
* localtime.realtime
165+
* localtime.statement
166+
* localtime.transaction
167+
* localtime.truncate
168+
* point.distance
169+
* point.withinBBox
170+
* time
171+
* time.realtime
172+
* time.statement
173+
* time.transaction
174+
* time.truncate
175+
* vector.similarity.cosine
176+
* vector.similarity.euclidean
177+

modules/ROOT/pages/extending-neo4j/procedures.adoc

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ Particular things to note:
143143
* The procedure annotation can take three optional arguments: `name`, `mode`, and `eager`.
144144
** `name` is used to specify a different name for the procedure than the default generated, which is `class.path.nameOfMethod`.
145145
If `mode` is specified, `name` must be specified as well.
146+
** `name` is not allowed in a reserved namespace, and having a `name` without a namespace is deprecated behavior.
147+
** If a procedure is registered with the same name as a built-in procedure in a deprecated namespace, the built-in procedure is shadowed.
146148
** `mode` is used to declare the types of interactions that the procedure performs.
147149
A procedure fails if it attempts to execute database operations that violate its mode.
148150
The default `mode` is `READ`.
@@ -163,7 +165,7 @@ Particular things to note:
163165
MATCH (n)
164166
WHERE n.key = 'value'
165167
WITH n
166-
CALL deleteNeighbours(n, 'FOLLOWS')
168+
CALL example.deleteNeighbours(n, 'FOLLOWS')
167169
----
168170
This query can delete some of the nodes that are matched by the Cypher query, and the `n.key` lookup will fail.
169171
Marking this procedure as `eager` prevents this from causing an error in Cypher code.
@@ -273,3 +275,24 @@ public class MyProcedures {
273275
}
274276
275277
----
278+
279+
280+
[[reserved-procedure-namespaces]]
281+
== Reserved procedure namespaces
282+
283+
List of reserved procedure namespaces::
284+
285+
* cdc.*
286+
* date.*
287+
* datetime.*
288+
* db.*
289+
* dbms.*
290+
* duration.*
291+
* graph.*
292+
* internal.*
293+
* localdatetime.*
294+
* localtime.*
295+
* time.*
296+
* tx.*
297+
* unsupported.*
298+

0 commit comments

Comments
 (0)