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

Sub-select in INSERT cause NPE in UpdateExprBuilder

    Details

      Description

      An INSERT operation with a sub-select in its WHERE clause causes a null pointer exception.

      Given data:

      PREFIX foaf: <http://xmlns.com/foaf/0.1/>
      INSERT DATA {

      GRAPH <http://example/in> {

      <http://example/president25> foaf:givenName "Bill" .
      <http://example/president25> foaf:familyName "McKinley" .
      <http://example/president27> foaf:givenName "Bill" .
      <http://example/president27> foaf:familyName "Taft" .
      <http://example/president42> foaf:givenName "Bill" .
      <http://example/president42> foaf:familyName "Clinton" .
      }
      }

      This query works:

      SELECT ?s ?p ?v
      WHERE {

      SELECT ?s ?p ?v

      WHERE {

      GRAPH <http://example/in> { ?s ?p ?v . }
      }
      }

      But this Update doesn't work:

      INSERT {

      GRAPH <http://example/out> { ?s ?p ?v . }

      }
      WHERE {

      SELECT ?s ?p ?v

      WHERE {

      GRAPH <http://example/in> { ?s ?p ?v . }
      }
      }

      But this Update works:

      INSERT {

      GRAPH <http://example/out> { ?s ?p ?v . }

      }
      WHERE {

      #SELECT ?s ?p ?v

      1. WHERE {
        GRAPH <http://example/in> { ?s ?p ?v . }

        #}

        }

        Activity

        Hide
        bryanthompson bryanthompson added a comment -

        The stack trace associated with the nested sub-select UPDATE request is:

        java.lang.NullPointerException
        	at com.bigdata.rdf.sparql.ast.DeleteInsertGraph.setGraphPattern(DeleteInsertGraph.java:167)
        	at com.bigdata.rdf.sparql.ast.DeleteInsertGraph.setWhereClause(DeleteInsertGraph.java:152)
        	at com.bigdata.rdf.sail.sparql.UpdateExprBuilder.visit(UpdateExprBuilder.java:585)
        	at com.bigdata.rdf.sail.sparql.UpdateExprBuilder.visit(UpdateExprBuilder.java:1)
        	at com.bigdata.rdf.sail.sparql.ast.ASTModify.jjtAccept(ASTModify.java:27)
        	at com.bigdata.rdf.sail.sparql.Bigdata2ASTSPARQLParser.parseUpdate2(Bigdata2ASTSPARQLParser.java:255)
        	at com.bigdata.rdf.sail.webapp.BigdataRDFContext.getQueryTask(BigdataRDFContext.java:1132)
        	at com.bigdata.rdf.sail.webapp.QueryServlet.doUpdate(QueryServlet.java:329)
        	at com.bigdata.rdf.sail.webapp.QueryServlet.doPost(QueryServlet.java:115)
        	at com.bigdata.rdf.sail.webapp.RESTServlet.doPost(RESTServlet.java:133)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:534)
        	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:475)
        	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:929)
        	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:403)
        	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:864)
        	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
        	at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:47)
        	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:114)
        	at org.eclipse.jetty.server.Server.handle(Server.java:352)
        	at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:596)
        	at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1068)
        	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:805)
        	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)
        	at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:426)
        	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:508)
        	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.access$000(SelectChannelEndPoint.java:34)
        	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
        	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:451)
        	at java.lang.Thread.run(Thread.java:680)
        

        Please attach stack traces in the future. It makes it a bit easier for us to look into the problem. In fact, this exception was thrown when producing the operator tree, not during query evaluation. With the stack trace, we could have identified this immediately.

        Show
        bryanthompson bryanthompson added a comment - The stack trace associated with the nested sub-select UPDATE request is: java.lang.NullPointerException at com.bigdata.rdf.sparql.ast.DeleteInsertGraph.setGraphPattern(DeleteInsertGraph.java:167) at com.bigdata.rdf.sparql.ast.DeleteInsertGraph.setWhereClause(DeleteInsertGraph.java:152) at com.bigdata.rdf.sail.sparql.UpdateExprBuilder.visit(UpdateExprBuilder.java:585) at com.bigdata.rdf.sail.sparql.UpdateExprBuilder.visit(UpdateExprBuilder.java:1) at com.bigdata.rdf.sail.sparql.ast.ASTModify.jjtAccept(ASTModify.java:27) at com.bigdata.rdf.sail.sparql.Bigdata2ASTSPARQLParser.parseUpdate2(Bigdata2ASTSPARQLParser.java:255) at com.bigdata.rdf.sail.webapp.BigdataRDFContext.getQueryTask(BigdataRDFContext.java:1132) at com.bigdata.rdf.sail.webapp.QueryServlet.doUpdate(QueryServlet.java:329) at com.bigdata.rdf.sail.webapp.QueryServlet.doPost(QueryServlet.java:115) at com.bigdata.rdf.sail.webapp.RESTServlet.doPost(RESTServlet.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:534) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:475) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:929) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:403) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:864) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:47) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:114) at org.eclipse.jetty.server.Server.handle(Server.java:352) at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:596) at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1068) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:805) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218) at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:426) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:508) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.access$000(SelectChannelEndPoint.java:34) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:451) at java.lang.Thread.run(Thread.java:680) Please attach stack traces in the future. It makes it a bit easier for us to look into the problem. In fact, this exception was thrown when producing the operator tree, not during query evaluation. With the stack trace, we could have identified this immediately.
        Hide
        bryanthompson bryanthompson added a comment -

        The problem was traced back to GroupGraphPatternBuilder. At approximately line 197 it was returning null. Evidently, there a requirement for the group to be returned in this UPDATE code path. The change was to replace the code there with the following lines:

                        @SuppressWarnings("rawtypes")
                        final GroupNodeBase group = new JoinGroupNode(subqueryRoot);
        
                        parentGP.add(group);
                        
                        ret2 = group;
        

        The existing code had the same semantics, but it was returning null rather than group.

        A unit test was written at the SPARQL UPDATE parser level to demonstrate the problem. The test now passes with this change. All existing parser and evaluation tests pass with this change.

        Committed revision r6355.

        Show
        bryanthompson bryanthompson added a comment - The problem was traced back to GroupGraphPatternBuilder. At approximately line 197 it was returning null. Evidently, there a requirement for the group to be returned in this UPDATE code path. The change was to replace the code there with the following lines: @SuppressWarnings("rawtypes") final GroupNodeBase group = new JoinGroupNode(subqueryRoot); parentGP.add(group); ret2 = group; The existing code had the same semantics, but it was returning null rather than group. A unit test was written at the SPARQL UPDATE parser level to demonstrate the problem. The test now passes with this change. All existing parser and evaluation tests pass with this change. Committed revision r6355.

          People

          • Assignee:
            bryanthompson bryanthompson
            Reporter:
            dbooth-boston dbooth-boston
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: