This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new a320401c9a Graph index, Graph constraint, Graph script and Create
property graph… (#9360)
a320401c9a is described below
commit a320401c9a8a21c0a85ed7f35a909431d0a6e7c7
Author: Bart Maertens <[email protected]>
AuthorDate: Thu Nov 12 10:07:29 2026 +0100
Graph index, Graph constraint, Graph script and Create property graph…
(#9360)
* Graph index, Graph constraint, Graph script and Create property graph
fail the action instead of stopping the workflow, fixes #9219
* Refuse a table used twice in Create property graph, add one error instead
of overwriting the count, share the index and constraint updates, test the
table cleanup, fixes #9219
---
.../workflow/actions/create-property-graph.adoc | 6 +-
.../pages/workflow/actions/graph-constraint.adoc | 4 +-
.../ROOT/pages/workflow/actions/graph-index.adoc | 6 +-
.../ROOT/pages/workflow/actions/graph-script.adoc | 4 +-
.../age/metadata/neo4j-graph-model/social.json | 83 ++++
.../main-9219-create-property-graph-fails.hwf | 339 +++++++++++++++
.../neo4j-connection/Test-wrong-login.json | 27 ++
.../main-9219-graph-constraint-fails.hwf | 397 ++++++++++++++++++
.../main-9219-graph-index-fails.hwf | 463 +++++++++++++++++++++
.../main-9219-graph-script-fails.hwf | 227 ++++++++++
.../hop/neo4j/actions/GraphSchemaUpdates.java | 106 +++++
.../neo4j/actions/constraint/Neo4jConstraint.java | 74 +---
.../neo4j/actions/cypherscript/CypherScript.java | 104 +++--
.../apache/hop/neo4j/actions/index/Neo4jIndex.java | 72 +---
.../propertygraph/ActionCreatePropertyGraph.java | 120 +++++-
.../propertygraph/PropertyGraphGenerator.java | 34 ++
.../hop/neo4j/actions/GraphActionFailuresTest.java | 285 +++++++++++++
.../ActionCreatePropertyGraphTest.java | 169 ++++++++
.../propertygraph/PropertyGraphGeneratorTest.java | 19 +
19 files changed, 2343 insertions(+), 196 deletions(-)
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/create-property-graph.adoc
b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/create-property-graph.adoc
index f12ae1b31f..3ad2ca3062 100644
---
a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/create-property-graph.adoc
+++
b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/create-property-graph.adoc
@@ -125,11 +125,9 @@ What this action passes on to the next action. See
xref:workflow/action-results.
|===
|Result|Value
|True|The property graph was created, with 0 errors, and with *Create missing
tables?* the tables that didn't exist yet. Tables that already exist are kept
as they are. With *Replace an existing graph?* an existing graph with the same
name is replaced.
-|False|The number of errors is 1. *Property graph name* is empty or holds a
character that can't be quoted (for example `"`), the *Graph model* doesn't
exist, the database can't be reached or doesn't support SQL/PGQ, the *Schema*
doesn't exist, a table is missing while *Create missing tables?* is unchecked,
or the graph already exists while *Replace an existing graph?* is unchecked.
+|False|The number of errors is 1. The *Relational database connection* is
empty or doesn't exist, *Property graph name* is empty or holds a character
that can't be quoted (for example `"`), the *Graph model* doesn't exist, the
database can't be reached or doesn't support SQL/PGQ, the *Schema* doesn't
exist, a table is missing while *Create missing tables?* is unchecked, or the
graph already exists while *Replace an existing graph?* is unchecked.
|Result files|Passed on unchanged.
|Result rows|Passed on unchanged.
|===
-WARNING: A *Relational database connection* that is empty or doesn't exist
doesn't make the action false: the workflow stops with an error, and no hop
from the action is followed.
-
-NOTE: The tables are created before the property graph. When the `CREATE
PROPERTY GRAPH` statement fails, for example on a database without SQL/PGQ, the
tables it created stay.
+NOTE: The tables are created before the property graph, and each statement is
committed on its own. When a later statement fails, for example `CREATE
PROPERTY GRAPH` on a database without SQL/PGQ, the action drops the tables it
created in that run. Tables that already existed are kept. If a table can't be
dropped, the error names the tables that stay.
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-constraint.adoc
b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-constraint.adoc
index 1fd692e4b6..0c8d5be462 100644
---
a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-constraint.adoc
+++
b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-constraint.adoc
@@ -64,11 +64,11 @@ What this action passes on to the next action. See
xref:workflow/action-results.
|===
|Result|Value
|True|All the constraint updates ran, with 0 errors. The drops run first, then
the creates. An empty list is also true.
-|False|The action is never false: see the WARNING.
+|False|The number of errors is 1. A constraint update can't be done: the
*Graph database connection* is empty, doesn't exist, can't be reached or
refuses the login, an update has no *Update type* (a blank type comes back as
CREATE when the workflow is loaded from its file), on Neo4j *Constraint name*
is empty or a create has no *Object property* (a drop only uses the name), on
Memgraph, which identifies a constraint by label and property, *Object name* or
*Object property* is empty, or t [...]
|Result files|Passed on unchanged.
|Result rows|Passed on unchanged.
|===
-WARNING: When a constraint update can't be done, the workflow stops with an
error and no hop from the action is followed: the *Graph database connection*
is empty, doesn't exist or can't be reached, an update has no *Update type* (a
blank type comes back as CREATE when the workflow is loaded from its file), on
Neo4j *Constraint name* is empty or a create has no *Object property* (a drop
only uses the name), on Memgraph, which identifies a constraint by label and
property, *Object name* o [...]
+NOTE: The updates run one by one. When one fails, the updates before it stay
done and the ones after it are not run. An update without *Update type* is
found before any update runs.
NOTE: On Neo4j the action creates with `IF NOT EXISTS` and drops with `IF
EXISTS`. Creating a constraint that already exists, or dropping one that
doesn't, does nothing and the action is still true. This is also the case when
a constraint with the same name exists on another label or property, or an
equivalent one exists with another name: nothing is created.
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-index.adoc
b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-index.adoc
index 26a9452260..1ab276c296 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-index.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-index.adoc
@@ -100,12 +100,12 @@ What this action passes on to the next action. See
xref:workflow/action-results.
[options="header", width="90%", cols="1,3"]
|===
|Result|Value
-|True|All the index updates ran, with 0 errors. The drops run first, then the
creates. An empty list is also true. An empty *Index name* is only fine where
the database doesn't use names: to create a RANGE index on Neo4j, which then
names the index, for range indexes on Memgraph, and for every index on
FalkorDB. In the other cases it stops the workflow, see the WARNING.
-|False|The action is never false: see the WARNING.
+|True|All the index updates ran, with 0 errors. The drops run first, then the
creates. An empty list is also true. An empty *Index name* is only fine where
the database doesn't use names: to create a RANGE index on Neo4j, which then
names the index, for range indexes on Memgraph, and for every index on
FalkorDB. In the other cases the action is false.
+|False|The number of errors is 1. An index update can't be done: the *Graph
database connection* is empty, doesn't exist, can't be reached or refuses the
login, an update has no *Update type*, an index is created without *Object
name* or *Properties* (on Memgraph and FalkorDB, which identify an index by
them, also when it is dropped, except a Memgraph vector index), a VECTOR index
is created with *Vector dimensions* that are empty, not a number or not
positive (a drop doesn't need them), [...]
|Result files|Passed on unchanged.
|Result rows|Passed on unchanged.
|===
-WARNING: When an index update can't be done, the workflow stops with an error
and no hop from the action is followed: the *Graph database connection* is
empty, doesn't exist or can't be reached, an update has no *Update type*, an
index is created without *Object name* or *Properties* (on Memgraph and
FalkorDB, which identify an index by them, also when it is dropped, except a
Memgraph vector index), a VECTOR index is created with *Vector dimensions* that
are empty, not a number or not po [...]
+NOTE: The updates run one by one. When one fails, the updates before it stay
done and the ones after it are not run. An update without *Update type* is
found before any update runs.
NOTE: On Neo4j and Apache AGE the action creates with `IF NOT EXISTS` and
drops with `IF EXISTS`. Creating an index that already exists, or dropping one
that doesn't, does nothing and the action is still true. On Neo4j this is also
the case when an index with the same name exists on another label or property,
or an equivalent one exists with another name: nothing is created.
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-script.adoc
b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-script.adoc
index f03c707f0e..5ba7682390 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-script.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/graph-script.adoc
@@ -77,9 +77,7 @@ What this action passes on to the next action. See
xref:workflow/action-results.
|===
|Result|Value
|True|All the statements ran, with 0 errors. An empty script is also true. A
query that returns rows is true too: the rows are not passed on.
-|False|The number of errors is 1. A statement fails, for example invalid
Cypher, a semicolon at the end of a line instead of on a new line (Neo4j then
gets two statements as one), or on Neo4j index or constraint changes and data
changes in the same script, in either order (`Tried to execute Write query
after executing Schema modification`, or the other way around). See
<<Transactions>> for the statements that are kept.
+|False|The number of errors is 1. The *Graph database connection* is empty,
doesn't exist, can't be reached or refuses the login, or a statement fails, for
example invalid Cypher, a semicolon at the end of a line instead of on a new
line (Neo4j then gets two statements as one), or on Neo4j index or constraint
changes and data changes in the same script, in either order (`Tried to execute
Write query after executing Schema modification`, or the other way around). See
<<Transactions>> for [...]
|Result files|Passed on unchanged.
|Result rows|Passed on unchanged.
|===
-
-WARNING: A *Graph database connection* that is empty, doesn't exist, can't be
reached or refuses the login doesn't make the action false: the workflow stops
with an error, and no hop from the action is followed.
diff --git a/integration-tests/age/metadata/neo4j-graph-model/social.json
b/integration-tests/age/metadata/neo4j-graph-model/social.json
new file mode 100644
index 0000000000..ad150033b2
--- /dev/null
+++ b/integration-tests/age/metadata/neo4j-graph-model/social.json
@@ -0,0 +1,83 @@
+{
+ "name": "social",
+ "description": "Property graph integration test model",
+ "nodes": [
+ {
+ "presentation": {
+ "x": 100,
+ "y": 100
+ },
+ "name": "Person",
+ "description": "",
+ "labels": [
+ "Person"
+ ],
+ "properties": [
+ {
+ "indexed": false,
+ "unique": false,
+ "name": "id",
+ "type": "Integer",
+ "mandatory": false,
+ "primary": true
+ },
+ {
+ "indexed": false,
+ "unique": false,
+ "name": "name",
+ "type": "String",
+ "mandatory": false,
+ "primary": false
+ }
+ ]
+ },
+ {
+ "presentation": {
+ "x": 400,
+ "y": 100
+ },
+ "name": "Company",
+ "description": "",
+ "labels": [
+ "Company"
+ ],
+ "properties": [
+ {
+ "indexed": false,
+ "unique": false,
+ "name": "code",
+ "type": "String",
+ "mandatory": false,
+ "primary": true
+ }
+ ]
+ }
+ ],
+ "relationships": [
+ {
+ "nodeSource": "Person",
+ "nodeTarget": "Person",
+ "name": "KNOWS",
+ "description": "",
+ "label": "KNOWS",
+ "properties": [
+ {
+ "indexed": false,
+ "unique": false,
+ "name": "since",
+ "type": "Integer",
+ "mandatory": false,
+ "primary": false
+ }
+ ]
+ },
+ {
+ "nodeSource": "Person",
+ "nodeTarget": "Company",
+ "name": "WORKS_AT",
+ "description": "",
+ "label": "WORKS_AT",
+ "properties": []
+ }
+ ]
+}
diff --git
a/integration-tests/age/tests/create-property-graph-fails-9219/main-9219-create-property-graph-fails.hwf
b/integration-tests/age/tests/create-property-graph-fails-9219/main-9219-create-property-graph-fails.hwf
new file mode 100644
index 0000000000..0916f76807
--- /dev/null
+++
b/integration-tests/age/tests/create-property-graph-fails-9219/main-9219-create-property-graph-fails.hwf
@@ -0,0 +1,339 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+ <name>main-9219-create-property-graph-fails</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>#9219: on PostgreSQL (no SQL/PGQ) Create property graph drops
the tables it created but keeps the ones that were there, and it is false on a
missing connection</description>
+ <extended_description/>
+ <workflow_version/>
+ <workflow_status>0</workflow_status>
+ <created_user>-</created_user>
+ <created_date>2026/11/07 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/11/07 12:00:00.000</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <intervalSeconds>0</intervalSeconds>
+ <intervalMinutes>60</intervalMinutes>
+ <hour>12</hour>
+ <minutes>0</minutes>
+ <weekDay>1</weekDay>
+ <DayOfMonth>1</DayOfMonth>
+ <parallel>N</parallel>
+ <xloc>64</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Drop test tables</name>
+ <description/>
+ <type>SQL</type>
+ <attributes/>
+ <sql>DROP TABLE IF EXISTS knows;
+DROP TABLE IF EXISTS works_at;
+DROP TABLE IF EXISTS person;
+DROP TABLE IF EXISTS company;</sql>
+ <useVariableSubstitution>F</useVariableSubstitution>
+ <sqlfromfile>F</sqlfromfile>
+ <sqlfilename/>
+ <sendOneStatement>F</sendOneStatement>
+ <connection>age-sql</connection>
+ <parallel>N</parallel>
+ <xloc>256</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Existing company table</name>
+ <description/>
+ <type>SQL</type>
+ <attributes/>
+ <sql>CREATE TABLE company (code VARCHAR(10) PRIMARY KEY)</sql>
+ <useVariableSubstitution>F</useVariableSubstitution>
+ <sqlfromfile>F</sqlfromfile>
+ <sqlfilename/>
+ <sendOneStatement>F</sendOneStatement>
+ <connection>age-sql</connection>
+ <parallel>N</parallel>
+ <xloc>448</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>No SQL/PGQ in PostgreSQL</name>
+ <description/>
+ <type>CREATE_PROPERTY_GRAPH</type>
+ <attributes/>
+ <connection>age-sql</connection>
+ <schema/>
+ <graph_name>social_graph_9219</graph_name>
+ <graph_model>social</graph_model>
+ <create_tables>Y</create_tables>
+ <replace_graph>N</replace_graph>
+ <node_tables>
+ </node_tables>
+ <edge_tables>
+ </edge_tables>
+ <parallel>N</parallel>
+ <xloc>640</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>No SQL/PGQ in PostgreSQL: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>640</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Created tables are dropped</name>
+ <description/>
+ <type>EVAL_TABLE_CONTENT</type>
+ <attributes/>
+ <connection>age-sql</connection>
+ <schemaname/>
+ <tablename/>
+ <success_condition>rows_count_equal</success_condition>
+ <limit>0</limit>
+ <is_custom_sql>Y</is_custom_sql>
+ <is_usevars>N</is_usevars>
+ <custom_sql>SELECT table_name FROM information_schema.tables WHERE
table_schema = 'public' AND table_name IN ('person', 'knows',
'works_at')</custom_sql>
+ <add_rows_result>N</add_rows_result>
+ <clear_result_rows>Y</clear_result_rows>
+ <parallel>N</parallel>
+ <xloc>832</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Existing table is kept</name>
+ <description/>
+ <type>EVAL_TABLE_CONTENT</type>
+ <attributes/>
+ <connection>age-sql</connection>
+ <schemaname/>
+ <tablename/>
+ <success_condition>rows_count_equal</success_condition>
+ <limit>1</limit>
+ <is_custom_sql>Y</is_custom_sql>
+ <is_usevars>N</is_usevars>
+ <custom_sql>SELECT table_name FROM information_schema.tables WHERE
table_schema = 'public' AND table_name IN ('company')</custom_sql>
+ <add_rows_result>N</add_rows_result>
+ <clear_result_rows>Y</clear_result_rows>
+ <parallel>N</parallel>
+ <xloc>1024</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Cleanup</name>
+ <description/>
+ <type>SQL</type>
+ <attributes/>
+ <sql>DROP TABLE IF EXISTS knows;
+DROP TABLE IF EXISTS works_at;
+DROP TABLE IF EXISTS person;
+DROP TABLE IF EXISTS company;</sql>
+ <useVariableSubstitution>F</useVariableSubstitution>
+ <sqlfromfile>F</sqlfromfile>
+ <sqlfilename/>
+ <sendOneStatement>F</sendOneStatement>
+ <connection>age-sql</connection>
+ <parallel>N</parallel>
+ <xloc>1216</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Unknown connection</name>
+ <description/>
+ <type>CREATE_PROPERTY_GRAPH</type>
+ <attributes/>
+ <connection>does-not-exist</connection>
+ <schema/>
+ <graph_name>social_graph_9219</graph_name>
+ <graph_model>social</graph_model>
+ <create_tables>Y</create_tables>
+ <replace_graph>N</replace_graph>
+ <node_tables>
+ </node_tables>
+ <edge_tables>
+ </edge_tables>
+ <parallel>N</parallel>
+ <xloc>1408</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Unknown connection: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>1408</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Empty connection</name>
+ <description/>
+ <type>CREATE_PROPERTY_GRAPH</type>
+ <attributes/>
+ <connection/>
+ <schema/>
+ <graph_name>social_graph_9219</graph_name>
+ <graph_model>social</graph_model>
+ <create_tables>Y</create_tables>
+ <replace_graph>N</replace_graph>
+ <node_tables>
+ </node_tables>
+ <edge_tables>
+ </edge_tables>
+ <parallel>N</parallel>
+ <xloc>1600</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Empty connection: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>1600</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Success</name>
+ <description/>
+ <type>SUCCESS</type>
+ <attributes/>
+ <parallel>N</parallel>
+ <xloc>1792</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>Drop test tables</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>Drop test tables</from>
+ <to>Existing company table</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Existing company table</from>
+ <to>No SQL/PGQ in PostgreSQL</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>No SQL/PGQ in PostgreSQL</from>
+ <to>No SQL/PGQ in PostgreSQL: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>No SQL/PGQ in PostgreSQL</from>
+ <to>Created tables are dropped</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Created tables are dropped</from>
+ <to>Existing table is kept</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Existing table is kept</from>
+ <to>Cleanup</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Cleanup</from>
+ <to>Unknown connection</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Unknown connection</from>
+ <to>Unknown connection: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Unknown connection</from>
+ <to>Empty connection</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Empty connection</from>
+ <to>Empty connection: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Empty connection</from>
+ <to>Success</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git
a/integration-tests/neo4j/metadata/neo4j-connection/Test-wrong-login.json
b/integration-tests/neo4j/metadata/neo4j-connection/Test-wrong-login.json
new file mode 100644
index 0000000000..019e9f5feb
--- /dev/null
+++ b/integration-tests/neo4j/metadata/neo4j-connection/Test-wrong-login.json
@@ -0,0 +1,27 @@
+{
+ "server": "${NEO_HOSTNAME}",
+ "browserPort": "7474",
+ "databaseName": "",
+ "manualUrls": [],
+ "automaticVariable": "",
+ "usingEncryption": false,
+ "routing": true,
+ "password": "wrong-password",
+ "usingEncryptionVariable": "",
+ "maxTransactionRetryTime": "",
+ "connectionLivenessCheckTimeout": "",
+ "connectionTimeout": "",
+ "connectionAcquisitionTimeout": "",
+ "trustAllCertificatesVariable": "",
+ "maxConnectionLifetime": "",
+ "routingVariable": "",
+ "automatic": false,
+ "routingPolicy": "",
+ "boltPort": "${NEO_PORT}",
+ "trustAllCertificates": false,
+ "version4": true,
+ "name": "Test-wrong-login",
+ "maxConnectionPoolSize": "",
+ "username": "hop-it-no-such-user",
+ "version4Variable": ""
+}
\ No newline at end of file
diff --git
a/integration-tests/neo4j/tests/neo4j-action-failures-9219/main-9219-graph-constraint-fails.hwf
b/integration-tests/neo4j/tests/neo4j-action-failures-9219/main-9219-graph-constraint-fails.hwf
new file mode 100644
index 0000000000..fc4d0d64c6
--- /dev/null
+++
b/integration-tests/neo4j/tests/neo4j-action-failures-9219/main-9219-graph-constraint-fails.hwf
@@ -0,0 +1,397 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+ <name>main-9219-graph-constraint-fails</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>#9219: every failing Graph constraint makes the action false,
so its failure hop is followed</description>
+ <extended_description/>
+ <workflow_version/>
+ <workflow_status>0</workflow_status>
+ <created_user>-</created_user>
+ <created_date>2026/11/07 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/11/07 12:00:00.000</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <intervalSeconds>0</intervalSeconds>
+ <intervalMinutes>60</intervalMinutes>
+ <hour>12</hour>
+ <minutes>0</minutes>
+ <weekDay>1</weekDay>
+ <DayOfMonth>1</DayOfMonth>
+ <parallel>N</parallel>
+ <xloc>64</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>cleanup-database.hwf</name>
+ <description/>
+ <type>WORKFLOW</type>
+ <attributes/>
+ <run_configuration>local</run_configuration>
+ <filename>${PROJECT_HOME}/tests/shared/cleanup-database.hwf</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Nothing</loglevel>
+ <wait_until_finished>Y</wait_until_finished>
+ <follow_abort_remote>N</follow_abort_remote>
+ <create_parent_folder>N</create_parent_folder>
+ <pass_export>N</pass_export>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <set_append_logfile>N</set_append_logfile>
+ <parallel>N</parallel>
+ <xloc>256</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Two nodes with the same id</name>
+ <description/>
+ <type>NEO4J_CYPHER_SCRIPT</type>
+ <attributes/>
+ <connection>Test</connection>
+ <replace_variables>N</replace_variables>
+ <script>CREATE (:IT9219 {id: 1})
+;
+CREATE (:IT9219 {id: 1})</script>
+ <parallel>N</parallel>
+ <xloc>448</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Unknown connection</name>
+ <description/>
+ <type>NEO4J_CONSTRAINT</type>
+ <attributes/>
+ <connection>does-not-exist</connection>
+ <updates>
+ <update>
+ <update_type>CREATE</update_type>
+ <object_type>NODE</object_type>
+ <index_name>it_9219_unique</index_name>
+ <object_name>IT9219</object_name>
+ <object_properties>id</object_properties>
+ <constraint_type>UNIQUE</constraint_type>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>640</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Unknown connection: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>640</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Refused login</name>
+ <description/>
+ <type>NEO4J_CONSTRAINT</type>
+ <attributes/>
+ <connection>Test-wrong-login</connection>
+ <updates>
+ <update>
+ <update_type>CREATE</update_type>
+ <object_type>NODE</object_type>
+ <index_name>it_9219_unique</index_name>
+ <object_name>IT9219</object_name>
+ <object_properties>id</object_properties>
+ <constraint_type>UNIQUE</constraint_type>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>832</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Refused login: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>832</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>No constraint name</name>
+ <description/>
+ <type>NEO4J_CONSTRAINT</type>
+ <attributes/>
+ <connection>Test</connection>
+ <updates>
+ <update>
+ <update_type>CREATE</update_type>
+ <object_type>NODE</object_type>
+ <index_name/>
+ <object_name>IT9219</object_name>
+ <object_properties>id</object_properties>
+ <constraint_type>UNIQUE</constraint_type>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>1024</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>No constraint name: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>1024</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>No object property</name>
+ <description/>
+ <type>NEO4J_CONSTRAINT</type>
+ <attributes/>
+ <connection>Test</connection>
+ <updates>
+ <update>
+ <update_type>CREATE</update_type>
+ <object_type>NODE</object_type>
+ <index_name>it_9219_unique</index_name>
+ <object_name>IT9219</object_name>
+ <object_properties/>
+ <constraint_type>UNIQUE</constraint_type>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>1216</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>No object property: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>1216</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>UNIQUE on duplicate values</name>
+ <description/>
+ <type>NEO4J_CONSTRAINT</type>
+ <attributes/>
+ <connection>Test</connection>
+ <updates>
+ <update>
+ <update_type>CREATE</update_type>
+ <object_type>NODE</object_type>
+ <index_name>it_9219_unique</index_name>
+ <object_name>IT9219</object_name>
+ <object_properties>id</object_properties>
+ <constraint_type>UNIQUE</constraint_type>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>1408</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>UNIQUE on duplicate values: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>1408</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>cleanup-database.hwf after</name>
+ <description/>
+ <type>WORKFLOW</type>
+ <attributes/>
+ <run_configuration>local</run_configuration>
+ <filename>${PROJECT_HOME}/tests/shared/cleanup-database.hwf</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Nothing</loglevel>
+ <wait_until_finished>Y</wait_until_finished>
+ <follow_abort_remote>N</follow_abort_remote>
+ <create_parent_folder>N</create_parent_folder>
+ <pass_export>N</pass_export>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <set_append_logfile>N</set_append_logfile>
+ <parallel>N</parallel>
+ <xloc>1600</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Success</name>
+ <description/>
+ <type>SUCCESS</type>
+ <attributes/>
+ <parallel>N</parallel>
+ <xloc>1792</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>cleanup-database.hwf</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>cleanup-database.hwf</from>
+ <to>Two nodes with the same id</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Two nodes with the same id</from>
+ <to>Unknown connection</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Unknown connection</from>
+ <to>Unknown connection: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Unknown connection</from>
+ <to>Refused login</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Refused login</from>
+ <to>Refused login: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Refused login</from>
+ <to>No constraint name</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>No constraint name</from>
+ <to>No constraint name: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>No constraint name</from>
+ <to>No object property</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>No object property</from>
+ <to>No object property: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>No object property</from>
+ <to>UNIQUE on duplicate values</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>UNIQUE on duplicate values</from>
+ <to>UNIQUE on duplicate values: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>UNIQUE on duplicate values</from>
+ <to>cleanup-database.hwf after</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>cleanup-database.hwf after</from>
+ <to>Success</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git
a/integration-tests/neo4j/tests/neo4j-action-failures-9219/main-9219-graph-index-fails.hwf
b/integration-tests/neo4j/tests/neo4j-action-failures-9219/main-9219-graph-index-fails.hwf
new file mode 100644
index 0000000000..b0477664b9
--- /dev/null
+++
b/integration-tests/neo4j/tests/neo4j-action-failures-9219/main-9219-graph-index-fails.hwf
@@ -0,0 +1,463 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+ <name>main-9219-graph-index-fails</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>#9219: every failing Graph index makes the action false, so its
failure hop is followed</description>
+ <extended_description/>
+ <workflow_version/>
+ <workflow_status>0</workflow_status>
+ <created_user>-</created_user>
+ <created_date>2026/11/07 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/11/07 12:00:00.000</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <intervalSeconds>0</intervalSeconds>
+ <intervalMinutes>60</intervalMinutes>
+ <hour>12</hour>
+ <minutes>0</minutes>
+ <weekDay>1</weekDay>
+ <DayOfMonth>1</DayOfMonth>
+ <parallel>N</parallel>
+ <xloc>64</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>cleanup-database.hwf</name>
+ <description/>
+ <type>WORKFLOW</type>
+ <attributes/>
+ <run_configuration>local</run_configuration>
+ <filename>${PROJECT_HOME}/tests/shared/cleanup-database.hwf</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Nothing</loglevel>
+ <wait_until_finished>Y</wait_until_finished>
+ <follow_abort_remote>N</follow_abort_remote>
+ <create_parent_folder>N</create_parent_folder>
+ <pass_export>N</pass_export>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <set_append_logfile>N</set_append_logfile>
+ <parallel>N</parallel>
+ <xloc>256</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Unknown connection</name>
+ <description/>
+ <type>NEO4J_INDEX</type>
+ <attributes/>
+ <connection>does-not-exist</connection>
+ <updates>
+ <update>
+ <index_name>IT_9219_A_ID</index_name>
+ <object_name>IT9219</object_name>
+ <object_properties>id</object_properties>
+ <object_type>NODE</object_type>
+ <update_type>CREATE</update_type>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>448</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Unknown connection: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>448</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Empty connection</name>
+ <description/>
+ <type>NEO4J_INDEX</type>
+ <attributes/>
+ <connection></connection>
+ <updates>
+ <update>
+ <index_name>IT_9219_A_ID</index_name>
+ <object_name>IT9219</object_name>
+ <object_properties>id</object_properties>
+ <object_type>NODE</object_type>
+ <update_type>CREATE</update_type>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>640</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Empty connection: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>640</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Refused login</name>
+ <description/>
+ <type>NEO4J_INDEX</type>
+ <attributes/>
+ <connection>Test-wrong-login</connection>
+ <updates>
+ <update>
+ <index_name>IT_9219_A_ID</index_name>
+ <object_name>IT9219</object_name>
+ <object_properties>id</object_properties>
+ <object_type>NODE</object_type>
+ <update_type>CREATE</update_type>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>832</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Refused login: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>832</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>No update type</name>
+ <description/>
+ <type>NEO4J_INDEX</type>
+ <attributes/>
+ <connection>Test</connection>
+ <updates>
+ <update>
+ <index_name>IT_9219_A_ID</index_name>
+ <object_name>IT9219</object_name>
+ <object_properties>id</object_properties>
+ <object_type>NODE</object_type>
+ <update_type/>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>1024</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>No update type: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>1024</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>No properties</name>
+ <description/>
+ <type>NEO4J_INDEX</type>
+ <attributes/>
+ <connection>Test</connection>
+ <updates>
+ <update>
+ <index_name>IT_9219_A_ID</index_name>
+ <object_name>IT9219</object_name>
+ <object_properties/>
+ <object_type>NODE</object_type>
+ <update_type>CREATE</update_type>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>1216</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>No properties: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>1216</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Vector dimensions not a number</name>
+ <description/>
+ <type>NEO4J_INDEX</type>
+ <attributes/>
+ <connection>Test</connection>
+ <updates>
+ <update>
+ <index_name>IT_9219_VECTOR</index_name>
+ <object_name>IT9219</object_name>
+ <object_properties>embedding</object_properties>
+ <object_type>NODE</object_type>
+ <update_type>CREATE</update_type>
+ <index_type>VECTOR</index_type>
+ <vector_dimensions>abc</vector_dimensions>
+ <vector_similarity>COSINE</vector_similarity>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>1408</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Vector dimensions not a number: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>1408</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Drop without index name</name>
+ <description/>
+ <type>NEO4J_INDEX</type>
+ <attributes/>
+ <connection>Test</connection>
+ <updates>
+ <update>
+ <index_name/>
+ <object_name>IT9219</object_name>
+ <object_properties>id</object_properties>
+ <object_type>NODE</object_type>
+ <update_type>DROP</update_type>
+ </update>
+ </updates>
+ <parallel>N</parallel>
+ <xloc>1600</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Drop without index name: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>1600</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>cleanup-database.hwf after</name>
+ <description/>
+ <type>WORKFLOW</type>
+ <attributes/>
+ <run_configuration>local</run_configuration>
+ <filename>${PROJECT_HOME}/tests/shared/cleanup-database.hwf</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Nothing</loglevel>
+ <wait_until_finished>Y</wait_until_finished>
+ <follow_abort_remote>N</follow_abort_remote>
+ <create_parent_folder>N</create_parent_folder>
+ <pass_export>N</pass_export>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <set_append_logfile>N</set_append_logfile>
+ <parallel>N</parallel>
+ <xloc>1792</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Success</name>
+ <description/>
+ <type>SUCCESS</type>
+ <attributes/>
+ <parallel>N</parallel>
+ <xloc>1984</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>cleanup-database.hwf</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>cleanup-database.hwf</from>
+ <to>Unknown connection</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Unknown connection</from>
+ <to>Unknown connection: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Unknown connection</from>
+ <to>Empty connection</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Empty connection</from>
+ <to>Empty connection: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Empty connection</from>
+ <to>Refused login</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Refused login</from>
+ <to>Refused login: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Refused login</from>
+ <to>No update type</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>No update type</from>
+ <to>No update type: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>No update type</from>
+ <to>No properties</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>No properties</from>
+ <to>No properties: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>No properties</from>
+ <to>Vector dimensions not a number</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Vector dimensions not a number</from>
+ <to>Vector dimensions not a number: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Vector dimensions not a number</from>
+ <to>Drop without index name</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Drop without index name</from>
+ <to>Drop without index name: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Drop without index name</from>
+ <to>cleanup-database.hwf after</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>cleanup-database.hwf after</from>
+ <to>Success</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git
a/integration-tests/neo4j/tests/neo4j-action-failures-9219/main-9219-graph-script-fails.hwf
b/integration-tests/neo4j/tests/neo4j-action-failures-9219/main-9219-graph-script-fails.hwf
new file mode 100644
index 0000000000..23a8c5f184
--- /dev/null
+++
b/integration-tests/neo4j/tests/neo4j-action-failures-9219/main-9219-graph-script-fails.hwf
@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+ <name>main-9219-graph-script-fails</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>#9219: Graph script is false on connection problems, so its
failure hop is followed</description>
+ <extended_description/>
+ <workflow_version/>
+ <workflow_status>0</workflow_status>
+ <created_user>-</created_user>
+ <created_date>2026/11/07 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/11/07 12:00:00.000</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <intervalSeconds>0</intervalSeconds>
+ <intervalMinutes>60</intervalMinutes>
+ <hour>12</hour>
+ <minutes>0</minutes>
+ <weekDay>1</weekDay>
+ <DayOfMonth>1</DayOfMonth>
+ <parallel>N</parallel>
+ <xloc>64</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Refused login</name>
+ <description/>
+ <type>NEO4J_CYPHER_SCRIPT</type>
+ <attributes/>
+ <connection>Test-wrong-login</connection>
+ <replace_variables>N</replace_variables>
+ <script>RETURN 1</script>
+ <parallel>N</parallel>
+ <xloc>256</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Refused login: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>256</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Unknown connection</name>
+ <description/>
+ <type>NEO4J_CYPHER_SCRIPT</type>
+ <attributes/>
+ <connection>does-not-exist</connection>
+ <replace_variables>N</replace_variables>
+ <script>RETURN 1</script>
+ <parallel>N</parallel>
+ <xloc>448</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Unknown connection: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>448</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Empty connection</name>
+ <description/>
+ <type>NEO4J_CYPHER_SCRIPT</type>
+ <attributes/>
+ <connection></connection>
+ <replace_variables>N</replace_variables>
+ <script>RETURN 1</script>
+ <parallel>N</parallel>
+ <xloc>640</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Empty connection: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>640</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Failing statement</name>
+ <description/>
+ <type>NEO4J_CYPHER_SCRIPT</type>
+ <attributes/>
+ <connection>Test</connection>
+ <replace_variables>N</replace_variables>
+ <script>THIS IS NOT CYPHER</script>
+ <parallel>N</parallel>
+ <xloc>832</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Failing statement: expected false</name>
+ <description/>
+ <type>ABORT</type>
+ <attributes/>
+ <always_log_rows>N</always_log_rows>
+ <parallel>N</parallel>
+ <xloc>832</xloc>
+ <yloc>240</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Success</name>
+ <description/>
+ <type>SUCCESS</type>
+ <attributes/>
+ <parallel>N</parallel>
+ <xloc>1024</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>Refused login</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>Refused login</from>
+ <to>Refused login: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Refused login</from>
+ <to>Unknown connection</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Unknown connection</from>
+ <to>Unknown connection: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Unknown connection</from>
+ <to>Empty connection</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Empty connection</from>
+ <to>Empty connection: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Empty connection</from>
+ <to>Failing statement</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Failing statement</from>
+ <to>Failing statement: expected false</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>Failing statement</from>
+ <to>Success</to>
+ <enabled>Y</enabled>
+ <evaluation>N</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/GraphSchemaUpdates.java
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/GraphSchemaUpdates.java
new file mode 100644
index 0000000000..7377316220
--- /dev/null
+++
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/GraphSchemaUpdates.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.neo4j.actions;
+
+import java.util.List;
+import java.util.function.Function;
+import org.apache.hop.core.Result;
+import org.apache.hop.core.exception.HopException;
+import org.apache.hop.core.graph.IGraphDialect;
+import org.apache.hop.neo4j.shared.NamedGraphConnection;
+import org.apache.hop.neo4j.shared.NeoConnectionUtils;
+import org.apache.hop.workflow.action.ActionBase;
+
+/** Runs the index or constraint updates of the Graph index and Graph
constraint actions. */
+public final class GraphSchemaUpdates {
+
+ /** What an update does. */
+ public enum Operation {
+ DROP,
+ CREATE
+ }
+
+ /** Generates the statement of an update in the dialect of the database. */
+ @FunctionalInterface
+ public interface StatementGenerator<T> {
+ String generate(T update, IGraphDialect dialect) throws HopException;
+ }
+
+ private GraphSchemaUpdates() {}
+
+ /**
+ * Run the drops first, then the creates. A failure fails the action with
one more error instead
+ * of throwing, so a failure hop can handle it: the updates before the
failing one stay done, the
+ * ones after it are not run.
+ *
+ * @param action The action, for the connection, variables and log
+ * @param result The result to update
+ * @param connectionName The name of the graph connection, variables not
resolved yet
+ * @param object What is updated, for the log: "index" or "constraint"
+ * @param updates The updates
+ * @param operation The operation of an update, null when it has no update
type
+ * @param dropStatement Generates the statement of a drop
+ * @param createStatement Generates the statement of a create
+ */
+ public static <T> void execute(
+ ActionBase action,
+ Result result,
+ String connectionName,
+ String object,
+ List<T> updates,
+ Function<T, Operation> operation,
+ StatementGenerator<T> dropStatement,
+ StatementGenerator<T> createStatement) {
+ try {
+ NamedGraphConnection connection =
+ NeoConnectionUtils.getGraphConnection(
+ action.getMetadataProvider(), action.resolve(connectionName));
+
+ for (T update : updates) {
+ if (operation.apply(update) == null) {
+ throw new HopException(
+ "Please make sure to always specify the update type of every " +
object);
+ }
+ }
+ for (T update : updates) {
+ if (operation.apply(update) == Operation.DROP) {
+ NeoConnectionUtils.runSchemaStatement(
+ connection,
+ action.getLogChannel(),
+ action,
+ dropStatement.generate(update, connection.getDialect(action)),
+ "Dropping " + object);
+ }
+ }
+ for (T update : updates) {
+ if (operation.apply(update) == Operation.CREATE) {
+ NeoConnectionUtils.runSchemaStatement(
+ connection,
+ action.getLogChannel(),
+ action,
+ createStatement.generate(update, connection.getDialect(action)),
+ "Creating " + object);
+ }
+ }
+ } catch (Exception e) {
+ action.logError("Error running the graph database " + object + "
updates", e);
+ result.setResult(false);
+ result.increaseErrors(1L);
+ }
+ }
+}
diff --git
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/constraint/Neo4jConstraint.java
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/constraint/Neo4jConstraint.java
index fde47a64d6..8cd3ce4e16 100644
---
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/constraint/Neo4jConstraint.java
+++
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/constraint/Neo4jConstraint.java
@@ -28,9 +28,8 @@ import org.apache.hop.core.graph.IGraphDialect;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.HopMetadataPropertyType;
+import org.apache.hop.neo4j.actions.GraphSchemaUpdates;
import org.apache.hop.neo4j.actions.index.Neo4jIndex;
-import org.apache.hop.neo4j.shared.NamedGraphConnection;
-import org.apache.hop.neo4j.shared.NeoConnectionUtils;
import org.apache.hop.workflow.action.ActionBase;
import org.apache.hop.workflow.action.IAction;
@@ -50,8 +49,6 @@ public class Neo4jConstraint extends ActionBase implements
IAction {
hopMetadataPropertyType = HopMetadataPropertyType.GRAPH_CONNECTION)
private String connectionName;
- private NamedGraphConnection connection;
-
@HopMetadataProperty(groupKey = "updates", key = "update")
private List<ConstraintUpdate> constraintUpdates;
@@ -72,43 +69,18 @@ public class Neo4jConstraint extends ActionBase implements
IAction {
public Result execute(Result result, int nr) throws HopException {
// Success unless something goes wrong, whatever the result of the
previous action
result.setResult(true);
-
- connection =
- NeoConnectionUtils.findGraphConnection(getMetadataProvider(),
resolve(connectionName));
-
- if (connection == null) {
- result.setResult(false);
- result.increaseErrors(1L);
- throw new HopException("Please specify a Neo4j connection to use");
- }
-
- // Loop over the constraint updates to see which need deleting...
- //
- for (ConstraintUpdate constraintUpdate : constraintUpdates) {
- if (constraintUpdate.getUpdateType() == null) {
- throw new HopException("Please make sure to always specify a
constraint update type");
- }
- switch (constraintUpdate.getUpdateType()) {
- case DROP:
- dropConstraint(constraintUpdate);
- break;
- default:
- break;
- }
- }
-
- // Create the constraints if needed
- //
- for (ConstraintUpdate constraintUpdate : constraintUpdates) {
- switch (constraintUpdate.getUpdateType()) {
- case CREATE:
- createConstraint(constraintUpdate);
- break;
- default:
- break;
- }
- }
-
+ GraphSchemaUpdates.execute(
+ this,
+ result,
+ connectionName,
+ "constraint",
+ constraintUpdates,
+ update ->
+ update.getUpdateType() == null
+ ? null
+ :
GraphSchemaUpdates.Operation.valueOf(update.getUpdateType().name()),
+ (update, dialect) -> generateDropConstraintCypher(resolved(update),
dialect),
+ (update, dialect) -> generateCreateConstraintCypher(resolved(update),
dialect));
return result;
}
@@ -163,26 +135,6 @@ public class Neo4jConstraint extends ActionBase implements
IAction {
return copy;
}
- private void dropConstraint(final ConstraintUpdate constraintUpdate) throws
HopException {
- String cypher =
- generateDropConstraintCypher(resolved(constraintUpdate),
connection.getDialect(this));
-
- // Run this cypher statement...
- //
- NeoConnectionUtils.runSchemaStatement(
- connection, getLogChannel(), this, cypher, "Dropping constraint");
- }
-
- private void createConstraint(ConstraintUpdate constraintUpdate) throws
HopException {
- String cypher =
- generateCreateConstraintCypher(resolved(constraintUpdate),
connection.getDialect(this));
-
- // Run this cypher statement...
- //
- NeoConnectionUtils.runSchemaStatement(
- connection, getLogChannel(), this, cypher, "Creating constraint");
- }
-
@Override
public boolean isEvaluation() {
return true;
diff --git
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/cypherscript/CypherScript.java
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/cypherscript/CypherScript.java
index 09f4bbec06..1b48ee14ba 100644
---
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/cypherscript/CypherScript.java
+++
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/cypherscript/CypherScript.java
@@ -71,17 +71,6 @@ public class CypherScript extends ActionBase implements
IAction {
result.setResult(true);
// Replace variables & parameters
//
- NamedGraphConnection graphConnection;
- String realConnectionName = resolve(connectionName);
- try {
- graphConnection =
- NeoConnectionUtils.getGraphConnection(getMetadataProvider(),
realConnectionName);
- } catch (Exception e) {
- result.setResult(false);
- result.increaseErrors(1L);
- throw new HopException("Unable to find connection with name '" +
realConnectionName + "'", e);
- }
-
String realScript;
if (replacingVariables) {
realScript = resolve(script);
@@ -92,37 +81,19 @@ public class CypherScript extends ActionBase implements
IAction {
int nrExecuted;
- try (IGraphConnection connection =
graphConnection.connect(getLogChannel(), this)) {
- IGraphDialect dialect = connection.getGraphDialect();
- if (dialect.isSupportingSchemaChangesInTransactions()
- && connection.isSupportingTransactions()
- && statements.stream().anyMatch(dialect::isRequiringAutoCommit)) {
- // Statements like CALL { ... } IN TRANSACTIONS can't run in an
explicit transaction
- //
- if (isBasic()) {
- logBasic(
- "Some statements run on their own in auto-commit transactions:
the script doesn't"
- + " run in a single transaction");
- }
- nrExecuted = executeAroundAutoCommit(connection, dialect, statements,
result);
- } else if (dialect.isSupportingSchemaChangesInTransactions()
- && connection.isSupportingTransactions()) {
- try {
- // The transaction is committed when the work returns, and rolled
back when it throws: a
- // failed script keeps none of its statements.
- nrExecuted = executeInTransaction(connection, statements);
- } catch (Exception e) {
- logError("Error executing cypher statements, the transaction is
rolled back", e);
- result.setNrErrors(1);
- result.setResult(false);
- nrExecuted = 0;
- }
- } else {
- // Index and constraint changes can't run in an explicit transaction
here, or there are no
- // transactions at all: run each statement on its own.
- //
- nrExecuted = executeAutoCommit(connection, statements, result);
+ // A connection which is empty, unknown, can't be reached or refuses the
login fails the action
+ // like a failing statement does.
+ //
+ try {
+ NamedGraphConnection graphConnection =
+ NeoConnectionUtils.getGraphConnection(getMetadataProvider(),
resolve(connectionName));
+ try (IGraphConnection connection =
graphConnection.connect(getLogChannel(), this)) {
+ nrExecuted = execute(connection, statements, result);
}
+ } catch (Exception e) {
+ logError("Error executing cypher statements", e);
+ fail(result);
+ nrExecuted = 0;
}
if (result.getResult()) {
@@ -138,6 +109,51 @@ public class CypherScript extends ActionBase implements
IAction {
return result;
}
+ /** Run the statements on an open connection, the way the database supports.
*/
+ private int execute(IGraphConnection connection, List<String> statements,
Result result)
+ throws HopException {
+ IGraphDialect dialect = connection.getGraphDialect();
+ if (dialect.isSupportingSchemaChangesInTransactions()
+ && connection.isSupportingTransactions()
+ && statements.stream().anyMatch(dialect::isRequiringAutoCommit)) {
+ // Statements like CALL { ... } IN TRANSACTIONS can't run in an explicit
transaction
+ //
+ if (isBasic()) {
+ logBasic(
+ "Some statements run on their own in auto-commit transactions: the
script doesn't"
+ + " run in a single transaction");
+ }
+ return executeAroundAutoCommit(connection, dialect, statements, result);
+ }
+ if (dialect.isSupportingSchemaChangesInTransactions()
+ && connection.isSupportingTransactions()) {
+ try {
+ // The transaction is committed when the work returns, and rolled back
when it throws: a
+ // failed script keeps none of its statements.
+ return executeInTransaction(connection, statements);
+ } catch (Exception e) {
+ logError("Error executing cypher statements, the transaction is rolled
back", e);
+ fail(result);
+ return 0;
+ }
+ }
+ // Index and constraint changes can't run in an explicit transaction here,
or there are no
+ // transactions at all: run each statement on its own.
+ //
+ return executeAutoCommit(connection, statements, result);
+ }
+
+ /**
+ * Fail the action with one more error than the previous actions had. A
failure is counted once,
+ * also when closing the connection fails after a failed statement.
+ */
+ private static void fail(Result result) {
+ if (result.getResult()) {
+ result.setResult(false);
+ result.increaseErrors(1L);
+ }
+ }
+
/** Split the script into statements: a semicolon at the start of a separate
line. */
private static List<String> splitScript(String script) {
List<String> statements = new ArrayList<>();
@@ -257,8 +273,7 @@ public class CypherScript extends ActionBase implements
IAction {
} catch (Exception e) {
logError(
"Error executing cypher statements, the statements before the error
stay committed", e);
- result.setNrErrors(1);
- result.setResult(false);
+ fail(result);
}
return executed;
}
@@ -276,8 +291,7 @@ public class CypherScript extends ActionBase implements
IAction {
}
} catch (Exception e) {
logError("Error executing cypher statements...", e);
- result.setNrErrors(1);
- result.setResult(false);
+ fail(result);
}
return executed;
}
diff --git
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/index/Neo4jIndex.java
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/index/Neo4jIndex.java
index 7d0c77ad91..c19d77e883 100644
---
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/index/Neo4jIndex.java
+++
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/index/Neo4jIndex.java
@@ -31,8 +31,7 @@ import org.apache.hop.core.graph.IGraphDialect;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.HopMetadataPropertyType;
-import org.apache.hop.neo4j.shared.NamedGraphConnection;
-import org.apache.hop.neo4j.shared.NeoConnectionUtils;
+import org.apache.hop.neo4j.actions.GraphSchemaUpdates;
import org.apache.hop.workflow.action.ActionBase;
import org.apache.hop.workflow.action.IAction;
@@ -52,8 +51,6 @@ public class Neo4jIndex extends ActionBase implements IAction
{
hopMetadataPropertyType = HopMetadataPropertyType.GRAPH_CONNECTION)
private String connectionName;
- private NamedGraphConnection connection;
-
@HopMetadataProperty(groupKey = "updates", key = "update")
private List<IndexUpdate> indexUpdates;
@@ -74,43 +71,18 @@ public class Neo4jIndex extends ActionBase implements
IAction {
public Result execute(Result result, int nr) throws HopException {
// Success unless something goes wrong, whatever the result of the
previous action
result.setResult(true);
-
- connection =
- NeoConnectionUtils.findGraphConnection(getMetadataProvider(),
resolve(connectionName));
-
- if (connection == null) {
- result.setResult(false);
- result.increaseErrors(1L);
- throw new HopException("Please specify a Neo4j connection to use");
- }
-
- // Loop over the index updates to see which need deleting...
- //
- for (IndexUpdate indexUpdate : indexUpdates) {
- if (indexUpdate.getType() == null) {
- throw new HopException("Please make sure to always specify an index
update type");
- }
- switch (indexUpdate.getType()) {
- case DROP:
- dropIndex(indexUpdate);
- break;
- default:
- break;
- }
- }
-
- // Create the indexes if needed
- //
- for (IndexUpdate indexUpdate : indexUpdates) {
- switch (indexUpdate.getType()) {
- case CREATE:
- createIndex(indexUpdate);
- break;
- default:
- break;
- }
- }
-
+ GraphSchemaUpdates.execute(
+ this,
+ result,
+ connectionName,
+ "index",
+ indexUpdates,
+ update ->
+ update.getType() == null
+ ? null
+ :
GraphSchemaUpdates.Operation.valueOf(update.getType().name()),
+ (update, dialect) -> generateDropIndexCypher(resolved(update),
dialect),
+ (update, dialect) -> generateCreateIndexCypher(resolved(update),
dialect));
return result;
}
@@ -162,24 +134,6 @@ public class Neo4jIndex extends ActionBase implements
IAction {
return copy;
}
- private void dropIndex(final IndexUpdate indexUpdate) throws HopException {
- String cypher = generateDropIndexCypher(resolved(indexUpdate),
connection.getDialect(this));
-
- // Run this cypher statement...
- //
- NeoConnectionUtils.runSchemaStatement(
- connection, getLogChannel(), this, cypher, "Dropping index");
- }
-
- private void createIndex(IndexUpdate indexUpdate) throws HopException {
- String cypher = generateCreateIndexCypher(resolved(indexUpdate),
connection.getDialect(this));
-
- // Run this cypher statement...
- //
- NeoConnectionUtils.runSchemaStatement(
- connection, getLogChannel(), this, cypher, "Creating index");
- }
-
static GraphIndexDefinition toIndexDefinition(IndexUpdate indexUpdate) {
return new GraphIndexDefinition(
indexUpdate.getIndexName(),
diff --git
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/propertygraph/ActionCreatePropertyGraph.java
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/propertygraph/ActionCreatePropertyGraph.java
index 3c46911f19..3e417fb2a1 100644
---
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/propertygraph/ActionCreatePropertyGraph.java
+++
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/propertygraph/ActionCreatePropertyGraph.java
@@ -22,6 +22,7 @@ import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
+import org.apache.hop.core.Const;
import org.apache.hop.core.Result;
import org.apache.hop.core.annotations.Action;
import org.apache.hop.core.database.Database;
@@ -207,17 +208,15 @@ public class ActionCreatePropertyGraph extends ActionBase
implements IAction {
public Result execute(Result result, int nr) throws HopException {
result.setResult(false);
IHopMetadataProvider metadataProvider = getMetadataProvider();
- DatabaseMeta databaseMeta = loadDatabaseMeta(metadataProvider);
- try (Database database = new Database(this, this, databaseMeta)) {
- database.connect();
- for (String statement : getStatements(database,
loadGraphModel(metadataProvider))) {
- if (isDetailed()) {
- logDetailed("Executing: " + statement);
- }
- database.execStatement(statement);
+ try {
+ DatabaseMeta databaseMeta = loadDatabaseMeta(metadataProvider);
+ try (Database database = new Database(this, this, databaseMeta)) {
+ database.connect();
+ executeStatements(
+ database, getPlannedStatements(database,
loadGraphModel(metadataProvider)));
}
- } catch (HopException e) {
- result.setNrErrors(1);
+ } catch (Exception e) {
+ result.increaseErrors(1L);
logError("Error creating property graph '" + resolve(graphName) + "'",
e);
return result;
}
@@ -225,8 +224,66 @@ public class ActionCreatePropertyGraph extends ActionBase
implements IAction {
return result;
}
+ /**
+ * Run the statements one by one. When one fails, drop the tables this run
created, newest first,
+ * so a failing CREATE PROPERTY GRAPH doesn't leave them behind. Each
statement commits on its
+ * own, so a rollback can't undo them.
+ */
+ void executeStatements(Database database, List<PlannedStatement> statements)
throws HopException {
+ List<String> createdTables = new ArrayList<>();
+ for (PlannedStatement statement : statements) {
+ if (isDetailed()) {
+ logDetailed("Executing: " + statement.sql());
+ }
+ try {
+ database.execStatement(statement.sql());
+ } catch (HopException e) {
+ String dropError = dropCreatedTables(database, createdTables);
+ if (dropError != null) {
+ throw new HopException(
+ "The property graph can't be created and the tables it created
can't be dropped: "
+ + dropError,
+ e);
+ }
+ throw e;
+ }
+ if (statement.createdTable() != null) {
+ createdTables.add(statement.createdTable());
+ }
+ }
+ }
+
+ /**
+ * Drop the tables in reverse order.
+ *
+ * @return null when all of them are dropped, or a message naming the tables
that are left
+ */
+ private String dropCreatedTables(Database database, List<String>
createdTables) {
+ List<String> left = new ArrayList<>();
+ String reason = null;
+ for (int i = createdTables.size() - 1; i >= 0; i--) {
+ String table = createdTables.get(i);
+ try {
+ database.execStatement("DROP TABLE " + table);
+ logBasic("Dropped table " + table + ", created by this action");
+ } catch (HopException e) {
+ left.add(0, table);
+ if (reason == null) {
+ reason = e.getMessage();
+ }
+ }
+ }
+ if (left.isEmpty()) {
+ return null;
+ }
+ return String.join(", ", left) + " stay in the database (" +
Const.trim(reason) + ")";
+ }
+
public DatabaseMeta loadDatabaseMeta(IHopMetadataProvider metadataProvider)
throws HopException {
String connectionName = resolve(connection);
+ if (StringUtils.isEmpty(connectionName)) {
+ throw new HopException("Please specify a relational database
connection");
+ }
DatabaseMeta databaseMeta =
metadataProvider.getSerializer(DatabaseMeta.class).load(connectionName);
if (databaseMeta == null) {
@@ -253,6 +310,24 @@ public class ActionCreatePropertyGraph extends ActionBase
implements IAction {
* @param model The graph model
*/
public List<String> getStatements(Database database, GraphModel model)
throws HopException {
+ List<String> statements = new ArrayList<>();
+ for (PlannedStatement statement : getPlannedStatements(database, model)) {
+ statements.add(statement.sql());
+ }
+ return statements;
+ }
+
+ /**
+ * A statement to execute.
+ *
+ * @param sql The statement
+ * @param createdTable The quoted name of the table a CREATE TABLE statement
creates, otherwise
+ * null
+ */
+ record PlannedStatement(String sql, String createdTable) {}
+
+ List<PlannedStatement> getPlannedStatements(Database database, GraphModel
model)
+ throws HopException {
if (StringUtils.isEmpty(resolve(graphName))) {
throw new HopException("Please specify the name of the property graph");
}
@@ -267,7 +342,8 @@ public class ActionCreatePropertyGraph extends ActionBase
implements IAction {
StringUtils.isEmpty(schema) ?
resolve(databaseMeta.getPreferredSchemaName()) : schema,
databaseMeta.getStartQuote(),
databaseMeta.getEndQuote());
- List<String> statements = new ArrayList<>();
+ generator.validateTables();
+ List<PlannedStatement> statements = new ArrayList<>();
if (creatingTables) {
for (PropertyGraphGenerator.NodeTable table : generator.getNodeTables())
{
addCreateTable(database, schema, table.table(), table.columns(),
table.keys(), statements);
@@ -277,8 +353,10 @@ public class ActionCreatePropertyGraph extends ActionBase
implements IAction {
}
}
statements.add(
- generator.getCreatePropertyGraphStatement(
- resolve(graphName), schema, replacingGraph,
databaseMeta::quoteField));
+ new PlannedStatement(
+ generator.getCreatePropertyGraphStatement(
+ resolve(graphName), schema, replacingGraph,
databaseMeta::quoteField),
+ null));
return statements;
}
@@ -288,7 +366,7 @@ public class ActionCreatePropertyGraph extends ActionBase
implements IAction {
String table,
List<PropertyGraphGenerator.Column> columns,
List<String> keys,
- List<String> statements)
+ List<PlannedStatement> statements)
throws HopException {
if (database.checkTableExists(schema, table)) {
return;
@@ -296,16 +374,20 @@ public class ActionCreatePropertyGraph extends ActionBase
implements IAction {
DatabaseMeta databaseMeta = database.getDatabaseMeta();
String qualified = databaseMeta.getQuotedSchemaTableCombination(this,
schema, table);
statements.add(
- database
- .getCreateTableStatement(
- qualified, PropertyGraphGenerator.getRowMeta(columns), null,
false, null, false)
- .trim());
+ new PlannedStatement(
+ database
+ .getCreateTableStatement(
+ qualified, PropertyGraphGenerator.getRowMeta(columns),
null, false, null, false)
+ .trim(),
+ qualified));
List<String> quotedKeys = new ArrayList<>();
for (String key : keys) {
quotedKeys.add(databaseMeta.quoteField(key));
}
statements.add(
- "ALTER TABLE " + qualified + " ADD PRIMARY KEY (" + String.join(", ",
quotedKeys) + ")");
+ new PlannedStatement(
+ "ALTER TABLE " + qualified + " ADD PRIMARY KEY (" + String.join(",
", quotedKeys) + ")",
+ null));
}
private List<NodeTableMapping> resolveNodeTables() {
diff --git
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/propertygraph/PropertyGraphGenerator.java
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/propertygraph/PropertyGraphGenerator.java
index 95cce0b9f8..2cb1972e4c 100644
---
a/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/propertygraph/PropertyGraphGenerator.java
+++
b/plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/propertygraph/PropertyGraphGenerator.java
@@ -18,6 +18,7 @@
package org.apache.hop.neo4j.actions.propertygraph;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -274,6 +275,39 @@ public class PropertyGraphGenerator {
return edgeTables;
}
+ /**
+ * Refuse a table used by more than one node or relationship. Each table is
a separate element of
+ * the property graph, named after the table, so the names would clash.
Checked before any table
+ * is created, so a failing graph doesn't leave tables behind.
+ *
+ * @throws HopException naming the first table which is used twice
+ */
+ public void validateTables() throws HopException {
+ Map<String, String> users = new HashMap<>();
+ for (NodeTable nodeTable : nodeTables) {
+ checkTable(users, nodeTable.table(), "node '" +
nodeTable.node().getName() + "'");
+ }
+ for (EdgeTable edgeTable : edgeTables) {
+ checkTable(
+ users, edgeTable.table(), "relationship '" +
edgeTable.relationship().getName() + "'");
+ }
+ }
+
+ private static void checkTable(Map<String, String> users, String table,
String user)
+ throws HopException {
+ String previous = users.putIfAbsent(table, user);
+ if (previous != null) {
+ throw new HopException(
+ "Table '"
+ + table
+ + "' is used by "
+ + previous
+ + " and "
+ + user
+ + ": every node and relationship needs a table of its own");
+ }
+ }
+
/**
* Refuse identifiers which can't be quoted safely. Identifiers are quoted
with {@link
* org.apache.hop.core.database.DatabaseMeta#quoteField(String)}, which
leaves a name containing a
diff --git
a/plugins/tech/neo4j/src/test/java/org/apache/hop/neo4j/actions/GraphActionFailuresTest.java
b/plugins/tech/neo4j/src/test/java/org/apache/hop/neo4j/actions/GraphActionFailuresTest.java
new file mode 100644
index 0000000000..425697e2cf
--- /dev/null
+++
b/plugins/tech/neo4j/src/test/java/org/apache/hop/neo4j/actions/GraphActionFailuresTest.java
@@ -0,0 +1,285 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.neo4j.actions;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.hop.core.HopClientEnvironment;
+import org.apache.hop.core.Result;
+import org.apache.hop.core.exception.HopException;
+import org.apache.hop.core.graph.BaseGraphDatabase;
+import org.apache.hop.core.graph.CypherGraphDialect;
+import org.apache.hop.core.graph.GraphConstraintType;
+import org.apache.hop.core.graph.GraphDatabaseMeta;
+import org.apache.hop.core.graph.IGraphConnection;
+import org.apache.hop.core.graph.IGraphDialect;
+import org.apache.hop.core.graph.IGraphTransaction;
+import org.apache.hop.core.graph.IGraphTransactionWork;
+import org.apache.hop.core.logging.ILogChannel;
+import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.metadata.serializer.memory.MemoryMetadataProvider;
+import org.apache.hop.neo4j.actions.constraint.ConstraintUpdate;
+import org.apache.hop.neo4j.actions.constraint.Neo4jConstraint;
+import org.apache.hop.neo4j.actions.cypherscript.CypherScript;
+import org.apache.hop.neo4j.actions.index.IndexUpdate;
+import org.apache.hop.neo4j.actions.index.Neo4jIndex;
+import org.apache.hop.neo4j.actions.index.ObjectType;
+import org.apache.hop.neo4j.actions.index.UpdateType;
+import org.apache.hop.neo4j.actions.propertygraph.ActionCreatePropertyGraph;
+import org.apache.hop.workflow.action.ActionBase;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Graph index, Graph constraint, Graph script and Create property graph are
false with 1 error when
+ * they fail, so a failure hop can handle it, instead of stopping the workflow
(#9219).
+ */
+class GraphActionFailuresTest {
+
+ private static final String REFUSING = "refusing";
+ private static final String ACCEPTING = "accepting";
+
+ /** The statements the accepting database ran. */
+ private static final List<String> statements = new ArrayList<>();
+
+ @BeforeAll
+ static void beforeAll() throws HopException {
+ HopClientEnvironment.init();
+ }
+
+ @BeforeEach
+ void beforeEach() {
+ statements.clear();
+ }
+
+ @Test
+ void indexFailures() throws Exception {
+ assertFalseWithOneError(index("does-not-exist", rangeIndex()));
+ assertFalseWithOneError(index("", rangeIndex()));
+ assertFalseWithOneError(index(REFUSING, rangeIndex()));
+
+ IndexUpdate noType = rangeIndex();
+ noType.setType(null);
+ assertFalseWithOneError(index(REFUSING, noType));
+
+ // On a database which connects, so only the validation can fail it
+ //
+ IndexUpdate noProperties = rangeIndex();
+ noProperties.setObjectProperties("");
+ assertFalseWithOneError(index(ACCEPTING, noProperties));
+ assertTrue(statements.isEmpty(), statements.toString());
+ }
+
+ @Test
+ void constraintFailures() throws Exception {
+ assertFalseWithOneError(constraint("does-not-exist", uniqueConstraint()));
+ assertFalseWithOneError(constraint("", uniqueConstraint()));
+ assertFalseWithOneError(constraint(REFUSING, uniqueConstraint()));
+
+ ConstraintUpdate noType = uniqueConstraint();
+ noType.setUpdateType(null);
+ assertFalseWithOneError(constraint(REFUSING, noType));
+
+ // On a database which connects, so only the validation can fail it
+ //
+ ConstraintUpdate noProperty = uniqueConstraint();
+ noProperty.setObjectProperties("");
+ assertFalseWithOneError(constraint(ACCEPTING, noProperty));
+ assertTrue(statements.isEmpty(), statements.toString());
+ }
+
+ /** The accepting database runs valid updates, so the failures above come
from the validation. */
+ @Test
+ void acceptingDatabaseRunsValidUpdates() throws Exception {
+ assertTrue(index(ACCEPTING, rangeIndex()).execute(new Result(),
0).getResult());
+ assertTrue(constraint(ACCEPTING, uniqueConstraint()).execute(new Result(),
0).getResult());
+ assertEquals(2, statements.size(), statements.toString());
+ }
+
+ /** A failure adds one error to the errors of the previous actions. */
+ @Test
+ void failuresAddOneError() throws Exception {
+ assertErrorsAdded(index(REFUSING, rangeIndex()));
+ assertErrorsAdded(constraint(REFUSING, uniqueConstraint()));
+ assertErrorsAdded(script(REFUSING));
+ assertErrorsAdded(propertyGraph("does-not-exist"));
+ }
+
+ @Test
+ void scriptFailures() throws Exception {
+ assertFalseWithOneError(script("does-not-exist"));
+ assertFalseWithOneError(script(""));
+ assertFalseWithOneError(script(REFUSING));
+ }
+
+ @Test
+ void propertyGraphConnectionFailures() throws Exception {
+ assertFalseWithOneError(propertyGraph("does-not-exist"));
+ assertFalseWithOneError(propertyGraph(""));
+ }
+
+ private static void assertFalseWithOneError(ActionBase action) throws
HopException {
+ Result result = action.execute(new Result(), 0);
+ assertFalse(result.getResult(), action.getName() + " is true");
+ assertEquals(1, result.getNrErrors(), action.getName());
+ }
+
+ private static void assertErrorsAdded(ActionBase action) throws HopException
{
+ Result previous = new Result();
+ previous.setNrErrors(2);
+ Result result = action.execute(previous, 0);
+ assertFalse(result.getResult(), action.getName() + " is true");
+ assertEquals(3, result.getNrErrors(), action.getName());
+ }
+
+ private static MemoryMetadataProvider metadataProvider() throws HopException
{
+ MemoryMetadataProvider metadataProvider = new MemoryMetadataProvider();
+ metadataProvider
+ .getSerializer(GraphDatabaseMeta.class)
+ .save(new GraphDatabaseMeta(REFUSING, new RefusingDatabase()));
+ metadataProvider
+ .getSerializer(GraphDatabaseMeta.class)
+ .save(new GraphDatabaseMeta(ACCEPTING, new AcceptingDatabase()));
+ return metadataProvider;
+ }
+
+ private static IndexUpdate rangeIndex() {
+ IndexUpdate update = new IndexUpdate();
+ update.setType(UpdateType.CREATE);
+ update.setObjectType(ObjectType.NODE);
+ update.setIndexName("A_ID");
+ update.setObjectName("A");
+ update.setObjectProperties("id");
+ return update;
+ }
+
+ private static ConstraintUpdate uniqueConstraint() {
+ ConstraintUpdate update = new ConstraintUpdate();
+
update.setUpdateType(org.apache.hop.neo4j.actions.constraint.UpdateType.CREATE);
+
update.setObjectType(org.apache.hop.neo4j.actions.constraint.ObjectType.NODE);
+ update.setConstraintName("a_id");
+ update.setObjectName("A");
+ update.setObjectProperties("id");
+ update.setConstraintType(GraphConstraintType.UNIQUE);
+ return update;
+ }
+
+ private static Neo4jIndex index(String connection, IndexUpdate update)
throws HopException {
+ Neo4jIndex action = new Neo4jIndex("index on '" + connection + "'");
+ action.setMetadataProvider(metadataProvider());
+ action.setConnectionName(connection);
+ action.setIndexUpdates(List.of(update));
+ return action;
+ }
+
+ private static Neo4jConstraint constraint(String connection,
ConstraintUpdate update)
+ throws HopException {
+ Neo4jConstraint action = new Neo4jConstraint("constraint on '" +
connection + "'");
+ action.setMetadataProvider(metadataProvider());
+ action.setConnectionName(connection);
+ action.setConstraintUpdates(List.of(update));
+ return action;
+ }
+
+ private static CypherScript script(String connection) throws HopException {
+ CypherScript action = new CypherScript("script on '" + connection + "'");
+ action.setMetadataProvider(metadataProvider());
+ action.setConnectionName(connection);
+ action.setScript("RETURN 1");
+ return action;
+ }
+
+ private static ActionCreatePropertyGraph propertyGraph(String connection)
throws HopException {
+ ActionCreatePropertyGraph action =
+ new ActionCreatePropertyGraph("property graph on '" + connection +
"'");
+ action.setMetadataProvider(metadataProvider());
+ action.setConnection(connection);
+ action.setGraphName("social");
+ return action;
+ }
+
+ /** A database which refuses the login, the way a driver does: with a
runtime exception. */
+ private static class RefusingDatabase extends BaseGraphDatabase {
+ @Override
+ public IGraphDialect getGraphDialect() {
+ return CypherGraphDialect.DEFAULT;
+ }
+
+ @Override
+ public IGraphConnection connect(ILogChannel log, IVariables variables,
String connectionName) {
+ throw new IllegalStateException("The client is unauthorized due to
authentication failure");
+ }
+
+ @Override
+ public String test(IVariables variables, String connectionName) {
+ return "refusing";
+ }
+ }
+
+ /** A database which connects and records the statements it runs. */
+ private static class AcceptingDatabase extends BaseGraphDatabase {
+ @Override
+ public IGraphDialect getGraphDialect() {
+ return CypherGraphDialect.DEFAULT;
+ }
+
+ @Override
+ public IGraphConnection connect(ILogChannel log, IVariables variables,
String connectionName) {
+ return new RecordingConnection();
+ }
+
+ @Override
+ public String test(IVariables variables, String connectionName) {
+ return "accepting";
+ }
+ }
+
+ private static class RecordingConnection implements IGraphConnection {
+ @Override
+ public List<Map<String, Object>> execute(String statement, Map<String,
Object> parameters) {
+ statements.add(statement);
+ return List.of();
+ }
+
+ @Override
+ public void executeSchemaStatement(String statement, boolean
inTransaction) {
+ statements.add(statement);
+ }
+
+ @Override
+ public IGraphTransaction beginTransaction() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T> T executeWrite(IGraphTransactionWork<T> work) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void close() {
+ // Nothing to close
+ }
+ }
+}
diff --git
a/plugins/tech/neo4j/src/test/java/org/apache/hop/neo4j/actions/propertygraph/ActionCreatePropertyGraphTest.java
b/plugins/tech/neo4j/src/test/java/org/apache/hop/neo4j/actions/propertygraph/ActionCreatePropertyGraphTest.java
new file mode 100644
index 0000000000..9bd969217c
--- /dev/null
+++
b/plugins/tech/neo4j/src/test/java/org/apache/hop/neo4j/actions/propertygraph/ActionCreatePropertyGraphTest.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.neo4j.actions.propertygraph;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import org.apache.hop.core.HopClientEnvironment;
+import org.apache.hop.core.database.Database;
+import org.apache.hop.core.database.DatabaseMeta;
+import org.apache.hop.core.exception.HopDatabaseException;
+import org.apache.hop.core.exception.HopException;
+import
org.apache.hop.neo4j.actions.propertygraph.ActionCreatePropertyGraph.PlannedStatement;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/** When a statement fails, the tables this run created are dropped and the
others are kept. */
+class ActionCreatePropertyGraphTest {
+
+ private static final String CREATE_GRAPH = "CREATE PROPERTY GRAPH g";
+
+ /** Two new tables with a primary key each, then the graph. */
+ private static final List<PlannedStatement> STATEMENTS =
+ List.of(
+ new PlannedStatement("CREATE TABLE a", "a"),
+ new PlannedStatement("ALTER TABLE a ADD PRIMARY KEY (id)", null),
+ new PlannedStatement("CREATE TABLE b", "b"),
+ new PlannedStatement("ALTER TABLE b ADD PRIMARY KEY (id)", null),
+ new PlannedStatement(CREATE_GRAPH, null));
+
+ @BeforeAll
+ static void beforeAll() throws HopException {
+ HopClientEnvironment.init();
+ }
+
+ @Test
+ void createdTablesAreDroppedNewestFirst() throws Exception {
+ List<String> executed = new ArrayList<>();
+ Database database = database(executed, Set.of(CREATE_GRAPH));
+
+ HopException e =
+ assertThrows(HopException.class, () ->
action().executeStatements(database, STATEMENTS));
+
+ assertTrue(e.getMessage().contains(CREATE_GRAPH + " failed"),
e.getMessage());
+ assertTrue(!e.getMessage().contains("stay in the database"),
e.getMessage());
+ assertEquals(
+ List.of(
+ "CREATE TABLE a",
+ "ALTER TABLE a ADD PRIMARY KEY (id)",
+ "CREATE TABLE b",
+ "ALTER TABLE b ADD PRIMARY KEY (id)",
+ CREATE_GRAPH,
+ "DROP TABLE b",
+ "DROP TABLE a"),
+ executed);
+ }
+
+ @Test
+ void failingCreateTableIsNotDropped() throws Exception {
+ List<String> executed = new ArrayList<>();
+ Database database = database(executed, Set.of("CREATE TABLE b"));
+
+ assertThrows(HopException.class, () ->
action().executeStatements(database, STATEMENTS));
+
+ assertEquals(
+ List.of(
+ "CREATE TABLE a",
+ "ALTER TABLE a ADD PRIMARY KEY (id)",
+ "CREATE TABLE b",
+ "DROP TABLE a"),
+ executed);
+ }
+
+ @Test
+ void tablesWhichCantBeDroppedAreReported() throws Exception {
+ List<String> executed = new ArrayList<>();
+ Database database = database(executed, Set.of(CREATE_GRAPH, "DROP TABLE
b"));
+
+ HopException e =
+ assertThrows(HopException.class, () ->
action().executeStatements(database, STATEMENTS));
+
+ assertTrue(e.getMessage().contains("b stay in the database"),
e.getMessage());
+ assertTrue(e.getMessage().contains("DROP TABLE b failed"), e.getMessage());
+ assertTrue(e.getCause().getMessage().contains(CREATE_GRAPH + " failed"));
+ assertEquals("DROP TABLE a", executed.get(executed.size() - 1));
+ }
+
+ @Test
+ void nothingIsDroppedWithoutAFailure() throws Exception {
+ List<String> executed = new ArrayList<>();
+ action().executeStatements(database(executed, Set.of()), STATEMENTS);
+
+ assertEquals(STATEMENTS.stream().map(PlannedStatement::sql).toList(),
executed);
+ }
+
+ /** A table used twice is refused before checking or creating any table. */
+ @Test
+ void duplicateTablesAreRefusedBeforeAnySql() throws Exception {
+ DatabaseMeta databaseMeta = mock(DatabaseMeta.class);
+ when(databaseMeta.getStartQuote()).thenReturn("\"");
+ when(databaseMeta.getEndQuote()).thenReturn("\"");
+ Database database = mock(Database.class);
+ when(database.getDatabaseMeta()).thenReturn(databaseMeta);
+
+ ActionCreatePropertyGraph action = action();
+ action.setCreatingTables(true);
+ action.setNodeTables(List.of(new NodeTableMapping("Company", "Person",
null)));
+
+ HopException e =
+ assertThrows(
+ HopException.class,
+ () -> action.getPlannedStatements(database,
PropertyGraphGeneratorTest.model()));
+ assertTrue(e.getMessage().contains("Table 'Person'"), e.getMessage());
+ verify(database, never()).checkTableExists(any(), anyString());
+ verify(database, never()).execStatement(anyString());
+ }
+
+ private static ActionCreatePropertyGraph action() {
+ ActionCreatePropertyGraph action = new ActionCreatePropertyGraph("property
graph");
+ action.setGraphName("g");
+ return action;
+ }
+
+ /**
+ * A database which records the statements it executes.
+ *
+ * @param failing The statements which fail
+ */
+ private static Database database(List<String> executed, Set<String> failing)
+ throws HopDatabaseException {
+ Database database = mock(Database.class);
+ when(database.execStatement(anyString()))
+ .thenAnswer(
+ invocation -> {
+ String sql = invocation.getArgument(0);
+ executed.add(sql);
+ if (failing.contains(sql)) {
+ throw new HopDatabaseException(sql + " failed");
+ }
+ return null;
+ });
+ return database;
+ }
+}
diff --git
a/plugins/tech/neo4j/src/test/java/org/apache/hop/neo4j/actions/propertygraph/PropertyGraphGeneratorTest.java
b/plugins/tech/neo4j/src/test/java/org/apache/hop/neo4j/actions/propertygraph/PropertyGraphGeneratorTest.java
index bc76b225c7..d4055136ff 100644
---
a/plugins/tech/neo4j/src/test/java/org/apache/hop/neo4j/actions/propertygraph/PropertyGraphGeneratorTest.java
+++
b/plugins/tech/neo4j/src/test/java/org/apache/hop/neo4j/actions/propertygraph/PropertyGraphGeneratorTest.java
@@ -161,6 +161,25 @@ class PropertyGraphGeneratorTest {
model(), null, List.of(new EdgeTableMapping("KNOWS", null,
null, "a, b", null))));
}
+ /** A table used by two nodes, or by a node and a relationship, is refused.
*/
+ @Test
+ void testValidateTables() throws Exception {
+ new PropertyGraphGenerator(model(), null, null).validateTables();
+
+ PropertyGraphGenerator twoNodes =
+ new PropertyGraphGenerator(
+ model(), List.of(new NodeTableMapping("Company", "Person", null)),
null);
+ HopException e = assertThrows(HopException.class,
twoNodes::validateTables);
+ assertTrue(e.getMessage().contains("node 'Person' and node 'Company'"),
e.getMessage());
+
+ PropertyGraphGenerator nodeAndEdge =
+ new PropertyGraphGenerator(
+ model(), null, List.of(new EdgeTableMapping("WORKS_AT", "Company",
null, null, null)));
+ e = assertThrows(HopException.class, nodeAndEdge::validateTables);
+ assertTrue(
+ e.getMessage().contains("node 'Company' and relationship 'WORKS_AT'"),
e.getMessage());
+ }
+
/** Names which the database quoting can't handle safely are refused before
generating SQL. */
@Test
void testValidateIdentifiers() throws Exception {