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

Named subquery has problem with aggrgate values and HAVING

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: BLAZEGRAPH_2_1_4
    • Fix Version/s: None
    • Component/s: Wikidata Query Service
    • Labels:
      None

      Description

      This query:

      SELECT ?x WHERE {
        {
          SELECT ?x (COUNT(*) AS ?count) WHERE {
            ?x a schema:Dataset.
          }
          GROUP BY ?x
          HAVING(?count > 0)
        }
      }
      

      works fine. However, if rewritten using a subquery:

      SELECT ?x WITH {
        SELECT ?x (COUNT(*) AS ?count) WHERE {
          ?x a schema:Dataset.
        }
        GROUP BY ?x
        HAVING(?count > 0)
      } AS %x WHERE {
        INCLUDE %x.
      }
      

      the same query produces an exception:

      SPARQL-QUERY: queryStr=SELECT ?x WITH {
        SELECT ?x (COUNT(*) AS ?count) WHERE {
          ?x a schema:Dataset.
        }
        GROUP BY ?x
        HAVING(?count > 0)
      } AS %x WHERE {
        INCLUDE %x.
      }
      java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Non-aggregate variable in select expression: x
      	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:286)
      	at com.bigdata.rdf.sail.webapp.QueryServlet.doSparqlQuery(QueryServlet.java:653)
      	at com.bigdata.rdf.sail.webapp.QueryServlet.doGet(QueryServlet.java:288)
      	at com.bigdata.rdf.sail.webapp.RESTServlet.doGet(RESTServlet.java:240)
      	at com.bigdata.rdf.sail.webapp.MultiTenancyServlet.doGet(MultiTenancyServlet.java:271)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:769)
      	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
      	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:1125)
      	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:1059)
      	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:311)
      	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
      	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:610)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:539)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Non-aggregate variable in select expression: x
      	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: java.lang.IllegalArgumentException: Non-aggregate variable in select expression: x
      	at com.bigdata.bop.solutions.GroupByState.isAggregate(GroupByState.java:467)
      	at com.bigdata.bop.solutions.GroupByState.isAggregate(GroupByState.java:404)
      	at com.bigdata.bop.solutions.GroupByState.<init>(GroupByState.java:251)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.addAggregation(AST2BOpUtility.java:4618)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertQueryBaseWithScopedVars(AST2BOpUtility.java:534)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertQueryBase(AST2BOpUtility.java:394)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.addNamedSubquery(AST2BOpUtility.java:953)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.addNamedSubqueries(AST2BOpUtility.java:922)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertQueryBaseWithScopedVars(AST2BOpUtility.java:466)
      	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:211)
      	at com.bigdata.rdf.sail.BigdataSailTupleQuery.evaluate(BigdataSailTupleQuery.java:79)
      	at com.bigdata.rdf.sail.BigdataSailTupleQuery.evaluate(BigdataSailTupleQuery.java:61)
      	at org.openrdf.repository.sail.SailTupleQuery.evaluate(SailTupleQuery.java:75)
      	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
      

        Attachments

          Activity

            People

            Assignee:
            beebs Brad Bebee
            Reporter:
            stasmalyshev stasmalyshev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: