知识库

错误 "Cannot merge node using null property value for" 的解释

在执行 MERGE 时(它相当于 MATCH 和/或 CREATE 的组合),如果 MERGE 对一个为 null 的属性进行 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 中第 3 列的 id 属性为 NULL,如果运行

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;
© . This site is unofficial and not affiliated with Neo4j, Inc.