penguin2048
penguin2048

Reputation: 1343

Double data type not working with RDF star query

Apache Jena is not able to query RDF Star Triples that have a double data type in them. Here is the code for reproduction of the issue with Jena 3.17 (it can be reproduced on other versions too).

Dataset dataset = TDB2Factory.createDataset();
Model tempModel = ModelFactory.createDefaultModel();
StringReader reader = new StringReader("@prefix : <http://ex#> "
                                     + "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> "
                                     + ":rk :val \"1.0\"^^xsd:double ."
                                     + "<<:rk :val \"1.0\"^^xsd:double>> :p_key 1");
RDFDataMgr.read(tempModel, reader, null, Lang.TURTLE);

dataset.begin(TxnType.WRITE);
Graph repositoryGraph = dataset.getNamedModel("RAW_MODEL").getGraph();
StmtIterator it = tempModel.listStatements();
while(it.hasNext()) {
    repositoryGraph.add(it.nextStatement().asTriple());
}
dataset.commit()
dataset.end()

Now during query time, I am using the following code.

dataset.begin(TxnType.READ);
Query query = QueryFactory.create("SELECT ?s ?o ?id WHERE {"
                                + "<<?s <http://ex#val> ?o>> <http://ex#p_key> ?id"
                                + "}");
try (QueryExecution exec = QueryExecutionFactory.create(query, dataset.getUnionModel())) {
    ResultSet result = exec.execSelect();
    while (result.hasNext()) {
        System.out.println(result.next().toString());
    }
}
dataset.end()

The above query fails to fetch any result. However, if I just replace xsd:double with xsd:float or xsd:decimal the results are fetched. Hence, I am looking for help to understand what is causing this issue with xsd:double?

Note: You might think that I am not using the most optimal way to make insertions. However, this was due to other requirements in the code and reproduction of issue is possible through this route.

Upvotes: 0

Views: 117

Answers (1)

AndyS
AndyS

Reputation: 16630

It works in Jena 4.0.0.

In 3.17.0 - SPARQL was more like the original RDF* in its use of indexing.

As a consequence, the non-canonical term map cause a problem.

Try a lexical form of "1.0e0"^^xsd:double or v 4.x.x.

Upvotes: 2

Related Questions