cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

RETURN apoc.coll.max([1,2,3,4,5]) result is NULL?

Using
Neo4j 4.0.3
APOC apoc-4.0.0.17-all.jar
Neo4j Browser version: 4.0.5

As part of an analysis process I get 5 (dirty) collections mixed with numbers, text ans NULLs. I'd like to find the maximum number over all 5 collections. Therefore I did something like
<RETURN apoc.coll.max([0]++[1,2,3,4,5,6]+[7,0]+["ABC"]+) > ==> 7 (fine)

Unfortunately some of the collections have NULL values
<return apoc.coll.max([NULL]+[NULL]+[NULL]+[0,1,2]) > ==> 2 (fine)
<return apoc.coll.max([0,1,2]+[NULL])> ==> 2 (fine)

But
<return apoc.coll.max([NULL]+[NULL]+[NULL]+[0,1,2]+[NULL]) > ==> NULL

afterwords executing again
<return apoc.coll.max([0,1,2]) > ==> NULL

The only chance to get rid of this NULL is to restart the database

Additional to this:
<apoc.coll.max([""]++[1,2,3,4,5,6]+[7,0]+["ABC"]+)> ==> "ABC"
I would like to have the control, that the apoc.coll.max evaluates only numeric values and not occasionally text.

2 REPLIES 2

Hello @klaus.bermuth

You could use a comprehension list with a CASE to clean your list to make sure to have only integers

Regards,
Cobra

Hey,

There's a bug in versions before 4.0.4 with respect to how apoc.coll.min and apoc.coll.max work. If you bump your Neo4j version that should sort it out.

See the note on the APOC releases page about this issue - https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/tag/4.0.0.11