Page MenuHomePhabricator

Label service in subquery and outer query causes NotMaterializedException
Closed, DuplicatePublic

Description

SELECT ?aLabel ?bLabel WHERE {
  {
    SELECT ?a ?aLabel WHERE {
      BIND(wd:Q1 AS ?a)
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    }
  }
  BIND(wd:Q2 AS ?b)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}


Caused by: org.openrdf.query.QueryEvaluationException: com.bigdata.rdf.internal.NotMaterializedException: TermId(20445L)
at com.bigdata.rdf.sail.Bigdata2Sesame2BindingSetIterator.hasNext(Bigdata2Sesame2BindingSetIterator.java:188)
at info.aduna.iteration.IterationWrapper.hasNext(IterationWrapper.java:68)
at org.openrdf.query.QueryResults.report(QueryResults.java:155)
at org.openrdf.repository.sail.SailTupleQuery.evaluate(SailTupleQuery.java:76)
at com.bigdata.rdf.sail.webapp.BigdataRDFContext$TupleQueryTask.doQuery(BigdataRDFContext.java:1713)
at com.bigdata.rdf.sail.webapp.BigdataRDFContext$AbstractQueryTask.innerCall(BigdataRDFContext.java:1569)
at com.bigdata.rdf.sail.webapp.BigdataRDFContext$AbstractQueryTask.call(BigdataRDFContext.java:1534)
at com.bigdata.rdf.sail.webapp.BigdataRDFContext$AbstractQueryTask.call(BigdataRDFContext.java:747)
... 4 more
Caused by: com.bigdata.rdf.internal.NotMaterializedException: TermId(20445L)
at com.bigdata.rdf.internal.impl.AbstractIV.getValue(AbstractIV.java:993)
at com.bigdata.rdf.sail.Bigdata2Sesame2BindingSetIterator.getBindingSet(Bigdata2Sesame2BindingSetIterator.java:298)
at com.bigdata.rdf.sail.Bigdata2Sesame2BindingSetIterator.hasNext(Bigdata2Sesame2BindingSetIterator.java:140)
... 11 more

Workaround: explicitly instruct the outer label service that we only need ?b rdfs:label ?bLabel, or remove label service and ?aLabel from the subquery.

Here’s a further reduced query that results in the same error:

SELECT ?aLabel ?bLabel WHERE {
  { SELECT (wd:Q1 AS ?a) ?aLabel {} }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Removing ?a or ?aLabel from the subquery, or removing the binding from ?a (SELECT ?a … without any AS), all remove the error.