History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: SES-713
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Arjohn Kampman
Reporter: Nick Giles
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Sesame

Query with strings in a maths expression results in an AssertionError during evaluation

Created: 09/Jun/10 03:36 PM   Updated: 07/Jul/10 04:32 PM
Component/s: Query Engine
Affects Version/s: 2.3.1
Fix Version/s: 2.3.2


 Description   
A query such as

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT * WHERE {
 ?foo rdfs:comment ?blah .
 FILTER ("foo" + "blah" = ?blah)
}

will not be caught as invalid during parsing, but will result in an AssertionError during evaluation. The case where the values being operated on by '+' are constants could be caught during parsing, but if they were variables they could not, so some error during evaluation seems sensible. However, a QueryEvaluationException would seem better, ideally with some information about exactly what the problem is (rather than "value must not be null" as currently).


public void testQuery() throws Exception {
String notANumber = "not a number";
String queryString = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">" + "SELECT * {\n"
+ " ?foo rdfs:comment ?blah .\n" + " FILTER ( \"" + notANumber + "\" + \"bar\" = ?blah )\n" + "}";

Repository repo = new SailRepository(new MemoryStore());
repo.initialize();
RepositoryConnection connection = repo.getConnection();
try {
TupleQuery query = connection.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
try {
query.evaluate();
fail("Should fail");
} catch (QueryEvaluationException e) {
// Would hope for one of these, with detail of the problem
assertTrue("Should contain some details of the problem", e.getMessage().contains(
notANumber));
}
} finally {
connection.close();
}

}


 All   Comments   Change History      Sort Order:
Comment by Arjohn Kampman [07/Jul/10 03:56 PM]
This is 'just' an issue with the query optimizer. The query shouldn't fail, as suggested, but rather return zero results. SPARQL specifies that invalid operations such as these result in a type error, which cause the filter to fail. The query optimizer could optimize away the entire query to a simple 'false' in this case.

Comment by Arjohn Kampman [07/Jul/10 04:32 PM]
The bug in the constant optimizer has been fixed.