Reputation: 51
Write the following RDF data into MarkLogic:
<http://John> <http://have> 2.1123519E7 .
Then execute the following query:
SELECT *
WHERE { ?s ?p ?o. }
The query result is:
?s | ?p | ?o |
---|---|---|
<http://John> |
<http://have> |
"21123519"^^xsd:double |
The expected query result is:
?s | ?p | ?o |
---|---|---|
<http://John> |
<http://have> |
"2.1123519E7"^^xsd:double |
The written data is expressed in scientific notation, but the data returned in query result is not in scientific notation. Will there be some inconsistencies?
Executing the SparQL query with Java Client API will get the unexpected query result. But executing it in Query Console will get the expected query result.
This query can also return the expected query result in Apache Jena and RDF4j.
Can someone give me an answer or a hint about it?
Upvotes: 2
Views: 55
Reputation: 7770
As Mads points points out: the numbers are the same.
However, this is an interesting one.
MarkLogic does keep and understand the scientific notation. The REST API also handles this for many return types. I tested your query against the /v1/sparql
endpoint:
Accept Header: application/sparql-results+xml
...
<result>
<binding name="s">
<uri>http://John</uri>
</binding>
<binding name="p">
<uri>http://have</uri>
</binding>
<binding name="o">
<literal datatype="http://www.w3.org/2001/XMLSchema#double">2.1123519E7</literal>
</binding>
</result>
...
** Accept Header: text/csv **
s,p,o
http://John,http://have,2.1123519E7
Same for HTML ETC..
However, for JSON, things are different:
{
"s": {
"type": "uri",
"value": "http://John"
},
"p": {
"type": "uri",
"value": "http://have"
},
"o": {
"datatype": "http://www.w3.org/2001/XMLSchema#double",
"type": "literal",
"value": "21123519"
}
}
This matches the fact that the scientific notation appears to be lost as double for JSON:
JSON.parse('{ "foo" : 2.1123519E7}')
//return:
{
"foo": 21123519
}
So, it all comes down to how you are requesting your results in your call to MarkLogic. Some response types return what you expect. At least one (JSON) does not. At this point, I suggest opening a ticket under the Java API project: https://github.com/marklogic/java-client-api/issues
Upvotes: 3