Cannot add NaN to a attribute

What version of Dgraph are you using?


Have you tried reproducing the issue with the latest release?

Not yet.

What is the hardware spec (RAM, OS)?

Ubuntu 1804

Steps to reproduce the issue (command/config used to run Dgraph).

Run the following mutation in Ratel

 set {
_:a <name> "foo".
_:a <rnd> "NaN"^^<xs:double>. 
_:b <name> "bar".
_:b <rnd> "NaN"^^<xs:double>.
_:c <name> "baz".
_:c <rnd> "NaN"^^<xs:double>.

Expected behaviour and actual result.

I expect this to work. I got the error message:

"errors": [
      "message": "Got invalid value: NaN",
      "extensions": {
        "code": "ErrorInvalidRequest"

Ironically, when I changed "NaN" to "nan" in my triples, I still get the same exact error, indicating that NaN was successfully parsed but somehow considered an invalid value.

I guess that a NaN element in dgraph is equivalent to not having the predicate. Although, I am not sure if we should support explicit nan values.