知识库

错误“Cannot merge node using null property value for”解释

在运行 MERGE 操作(它是 MATCH 和/或 CREATE 的组合)时,如果 MERGE 对空属性执行 MATCH,可能会遇到 Cannot merge node using null property value for 的错误。例如,当使用以下输入文件 test.csv 时

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

并且 CSV 中的第三个值具有 NULL id 属性,如果运行

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;

这将报错

Cannot merge node using null property value for id

可以通过将 Cypher 语句重新运行为以下形式来避免此错误:

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;