Last modified: 2012-02-11 14:44:55 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T32993, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 30993 - SMW 1.6.1 with SMWSparqlStore: Erroneous SPARQL for property value comparison queries
SMW 1.6.1 with SMWSparqlStore: Erroneous SPARQL for property value comparison...
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-19 14:44 UTC by Matt Voysey
Modified: 2012-02-11 14:44 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Matt Voysey 2011-09-19 14:44:17 UTC
Using SMW 1.6.1 and SMWSparqlStore to use external triple store (TDB via Fuseki). A semantic query of the form:

{{#ask: [[Age::<75]] }}

Generates the following SPARQL query (namespace prefixes omitted):

SELECT DISTINCT ?result WHERE {
?result swivt:wikiPageSortKey ?resultsk .
?result property:Age ?v1 .
{ FILTER ( ?v1 <= "75"^^xsd:double )
}
}
ORDER BY ASC(?resultsk)
OFFSET 0
LIMIT 51

The above returns no results, because the FILTER is placed in a different group to the query - see the SPARQL Query Spec section "5.2.2 Scope of Filters" (http://www.w3.org/TR/rdf-sparql-query/#scopeFilters). Indeed, testing the same form of query using dbpedia's Virtuoso SPARQL server yields the error "Virtuoso 37000 Error SP031: SPARQL compiler: Variable 'v1' is used in subexpressions of the query but not assigned". I'm not sure it's valid SPARQL to filter within a graph with no variables.

The same problem also causes Special:SearchByProperty to not return any "nearby values" results for numeric properties.

I traced the source of this rogue nested group to SMW_SparqlStoreQueryEngine buildPropertyCondition method, around line 713:

$innerConditionString = $innerCondition->getCondition() . $innerCondition->getWeakConditionString();
  if ( $innerConditionString != '' ) {
    $condition .= "{ $innerConditionString}\n" ;
  }

Removing the '{' and '}' characters from the above fixes the problems and the queries then work OK, but I'm not sure whether it will break anything else.
Comment 1 Markus Krötzsch 2012-02-11 14:44:55 UTC
Fixed in r111235. The braces are now only placed if not a filter.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links