You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[NOID] Fixes#3401: APOC Custom Procedures/Function new procedures working with Cluster (#3943) (#4030)
* [NOID] Fixes#3401: APOC Custom Procedures/Function new procedures working with Cluster (#3943)
* Fixes#3401: APOC Custom Procedures/Function new procedures working with Cluster
* removed unused imports
* changed writeTransaction to executeWrite
* [NOID] code formatting
Copy file name to clipboardExpand all lines: docs/asciidoc/modules/ROOT/pages/cypher-execution/cypher-based-procedures-functions.adoc
+60-38Lines changed: 60 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,19 +5,44 @@
5
5
6
6
7
7
8
-
I wanted for a long time to be able to register Cypher statements as proper procedures and functions, so that they become callable in a standalone way.
8
+
include::partial$systemdbonly.note.adoc[]
9
9
10
-
You can achieve that with the `apoc.custom.declareProcedure` and `apoc.custom.declareFunction` procedure calls.
11
-
Those register a given Cypher statement, prefixed with the `custom.*` namespace, overriding potentially existing ones, so you can redefine them as needed.
10
+
[WARNING]
11
+
====
12
+
Installing, updating or removing a custom Cypher statement is an eventually consistent operation.
13
+
Therefore, they are not immediately added/updated/removed,
14
+
but they have a refresh rate handled by the Apoc configuration `apoc.custom.procedures.refresh=<MILLISECONDS>`.
15
+
16
+
In case of a cluster environment,
17
+
the `apoc.custom.procedures.refresh` also replicate the procedures/functions to each cluster member.
NOTE: APOC provides also xref::overview/apoc.custom/apoc.custom.asFunction.adoc[apoc.custom.asFunction] and xref::overview/apoc.custom/apoc.custom.asProcedure.adoc[apoc.custom.asProcedure] procedures,
14
-
but they have been deprecated in favor of `apoc.custom.declare*`s.
36
+
I wanted for a long time to be able to register Cypher statements as proper procedures and functions, so that they become callable in a standalone way.
15
37
38
+
You can achieve that with the `apoc.custom.installProcedure` and `apoc.custom.installFunction` procedure calls.
39
+
Those register a given Cypher statement, prefixed with the `custom.*` namespace, overriding potentially existing ones, so you can redefine them as needed.
16
40
17
-
The first parameter of the `apoc.custom.declareProcedure` and `apoc.custom.declareFunction` procedures,
41
+
The first parameter of the `apoc.custom.installProcedure` and `apoc.custom.installFunction` procedures,
18
42
is the signature of the procedure/function you want to create.
19
-
This looks similar to the `signature` results returned by the `SHOW PROCEDURES YIELD signature` and `SHOW FUNCTIONS YIELD signature` cypher commands,
20
-
that is:
43
+
44
+
This looks similar to the `signature` results returned by the `SHOW PROCEDURES YIELD signature`, `SHOW FUNCTIONS YIELD signature` cypher commands, or by the `CALL apoc.help('<fun_or_procedure_name>') YIELD signature` procedure, just without the `?`.
- for a function: `nameFunction(firstParam = defaultValue :: typeParam , secondParam = defaultValue :: typeParam, ....) :: typeResult`
23
48
@@ -49,9 +74,9 @@ The type names are what you would expect and see in outputs of `dbms.procedures`
49
74
The default values are parsed as JSON.
50
75
51
76
.Type Names
52
-
The `typeParam` and `typeResult` in the signature parameter are what you would expect to see in outputs of `SHOW PROCEDURES`, `SHOW FUNCTIONS` or `CALL apoc.help('')`, just without the final `?`.
53
-
The following values are supported:
54
-
* FLOAT, DOUBLE, INT, INTEGER, NUMBER, LONG
77
+
The `typeParam` and `typeResult` in the signature parameter can be one of the following values:
78
+
79
+
* FLOAT, DOUBLE, INT, INTEGER, INTEGER | FLOAT, NUMBER, LONG
55
80
* TEXT, STRING
56
81
* BOOL, BOOLEAN
57
82
* POINT, GEO, GEOMETRY
@@ -66,21 +91,24 @@ The following values are supported:
66
91
NOTE: If you override procedures or functions you might need to call `call db.clearQueryCaches()` as lookups to internal id's are kept in compiled query plans.
67
92
68
93
69
-
== Custom Procedures with `apoc.custom.declareProcedure`
94
+
The following examples assume that we are on the `neo4j` database,
95
+
and we want to create the custom procedures/function in that database.
96
+
97
+
== Custom Procedures with `apoc.custom.installProcedure`
| "procedure" | "answer" | "Procedure that answer to the Ultimate Question of Life, the Universe, and Everything" | "read" | "RETURN $input as answer" | [["input","int","42"]] | [["answer","number"]] | <null>
| "procedure" | "answer" | "Procedure that answer to the Ultimate Question of Life, the Universe, and Everything" | "read" | "RETURN $input as answer" | [["input","int","42"]] | [["answer","integer \| float"]] | <null>
97
125
|===
98
126
99
127
100
-
== Remove a procedure `apoc.custom.removeProcedure`
128
+
== Remove a procedure `apoc.custom.dropProcedure`
101
129
102
-
The procedure `apoc.custom.removeProcedure` allows to delete the targeted custom procedure.
130
+
The procedure `apoc.custom.dropProcedure` allows to delete the targeted custom procedure, from a specific database (with `neo4j` as a default),
131
+
*after a time defined by the configuration `apoc.custom.procedures.refresh`*.
0 commit comments