Knowledge Base

Explanation of error "Cannot merge node using null property value for"

When running a MERGE, which is a combination of MATCH and/or CREATE one may encounter an error of Cannot merge node using null property value for if the MERGE is performing a MATCH against a null property. For example, when using the following input file, test.csv

id,name,employee_number
101,Emil Eifrem, Neo001
102,Mary Smith, Neo002
,Joseph Wilson-contractor, Neo003

and such that the 3rd value in the CSV has a NULL id property, if one runs

load csv with headers from 'file:///test.csv' as row
merge (emp:Employee {id: row.id}) set emp.name=row.name, emp.employee_numer=row.employee_number;

this will error with

Cannot merge node using null property value for id

One can avoid this error by rerunning the cypher statement as

load csv with headers from 'file:///test.csv' as row  with row where row.id is not null
merge (emp:Employee {id: row.id}) set emp.name=row.name, emp.employee_numer=row.employee_number;