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.

Want better error handling in apoc.number.parseFloat()

clem
Graph Steward

I was trying to do a CSV import and I had a stray extra space at the end of my column name. So, it became the equivalent of:

LOAD CSV WITH HEADERS FROM "file:///import.txt" AS row
 FIELDTERMINATOR '\t' WITH
apoc.number.parseFloat(row.NonExistantFieldName) AS NonExistantFieldName
RETURN NonExistantFieldName

Failed to invoke function apoc.number.parseFloat: Caused by: java.lang.NullPointerException (Failure when processing file '[directory omitted]/import.txt' on line 2.)

But if I replace function apoc.number.parseFloat() with toFloat(), I get all null values instead of an exception being thrown. While at first glance, the null is a bit mysterious, at least it's not making me wonder if the first string has some mysterious value that is causing the function apoc.number.parseFloat to give up in an unexpected way.

Or even more simple way to cause this error:
match(n) return apoc.number.parseFloat(n.NonExistantFieldName)

Perhaps apoc.number.parseFloat() should return null to be consistent with toFloat()

1 REPLY 1

You're right.
To be consistent also with ParseError case (for example apoc.number.parseFloat('aaa')),
with null argument should be return null.
I've created an issue for this one: