marklogic / marklogic-jena

Adapter for using MarkLogic with the Jena RDF Framework
Other
5 stars 11 forks source link

SPARQL select on non-existing variable value should return null, but throws exception #9

Closed kkanthet closed 8 years ago

kkanthet commented 9 years ago
String query7 = "PREFIX  bb: <http://marklogic.com/baseball/players#>  SELECT  ?n FROM <http://marklogic.com/Graph1> WHERE"
                + "{ ?s bb:position ?o.} LIMIT 2";
QueryExecution queryExec7 = QueryExecutionFactory.create(query7, dataSet);
ResultSet results7 = queryExec7.execSelect();
Throws string: key: value Exception, Expected to return null string.

Same query in qconsole returns "null"

 Exception::
com.hp.hpl.jena.sparql.resultset.ResultSetException: Not a string: key: value
    at com.hp.hpl.jena.sparql.resultset.JSONInput.stringOrNull(JSONInput.java:254)
    at com.hp.hpl.jena.sparql.resultset.JSONInput.parseOneTerm(JSONInput.java:223)
    at com.hp.hpl.jena.sparql.resultset.JSONInput.parse(JSONInput.java:192)
    at com.hp.hpl.jena.sparql.resultset.JSONInput.process(JSONInput.java:109)
    at com.hp.hpl.jena.sparql.resultset.JSONInput.fromJSON(JSONInput.java:66)
    at com.marklogic.semantics.jena.engine.MarkLogicQueryEngine.eval(MarkLogicQueryEngine.java:191)
    at com.hp.hpl.jena.sparql.engine.QueryEngineBase.evaluate(QueryEngineBase.java:137)
    at com.hp.hpl.jena.sparql.engine.QueryEngineBase.createPlan(QueryEngineBase.java:107)
    at com.hp.hpl.jena.sparql.engine.QueryEngineBase.getPlan(QueryEngineBase.java:88)
    at com.marklogic.semantics.jena.engine.MarkLogicQueryEngine$MarkLogicQueryEngineFactory.create(MarkLogicQueryEngine.java:215)
    at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.getPlan(QueryExecutionBase.java:547)
    at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.startQueryIterator(QueryExecutionBase.java:491)
    at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execResultSet(QueryExecutionBase.java:532)
    at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execSelect(QueryExecutionBase.java:183)
    at com.marklogic.jena.functionaltests.JenaSPARQLUpdateTests.test001StringQuery_withbinding(JenaSPARQLUpdateTests.java:285)
grechaw commented 9 years ago

Hi Kiran, I think this was a bug on the server, which is fixed now. In any event with my most recent changes it's not throwing an exception anymore.

grechaw commented 9 years ago

My test was not sufficient to verify. Will fix.

grechaw commented 9 years ago

Got it. This is a bug for fayez. The result set is returning null, unquoted, for null, whereas the SPARQL results expect "null" as a quoted string

grechaw commented 9 years ago

Created bugtrack bug to fix JSON serialization https://bugtrack.marklogic.com/35311

grechaw commented 9 years ago

Hi Kiran I verified the fix is in the server now.

kkanthet commented 9 years ago

Verified and added tests.