Page MenuHomePhabricator

NotMaterializedException when one branch of UNION binds ?variable and other branch binds ?variableLabel and label service is used
Closed, ResolvedPublic

Description

SELECT ?xLabel WHERE {
  { BIND(wd:Q1 AS ?x). } UNION
  { BIND("none"@en AS ?xLabel). }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Query link

Stack trace (abridged):

Caused by: org.openrdf.query.QueryEvaluationException: com.bigdata.rdf.internal.NotMaterializedException: TermId(22199L)
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)
... 7 more
Caused by: com.bigdata.rdf.internal.NotMaterializedException: TermId(22199L)
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

Event Timeline

Restricted Application added projects: Wikidata, Discovery. · View Herald TranscriptMar 6 2017, 4:33 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

This is rather weird query - why you need a service if you already have the label bound?

Here is the real query – the relevant part is: either a statement is a normal statement and has a proper object (?object), in which case I want its label, or it’s a “no value” statement, in which case I want to bind ?objectLabel to "no value"@en. (In the real query, in the end I had to use rdfs:label anyways to make the GROUP_CONCAT in the SELECT clause work.)

Smalyshev triaged this task as Normal priority.Mar 6 2017, 8:59 PM

I see now, thanks. Will look into it, probably some conflict between service assumptions and existing bindings...

@WikidataFacts the query you provided however works. Could you provide a full query that didn't work for you? That'd make figuring out the problem easier.

Here’s a variation that triggers the error: query

It returns some partial results before the error message because the error is only triggered when the first “no value” is reached, in “abbot” – “applies to territorial jurisdiction” – no value. (To see the result list, comment out or remove line 24.)

WikidataFacts added a comment.EditedMar 12 2017, 8:21 PM

I think these are the same issue:

SELECT ?x ?xLabel WHERE {
  BIND(wd:Q42 AS ?x).
  BIND("Douglas Adams"@en AS ?xLabel).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Link

SELECT ?x ?xLabel WHERE {
  VALUES (?x ?xLabel) {
    (wd:Q42 "Douglas Adams"@en)
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Link

(Motivation for the second example: I have a selection of values with predefined labels, which may not match the Wikidata labels, but I still want to use the label service for other, unrelated variables.)

Lydia_Pintscher moved this task from incoming to monitoring on the Wikidata board.Mar 23 2017, 2:30 PM

Change 533112 had a related patch set uploaded (by Igor Kim; owner: Igor Kim):
[wikidata/query/blazegraph@master] Support for uncertainVars in ServiceNode

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

Change 533117 had a related patch set uploaded (by Igor Kim; owner: Igor Kim):
[wikidata/query/rdf@master] Fix NME on bind variable both by LabelService and some other clause

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

Change 533112 merged by Smalyshev:
[wikidata/query/blazegraph@master] Support for uncertainVars in ServiceNode

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

Change 533117 merged by jenkins-bot:
[wikidata/query/rdf@master] Fix NME on bind variable both by LabelService and some other clause

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

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