You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@mingfang Yes. I was just stating that this is also the case for edges. Vertices can have duplicate properties and edges can have duplicate properties. Properties are not unique.
@mingfang I stand corrected. It seems odd, though, that properties would be unique in this sense. We will likely need to adjust the contains versus equals operator for this case.
Also this is only a problem when multiple MERGE are called in the same query.
e.g. this works as expected, only one vertex is created after both queries.
SELECT * FROM cypher('playground', $$
unwind ["foo"] as each
merge (v:TEST {name: each})
return v
$$) AS (v agtype)
SELECT * FROM cypher('playground', $$
unwind ["foo"] as each
merge (v:TEST {name: each})
return v
$$) AS (v agtype)
I'm guessing that multiple MERGE in the same query somehow is not seeing each statement's "state" since the transaction is not committed yet. Totally a wild guess.
@mingfang The particular cause for this issue is hard to easily describe, especially without getting very technical. Suffice to say, that MERGE (within the execution of a MERGE command instance) can't (or doesn't) see what it has just created.
In most cases, this isn't an issue because MERGE only CREATEs what isn't already there. However, when it is driven externally, it is possible for it to have duplicates for duplicated data. I'm not sure if this is the only case where this is possible, though.
I am looking into how to allow MERGE to know prior to inserting a duplicate and if this can resolve the issue. This may take some time, though, to implement.
@mingfang Update: I currently have a fix for this and am reviewing it, creating test cases, and cleaning up the code. If all goes well, a PR should be available Monday or Tuesday.
Sorry for the long delay, but this particular issue required a bit of a rewrite of MERGE.
@mingfang This should be fixed in the master branch now. If you could verify it, and close the ticket provided it resolves the issue, that would be great.
Activity
mingfang commentedon Mar 16, 2024
maybe same as #1446
jrgemignani commentedon Mar 18, 2024
@mingfang This is expected behavior. The key
nameis a property of a vertex, in this case. Vertices and edges are allowed to have the same properties.mingfang commentedon Mar 18, 2024
@jrgemignani please note in my test case the problem is that MERGE created two vertices with the same name, and not one vertex and one edge.
jrgemignani commentedon Mar 18, 2024
@mingfang Yes. I was just stating that this is also the case for edges. Vertices can have duplicate properties and edges can have duplicate properties. Properties are not unique.
mingfang commentedon Mar 18, 2024
I'm sorry but I don't think that's correct.
I've tested this in neo4j and it only results in one vertex created, not two like in AGE.
Here is the neo4j doc that speaks directly to this
https://neo4j.com/docs/cypher-manual/current/clauses/merge/#merge-merge-single-node-specifying-both-label-and-property
Merging a single node with both label and property matching an existing node will not create a new node:jrgemignani commentedon Mar 18, 2024
@mingfang I stand corrected. It seems odd, though, that properties would be unique in this sense. We will likely need to adjust the contains versus equals operator for this case.
mingfang commentedon Mar 18, 2024
Also this is only a problem when multiple MERGE are called in the same query.
e.g. this works as expected, only one vertex is created after both queries.
I'm guessing that multiple MERGE in the same query somehow is not seeing each statement's "state" since the transaction is not committed yet. Totally a wild guess.
jrgemignani commentedon Mar 18, 2024
Yeah, the more that I look at it, the more it appears to fall there. Transaction bugs, though, can be a pain to fix. Especially, for merge.
jrgemignani commentedon Mar 20, 2024
@mingfang This is an interesting one.
jrgemignani commentedon Mar 21, 2024
@mingfang The particular cause for this issue is hard to easily describe, especially without getting very technical. Suffice to say, that MERGE (within the execution of a MERGE command instance) can't (or doesn't) see what it has just created.
In most cases, this isn't an issue because MERGE only CREATEs what isn't already there. However, when it is driven externally, it is possible for it to have duplicates for duplicated data. I'm not sure if this is the only case where this is possible, though.
I am looking into how to allow MERGE to know prior to inserting a duplicate and if this can resolve the issue. This may take some time, though, to implement.
mingfang commentedon Mar 21, 2024
@jrgemignani
Thanks for the update.
I appreciate all your hard work.
Thanks!
jrgemignani commentedon Mar 30, 2024
@mingfang Update: I currently have a fix for this and am reviewing it, creating test cases, and cleaning up the code. If all goes well, a PR should be available Monday or Tuesday.
Sorry for the long delay, but this particular issue required a bit of a rewrite of MERGE.
jrgemignani commentedon Apr 1, 2024
@mingfang PR #1718 should address this issue once it is reviewed and merged.
mingfang commentedon Apr 1, 2024
@jrgemignani Amazing. Thanks again!
jrgemignani commentedon Apr 2, 2024
@mingfang This should be fixed in the master branch now. If you could verify it, and close the ticket provided it resolves the issue, that would be great.
mingfang commentedon Apr 3, 2024
@jrgemignani
confirm fixed. Thank you!