openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
https://vos.openlinksw.com
Other
853 stars 211 forks source link

Different numeric datatype of literal depending on return type #454

Open LorenzBuehmann opened 9 years ago

LorenzBuehmann commented 9 years ago

Tested against officila DBpedia endpoint (http://dbpedia.org/sparql)

When retrieving triples via CONSTRUCT queries, and among those triples there are literal values that are supposed to be xsd:double, depending on the chosen return type (TURTLE vs. N-TRIPLES) the literals have a different return type.

A test query is

CONSTRUCT { ?s <http://dbpedia.org/ontology/height> ?o . } { ?s <http://dbpedia.org/ontology/height> ?o . } LIMIT 1

TURTLE result:

@prefix xsd:    <http://www.w3.org/2001/XMLSchema#> .
@prefix dbo:    <http://dbpedia.org/ontology/> .
@prefix dbr:    <http://dbpedia.org/resource/> .
dbr:Adam_Yahiye_Gadahn  dbo:height  1.5240000000000000213 .

N-TRIPLE result:

<http://dbpedia.org/resource/Adam_Yahiye_Gadahn>    <http://dbpedia.org/ontology/height>    "1.524"^^<http://www.w3.org/2001/XMLSchema#double> .

Literals like 1.3 are supposed to be of type xsd:decimal in Turtle.

When querying for resources with the given literal, xsd:double has to be used, so I guess there is a bug in the Turtle serializer.

HughWilliams commented 9 years ago

We are looking into this reported issue ...

jindrichmynarz commented 7 years ago

@LorenzBuehmann: Have you resolved this issue somehow?

It seems that Virtuoso's serialization of xsd:double to Turtle is broken. While serializing the following query to N-Triples or RDF/XML preserves the xsd:double data type, Turtle export casts it to xsd:decimal:

PREFIX :    <http://example.com/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

CONSTRUCT {
  [] :p "1.23"^^xsd:double.
}
WHERE {}
LorenzBuehmann commented 7 years ago

@jindrichmynarz No, I just reported this bug, but I don't know whether this has been fixed in any new versions of Virtuoso. At least the version on which DBpedia is hosted still does return the implicit xsd:decimal for the Turtle format.

HughWilliams commented 7 years ago

this issue is on the agenda for development to look into ...

jindrichmynarz commented 7 years ago

Eventually, I worked around this by requesting data in N-Triples instead of Turtle, since xsd:doubles are correctly preserved in this serialization.

LorenzBuehmann commented 7 years ago

@jindrichmynarz I know that this works for N-Triples (see my initial post). That's why I reported this issue as I've seen that there is a difference between the N-Triples and Turtle serialization. I hope that it will be fixed together with the more critical https://github.com/openlink/virtuoso-opensource/issues/569 in the next version.