Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: expose isEqualCollection to cypher #151

Closed
dan-kez opened this issue Sep 20, 2016 · 5 comments · Fixed by #1313
Closed

Feature Request: expose isEqualCollection to cypher #151

dan-kez opened this issue Sep 20, 2016 · 5 comments · Fixed by #1313

Comments

@dan-kez
Copy link

dan-kez commented Sep 20, 2016

See: CollectionUtils#isEqualCollection

This would be very useful to check if two collections are the same. As far as I'm aware this isn't exposed to cypher.

@jexp
Copy link
Member

jexp commented Oct 29, 2016

Did you try in cypher [1,2,3] = [1,2,3] ?
Or where doesn't that hold true?

@InverseFalcon
Copy link
Collaborator

InverseFalcon commented Nov 8, 2016

Unless I'm mistaken, isEqualCollection() ignores ordering, it returns true if all elements in both collections are the same, and the cardinality (# of occurrences) of each element are the same.

In Cypher, [1,2,3] = [3,2,1] returns false. An isEqualCollection() call on these would return true.

I wanted to check if apoc.coll.containsAll(coll, values) already does this (seems it would ignore order but probably miss cardinality checking), but I can't seem to get it to work...I don't know what the return key is to use for YIELD (am I overlooking something simple, or is this a gap in the documentation of how to get a boolean result from APOC procedures?)

@jexp
Copy link
Member

jexp commented Dec 13, 2016

So length(c1) = length(c2) AND apoc.coll.containsAll(c1,c2) should do it?

@InverseFalcon
Copy link
Collaborator

InverseFalcon commented Dec 13, 2016

Oddly enough, containsAll() doesn't seem to be available with apoc-3.1.0.2-all, I get an error if attempting to call it:

There is no procedure with the name apoc.coll.containsAll registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

However, I don't think this would work, at least where elements of the collection repeat. This would work for [1,2,3] and [3,2,1], but would not work for [1,1,2,3] and [1,2,2,3], containsAll() in either direction would return true, and the length would be the same, but the cardinalities of the elements would be different. The backing collection used for this couldn't be a set. We would need some kind of counted bag collection or similar.

@jexp
Copy link
Member

jexp commented Dec 14, 2016 via email

vboulaye added a commit to vboulaye/neo4j-apoc-procedures that referenced this issue Oct 6, 2019
vboulaye added a commit to vboulaye/neo4j-apoc-procedures that referenced this issue Oct 18, 2019
vboulaye added a commit to vboulaye/neo4j-apoc-procedures that referenced this issue Oct 22, 2019
…in any order - simplify using groupingBy collector
vboulaye added a commit to vboulaye/neo4j-apoc-procedures that referenced this issue Oct 27, 2019
vboulaye added a commit to vboulaye/neo4j-apoc-procedures that referenced this issue Nov 4, 2019
vboulaye added a commit to vboulaye/neo4j-apoc-procedures that referenced this issue Nov 4, 2019
@jexp jexp closed this as completed in #1313 Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants