Skip to content

Commit e88834e

Browse files
committed
Skip relationshipType if target is null
Otherwise we end up with relationshipTypes none of the relationships actually has
1 parent a66ac8e commit e88834e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

cypher-aggregation/src/main/java/org/neo4j/gds/projection/CypherAggregation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,10 @@ public void update(
195195
}
196196
}
197197

198-
var relImporter = this.relImporters.computeIfAbsent(relationshipType, this::newRelImporter);
199-
200198
var intermediateSourceId = loadNode(sourceNode, sourceNodeLabels, sourceNodePropertyValues);
201199

202200
if (targetNode != null) {
201+
var relImporter = this.relImporters.computeIfAbsent(relationshipType, this::newRelImporter);
203202
var intermediateTargetId = loadNode(targetNode, targetNodeLabels, targetNodePropertyValues);
204203

205204
if (this.relationshipPropertySchemas != null && !this.relationshipPropertySchemas.isEmpty()) {

cypher-aggregation/src/test/java/org/neo4j/gds/projection/CypherAggregationTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,20 @@ void testRelationshipType(String type) {
441441
.returns(4L, Graph::relationshipCount);
442442
}
443443

444+
445+
@Test
446+
void ignoreRelationshipTypeIfTargetIsNull() {
447+
runQuery(
448+
"UNWIND [[1, null, null], [1, 2, 'REL']] AS data" +
449+
" RETURN gds.alpha.graph.project('g', data[0], data[1], {}, {relationshipType: data[2]})"
450+
);
451+
452+
var graphStore = GraphStoreCatalog.get("", db.databaseName(), "g").graphStore();
453+
454+
assertThat(graphStore.relationshipCount()).isEqualTo(1);
455+
assertThat(graphStore.relationshipTypes()).containsOnly(org.neo4j.gds.RelationshipType.of("REL"));
456+
}
457+
444458
@Test
445459
void shouldNotFailOnMissingProperty() {
446460
var query = "MATCH (s:B)-[:REL]->(t:B) " +

0 commit comments

Comments
 (0)