Uploaded image for project: 'Blazegraph (by SYSTAP)'
  1. Blazegraph (by SYSTAP)
  2. BLZG-2098

Using query as subquery leads to NotMaterializedException

    Details

      Description

      Running this query:

      SELECT
      ?person ?personLabel
      (CONCAT(?award1Label, " (", ?country1Label, ")") AS ?award1)
      (CONCAT(?award2Label, " (", ?country2Label, ")") AS ?award2)
      WHERE {
        {
          SELECT ?person ?personLabel ?award1Label ?country1Label ?award2Label ?country2Label WHERE {
            ?person wdt:P31 wd:Q5;
                    wdt:P166 ?award1, ?award2.
            FILTER(?award1 != ?award2).
            ?award1 wdt:P17 ?country1.
            ?award2 wdt:P17 ?country2.
            FILTER(?country1 != ?country2).
            SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
          }
          LIMIT 25
        }
      }
      

      Leads to NotMaterializedException. The inside query runs just fine by itself and produces 25 results.

        Activity

        Hide
        stasmalyshev stasmalyshev added a comment -

        Unfortunately, still getting NME:

        ERROR: SPARQL-QUERY: queryStr=PREFIX wdt: 
        PREFIX wd: 
        PREFIX bd: 
        PREFIX wikibase: 
        
        SELECT ?val ?valLabel WHERE {
            {
              SELECT ?val ?valLabel WHERE {
                ?s wdt:P166 ?val .
                SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
               } LIMIT 25
           }
        } 
        java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: org.openrdf.query.QueryEvaluationException: com.bigdata.rdf.internal.NotMaterializedException: TermId(1U)
        	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        	at com.bigdata.rdf.sail.webapp.BigdataServlet.submitApiTask(BigdataServlet.java:281)
        	at com.bigdata.rdf.sail.webapp.QueryServlet.doSparqlQuery(QueryServlet.java:653)
        	at com.bigdata.rdf.sail.webapp.QueryServlet.doPost(QueryServlet.java:273)
        	at com.bigdata.rdf.sail.webapp.RESTServlet.doPost(RESTServlet.java:269)
        	at com.bigdata.rdf.sail.webapp.MultiTenancyServlet.doPost(MultiTenancyServlet.java:193)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
        	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
        	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
        	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
        	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
        	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
        	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
        	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
        	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
        	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
        	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        	at org.eclipse.jetty.server.Server.handle(Server.java:497)
        	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
        	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
        	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
        	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
        	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
        	at java.lang.Thread.run(Thread.java:745)
        Caused by: java.util.concurrent.ExecutionException: org.openrdf.query.QueryEvaluationException: com.bigdata.rdf.internal.NotMaterializedException: TermId(1U)
        	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        	at com.bigdata.rdf.sail.webapp.QueryServlet$SparqlQueryTask.call(QueryServlet.java:864)
        	at com.bigdata.rdf.sail.webapp.QueryServlet$SparqlQueryTask.call(QueryServlet.java:670)
        	at com.bigdata.rdf.task.ApiTaskForIndexManager.call(ApiTaskForIndexManager.java:68)
        	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        	... 1 more
        Caused by: org.openrdf.query.QueryEvaluationException: com.bigdata.rdf.internal.NotMaterializedException: TermId(1U)
        	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(1U)
        	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
        

        Used the reproduction from above, with P166, to reproduce this. As before, setting query to non-analytic mode removes the problem.

        Show
        stasmalyshev stasmalyshev added a comment - Unfortunately, still getting NME: ERROR: SPARQL-QUERY: queryStr=PREFIX wdt: PREFIX wd: PREFIX bd: PREFIX wikibase: SELECT ?val ?valLabel WHERE { { SELECT ?val ?valLabel WHERE { ?s wdt:P166 ?val . SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } LIMIT 25 } } java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: org.openrdf.query.QueryEvaluationException: com.bigdata.rdf.internal.NotMaterializedException: TermId(1U) at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:192) at com.bigdata.rdf.sail.webapp.BigdataServlet.submitApiTask(BigdataServlet.java:281) at com.bigdata.rdf.sail.webapp.QueryServlet.doSparqlQuery(QueryServlet.java:653) at com.bigdata.rdf.sail.webapp.QueryServlet.doPost(QueryServlet.java:273) at com.bigdata.rdf.sail.webapp.RESTServlet.doPost(RESTServlet.java:269) at com.bigdata.rdf.sail.webapp.MultiTenancyServlet.doPost(MultiTenancyServlet.java:193) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:497) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:745) Caused by: java.util.concurrent.ExecutionException: org.openrdf.query.QueryEvaluationException: com.bigdata.rdf.internal.NotMaterializedException: TermId(1U) at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:192) at com.bigdata.rdf.sail.webapp.QueryServlet$SparqlQueryTask.call(QueryServlet.java:864) at com.bigdata.rdf.sail.webapp.QueryServlet$SparqlQueryTask.call(QueryServlet.java:670) at com.bigdata.rdf.task.ApiTaskForIndexManager.call(ApiTaskForIndexManager.java:68) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ... 1 more Caused by: org.openrdf.query.QueryEvaluationException: com.bigdata.rdf.internal.NotMaterializedException: TermId(1U) 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(1U) 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 Used the reproduction from above, with P166, to reproduce this. As before, setting query to non-analytic mode removes the problem.
        Hide
        michaelschmidt michaelschmidt added a comment -

        Yes, can confirm that this does indeed not solve the problem. I succeeded in setting up a local reproducer of the problem, without the WDQS extensions.

        Data:

        <http://s> <http://p> <http://o> .
        <http://o> rdfs:label "o label" .
        

        Query:

        SELECT ?val ?valLabel WHERE {
            {
              SELECT ?val ?valLabel WHERE {
                ?s <http://p> ?val .
                SERVICE <http://localhost:9999/bigdata/sparql> { ?val rdfs:label ?valLabel . }
               } LIMIT 25
           }
        } 
        

        This still breaks, even with the proposed fix. Looking at this now.

        Show
        michaelschmidt michaelschmidt added a comment - Yes, can confirm that this does indeed not solve the problem. I succeeded in setting up a local reproducer of the problem, without the WDQS extensions. Data: <http: //s> <http://p> <http://o> . <http: //o> rdfs:label "o label" . Query: SELECT ?val ?valLabel WHERE { { SELECT ?val ?valLabel WHERE { ?s <http: //p> ?val . SERVICE <http: //localhost:9999/bigdata/sparql> { ?val rdfs:label ?valLabel . } } LIMIT 25 } } This still breaks, even with the proposed fix. Looking at this now.
        Hide
        stasmalyshev stasmalyshev added a comment -

        Looks like the latest patch does fix the issue. It is no longer reproducing on the test server (didn't test on production since I don't have full build yet but very likely the same result will happen there).

        Show
        stasmalyshev stasmalyshev added a comment - Looks like the latest patch does fix the issue. It is no longer reproducing on the test server (didn't test on production since I don't have full build yet but very likely the same result will happen there).
        Hide
        michaelschmidt michaelschmidt added a comment -

        Updated patch is at https://github.com/blazegraph/bigdata/pull/493. Please review.

        Show
        michaelschmidt michaelschmidt added a comment - Updated patch is at https://github.com/blazegraph/bigdata/pull/493 . Please review.
        Hide
        stasmalyshev stasmalyshev added a comment - - edited

        This query:

        SELECT ?lang #?langLabel
        WHERE {
        {
                SELECT ?lang ?langLabel WHERE {
        		BIND(wd:Q154755 AS ?lang)
        		SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
        	}
        }
        FILTER("Ada"@en = ?langLabel) .
        }
        

        still returns no result unless I add ?langLabel to projection. Original query no longer NMEs though.

        Show
        stasmalyshev stasmalyshev added a comment - - edited This query: SELECT ?lang #?langLabel WHERE { { SELECT ?lang ?langLabel WHERE { BIND(wd:Q154755 AS ?lang) SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . } } } FILTER( "Ada" @en = ?langLabel) . } still returns no result unless I add ?langLabel to projection. Original query no longer NMEs though.

          People

          • Assignee:
            michaelschmidt michaelschmidt
            Reporter:
            stasmalyshev stasmalyshev
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: