Neo4j-ETL import error from MySql 'Invalid constraint syntax'

Hi everyone,

I have tried to import database from Mysql to Neo4j, but there are some error report by logs.

Some keys has properties in MySql as unique, and these properties seems cant be import with syntax error. But I havent find the right place to replace the syntax.

(I have tried Neo4j database 5.9.0 and 4.4.22 mysql 8.0)
here is my full error:
- Direct driver instance 1668837760 created for server address localhost:7687

- Running ETL on Neo4j 5.9.0 - ENTERPRISE

- Direct driver instance 33419717 created for server address localhost:7687

- Starting reading metadataMapping

- Creating constraints on nodes

- Creating constraint for label Hangar and properties (h-number)

- Creating constraint for label Airplane and properties (reg-no)

- Creating constraint for label Plane-Type and properties (model)

- Creating constraint for label Pilot and properties (n-i-n)

- Creating constraint for label Perform-By and properties (rowIndex)

- Creating constraint for label Person and properties (n-i-n)

- Creating constraint for label Service and properties (s-date,reg-no)

- Creating nodes with label Hangar

- Creating nodes with label Airplane

- Creating nodes with label Plane-Type

- Creating nodes with label Pilot

- Creating nodes with label Perform-By

- Creating nodes with label Person

- Creating nodes with label Service

- Creating relationships of type SERVICE

- Creating relationships of type PERSON

- Creating relationships of type AIRPLANE

- Creating relationships of type PLANE_-_TYPE

- Creating relationships of type AIRPLANE

- Creating relationships of type HANGAR

- Creating relationships of type PERSON

- Creating relationships of type OWNED_-BY-DURING-_PERIOD

- Creating relationships of type FLIGHT

- Creating relationships of type CAN_-BE-WORKED-ON-_BY

- Creating relationships of type CAN_-BE-PILOTED-_BY

- Data imported with errors. Below the list of errors.

- For exception ClientException we got the following errors:

-

Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))

"CREATE CONSTRAINT ON (n:Hangar) ASSERT n.h-number IS UNIQUE"

^

-

Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))

"CREATE CONSTRAINT ON (n:Airplane) ASSERT n.reg-no IS UNIQUE"

^

-

Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))

"CREATE CONSTRAINT ON (n:Plane-Type) ASSERT n.model IS UNIQUE"

^

-

Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))

"CREATE CONSTRAINT ON (n:Pilot) ASSERT n.n-i-n IS UNIQUE"

^

-

Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))

"CREATE CONSTRAINT ON (n:Perform-By) ASSERT n.rowIndex IS UNIQUE"

^

-

Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))

"CREATE CONSTRAINT ON (n:Person) ASSERT n.n-i-n IS UNIQUE"

^

-

Unable to execute Query: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))

"CREATE CONSTRAINT ON (n:Service) ASSERT (n.s-date,n.reg-no) IS NODE KEY"

Hello! The syntax for creating constraints changed between Neo4j version 4 and version 5, and I don't believe the ETL tool supports Neo4j 5.0. So that's why the tool does not recognize the updated constraint syntax for that version. Could you try to import into a Neo4j 4.4 database?

1 Like

Thank you. I have tried version 4.4.0, the error turns into
'unable to execute statement: Cannot merge the following node because of null property value for 'n-i-n': (:Person {n-i-n: null})'
*Person is the table and n-i-n is the PK
Maybe the error is due to the PK characteristic?

Here is the full log:
- Reading options from file C:\Users\Lenovo\AppData\Local\Temp\import-tool-options.json.
- Reading metadata mapping from file: C:\Users\Lenovo\AppData\Local\Temp/mysql_ans_ex_ans_ex_mapping.json
- Direct driver instance 1668837760 created for server address localhost:7687
- Running ETL on Neo4j 4.3.22 - ENTERPRISE
- Direct driver instance 764826684 created for server address localhost:7687
- Starting reading metadataMapping
- Creating constraints on nodes
- Creating constraint for label Hangar and properties (h-number)
- Creating constraint for label Airplane and properties (reg-no)
- Creating constraint for label Plane-Type and properties (model)
- Creating constraint for label Pilot and properties (n-i-n)
- Creating constraint for label Perform-By and properties (rowIndex)
- Creating constraint for label Person and properties (n-i-n)
- Creating constraint for label Service and properties (s-date,reg-no)
- Creating nodes with label Hangar
- Creating nodes with label Airplane
- Creating nodes with label Plane-Type
- Creating nodes with label Pilot
- Creating nodes with label Perform-By
- Creating nodes with label Person
- Creating nodes with label Service
- Creating relationships of type SERVICE
- Creating relationships of type PERSON
- Creating relationships of type AIRPLANE
- Creating relationships of type PLANE_-_TYPE
- Creating relationships of type AIRPLANE
- Creating relationships of type HANGAR
- Creating relationships of type PERSON
- Creating relationships of type OWNED_-BY-DURING-_PERIOD
- Creating relationships of type FLIGHT
- Creating relationships of type CAN_-BE-WORKED-ON-_BY
- Creating relationships of type CAN_-BE-PILOTED-_BY
- Data imported with errors. Below the list of errors.
- For exception ClientException we got the following errors:
*- *
Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=4, name='constraint_1933e5a', type='UNIQUENESS', schema=(:Hangar {h-number}), ownedIndex=3 )'.
*- *
Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=6, name='constraint_5337d473', type='UNIQUENESS', schema=(:Airplane {reg-no}), ownedIndex=5 )'.
*- *
Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=8, name='constraint_78a00635', type='UNIQUENESS', schema=(:Plane-Type {model}), ownedIndex=7 )'.
*- *
Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=10, name='constraint_6ffb6489', type='UNIQUENESS', schema=(:Pilot {n-i-n}), ownedIndex=9 )'.
*- *
Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=12, name='constraint_6ed71327', type='UNIQUENESS', schema=(:Perform-By {rowIndex}), ownedIndex=11 )'.
*- *
Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=14, name='constraint_8aff69f6', type='UNIQUENESS', schema=(:Person {n-i-n}), ownedIndex=13 )'.
*- *
Unable to execute Query: An equivalent constraint already exists, 'Constraint( id=16, name='constraint_8d8c5c89', type='NODE KEY', schema=(:Service {s-date, reg-no}), ownedIndex=15 )'.
*- *
Unable to execute statement: Cannot merge the following node because of null property value for 'h-number': (:Hangar {h-number: null})
*- *
Process failed Transaction can't be committed. It has been rolled back either because of an error or explicit termination
*- *
Unable to execute statement: Cannot merge the following node because of null property value for 'reg-no': (:Airplane {reg-no: null})
- Closing driver instance 764826684
- Closing connection pool towards localhost:7687

It sounds like there is a n-i-n value that is null in the data set. Since that field is a primary key, it can't be null, which is why the import errors out. If you can review your data and ensure there is some type of value for every n-i-n entry, then that should fix that one!