Page MenuHomePhabricator

UnsupportedOperationException on property path in EXISTS
Closed, ResolvedPublic

Description

Minimal query:

SELECT * { BIND(EXISTS { ?a p:1/p:2 ?b. } AS ?t) }

Caused by: java.lang.UnsupportedOperationException: child:
PropertyPathNode(VarNode(a), com.bigdata.rdf.sparql.ast.PathNode(PathAlternative), VarNode(c)) [scope=DEFAULT_CONTEXTS]
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertJoinGroup(AST2BOpUtility.java:3383)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertJoinGroupOrUnion(AST2BOpUtility.java:2586)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.addSubgroup(AST2BOpUtility.java:4352)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertJoinGroup(AST2BOpUtility.java:3342)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertJoinGroupOrUnion(AST2BOpUtility.java:2586)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.addExistsSubqueryFast(AST2BOpUtility.java:2426)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.addExistsSubquery(AST2BOpUtility.java:2253)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertJoinGroup(AST2BOpUtility.java:3296)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertJoinGroupOrUnion(AST2BOpUtility.java:2586)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertQueryBaseWithScopedVars(AST2BOpUtility.java:474)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convert(AST2BOpUtility.java:287)
at com.bigdata.rdf.sparql.ast.eval.ASTEvalHelper.optimizeQuery(ASTEvalHelper.java:426)
at com.bigdata.rdf.sparql.ast.eval.ASTEvalHelper.evaluateTupleQuery(ASTEvalHelper.java:212)

Looks like a bug to me (almost certainly upstream).

Here’s the unreduced query:

# % of unsourced religion statements by religion
SELECT ?religion ?religionLabel ?count ?anyReferencedCount ?realReferencedCount (100*?anyReferencedCount/?count AS ?anyPercent) (100*?realReferencedCount/?count AS ?realPercent) WITH {
  SELECT ?religion (COUNT(?statement) AS ?count) (SUM(?anyeferences) AS ?anyReferencedCount) (SUM(?realReferences) AS ?realReferencedCount) WHERE {
    ?item p:P140 ?statement.
    ?statement ps:P140 ?religion.
    BIND(IF(EXISTS { ?statement prov:wasDerivedFrom ?reference. }, 1, 0) AS ?anyReferences)
    BIND(IF(EXISTS { ?statement prov:wasDerivedFrom ?reference. MINUS { ?reference pr:P143/wdt:P31 wd:Q10876391. } }, 1, 0) AS ?realReferences)
  }
  GROUP BY ?religion
} AS %results WHERE {
  INCLUDE %results.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?count)

Event Timeline

Restricted Application added a project: Discovery. · View Herald TranscriptAug 13 2017, 1:20 PM
Restricted Application added subscribers: PokestarFan, Aklapper. · View Herald Transcript
Lucas_Werkmeister_WMDE renamed this task from UnsupportedOperationException on BIND + EXISTS + MINUS + property path to UnsupportedOperationException on property path in EXISTS.Aug 13 2017, 1:25 PM
Lucas_Werkmeister_WMDE updated the task description. (Show Details)
Lucas_Werkmeister_WMDE updated the task description. (Show Details)

Hmm... I wasn't aware EXISTS works in this way... I'd just use OPTIONAL+BOUND().

Smalyshev triaged this task as Normal priority.Sep 25 2017, 1:35 AM

Change 533110 had a related patch set uploaded (by Smalyshev; owner: Igor Kim):
[wikidata/query/blazegraph@master] Fix UnsupportedOperationException on property path in EXISTS

https://gerrit.wikimedia.org/r/533110

Change 533110 merged by Smalyshev:
[wikidata/query/blazegraph@master] Fix UnsupportedOperationException on property path in EXISTS

https://gerrit.wikimedia.org/r/533110

debt closed this task as Resolved.Sep 5 2019, 6:47 PM
debt claimed this task.