Import from CSV silently fails if name property is not unique

I understand that with manual input, the reserved name property does not have to be unique. However, we are finding that with CSV import, if the name is NOT unique, then that particular node import fails to set the property values correctly.

As a newbie, I'd like to know if this a known issue or if my import process is wrong, before I log a defect in GH.

We're trying to import a list of tables in a database. The tables are in several schemas, and so the same table name (it transpires) exists in multiple schemas! With the following cypher code,
// load file
LOAD CSV WITH HEADERS FROM "file:///Tables.csv" AS row
MERGE (c:Table {uuid:row.tableUUID})
ON MATCH
SET c.schemaName=row.schemaName

ONLY ONE of the tables get created with the correct name. For the others the name is not created, although the UUID is!

Am I doing anything wrong, or is this a defect in CSV import?

TIA,
Paolo

You are missing ON CREATE SET. Merge create node if not exist, but only with uuid parameter. ON CREATE set additional parameters when node is created, ON MATCH update parameters, but will be ignored if node not exist.

Try this:

LOAD CSV WITH HEADERS FROM "file:///Tables.csv" AS row
MERGE (c:Table {uuid:row.tableUUID})
ON CREATE SET c.schemaName=row.schemaName

You can combine to update is exist and create if not

…
MERGE (c:Table {uuid:row.tableUUID})
ON CREATE SET c.schemaName=row.schemaName
ON MATCH SET c.schemaName=row.schemaName

Thanks chikawick. I just noticed I gave the wrong example. Nevertheless, two pints to make:

  1. This was an initial load, so there was nothing to match (hence the ON CREATE clause only)
  2. I repeated the import (to a different label) and it worked fine - so I was unable to reproduce the problem!

This is the correct example (for completeness)
// load file (initial load only)
LOAD CSV WITH HEADERS FROM "file:///Tables.csv" AS row
MERGE (t:Table {uuid:row.tableUUID})
ON CREATE
SET t.name=row.tableName