gjhiggins/rdfextras — Issue #22: DESC() & ASC() broken in ORDER BY clauses
Author: gjhiggins
Created: 2011-10-19 03:00:51+00:00
State: open
Labels: Priority-Medium, Type-Defect

Originally filed by christop...@gmail.com on 2011-02-06T11:52:57

Passing query 'SELECT ?s WHERE {?s ?p ?o} ORDER BY DESC(?s)' will raise an Exception:

...
File "/tmp/env/lib/python2.6/site-packages/rdflib/graph.py", line 770, in query
return result(processor.query(query_object))
File "/tmp/env/lib/python2.6/site-packages/rdfextras-0.1a-py2.6.egg/rdfextras/sparql/processor.py", line 43, in query
extensionFunctions=extensionFunctions)
File "/tmp/env/lib/python2.6/site-packages/rdfextras-0.1a-py2.6.egg/rdfextras/sparql/algebra.py", line 402, in TopEvaluate
"Support for ORDER BY with anything other than a variable is not supported: %s"%order_expr
AssertionError: Support for ORDER BY with anything other than a variable is not supported: FILTER o

This bug is triggered by errorneous parsing. In addition to the wrong parse result the algebra will raise an Exception as no simple variable is produced by the parser when following rules defined in the SPARQL specification (http://www.w3.org/TR/rdf-sparql-query/#rOrderCondition).

See attached patch for a fix addressing both issues.