Details

      Description

      With the following query, simplified from a real query, the cryptic error message from an assertion failure is produced

      prefix eg: <http://example.org/>
      SELECT *
      WITH {
      SELECT *
      WHERE {
         {  SELECT *
            WHERE {
            }  
      }
      }} AS %__FullQuery
      
      WHERE {
      { SELECT (COUNT(*) AS $S__COUNT)
        WHERE {
          INCLUDE %__FullQuery
        }
       }
       INCLUDE %__FullQuery
      }
      

      root cause appears to be:

      Caused by: java.lang.AssertionError: Wildcard projection was not rewritten.
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertQueryBaseWithScopedVars(AST2BOpUtility.java:424)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertQueryBase(AST2BOpUtility.java:323)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.addSparql11Subquery(AST2BOpUtility.java:1723)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertJoinGroup(AST2BOpUtility.java:2584)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertJoinGroupOrUnion(AST2BOpUtility.java:2108)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertQueryBaseWithScopedVars(AST2BOpUtility.java:389)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertQueryBase(AST2BOpUtility.java:323)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.addNamedSubquery(AST2BOpUtility.java:774)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.addNamedSubqueries(AST2BOpUtility.java:751)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convertQueryBaseWithScopedVars(AST2BOpUtility.java:381)
      	at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convert(AST2BOpUtility.java:237)
      	at com.bigdata.rdf.sparql.ast.eval.ASTEvalHelper.evaluateTupleQuery(ASTEvalHelper.java:236)
      	at com.bigdata.rdf.sail.BigdataSailTupleQuery.evaluate(BigdataSailTupleQuery.java:93)
      	at com.bigdata.rdf.sail.BigdataSailTupleQuery.evaluate(BigdataSailTupleQuery.java:75)
      	at org.openrdf.repository.sail.SailTupleQuery.evaluate(SailTupleQuery.java:62)
      	at com.bigdata.rdf.sail.webapp.BigdataRDFContext$TupleQueryTask.doQuery(BigdataRDFContext.java:1211)
      	at com.bigdata.rdf.sail.webapp.BigdataRDFContext$AbstractQueryTask.call(BigdataRDFContext.java:1065)
      

        Activity

        Hide
        bradbebee bradbebee added a comment -

        Closed based on BLZG-1235 fix.

        Show
        bradbebee bradbebee added a comment - Closed based on BLZG-1235 fix.
        Hide
        bryanthompson bryanthompson added a comment -

        I think that this might be a bug in the postOrderIteratorWithAnnotations. Which lacks a unit test. And is only used by this one class.

        The following ticket should fix this one once it has been addressed.

        See BLZG-1235 BOpUtility.postOrderIteratorWithAnnotations() is has wrong visitation order.

        Show
        bryanthompson bryanthompson added a comment - I think that this might be a bug in the postOrderIteratorWithAnnotations. Which lacks a unit test. And is only used by this one class. The following ticket should fix this one once it has been addressed. See BLZG-1235 BOpUtility.postOrderIteratorWithAnnotations() is has wrong visitation order.
        Hide
        bryanthompson bryanthompson added a comment -

        I've pushed the test into the TICKET_757 branch on github. I am not convinced that the test is as intended yet. I am seeking clarification on the input AST before looking over the output AST in more detail.

        Show
        bryanthompson bryanthompson added a comment - I've pushed the test into the TICKET_757 branch on github. I am not convinced that the test is as intended yet. I am seeking clarification on the input AST before looking over the output AST in more detail.
        Hide
        bryanthompson bryanthompson added a comment -

        Re-opening to look at this test (from list). The test might or might not be good. The query that fails the rewrite is below. The optimizer fails to rewrite the SELECT * with the LIMIT/OFFSET.

        SELECT (COUNT(*) as ?c) {
          SELECT * {
            SELECT * WHERE { ?s ?p ?o }
          } LIMIT 21 OFFSET 0
        }
        

        The proposed test is:

        public void test_wildcardProjectionOptimizer03() {
        
                /*
               * Note: DO NOT share structures in this test!!!!
               */
                final IBindingSet[] bsets = new IBindingSet[] {};
        
                // The source AST.
                final QueryRoot given = new QueryRoot(QueryType.SELECT);
                {
                    final SubqueryRoot selectQuery = new SubqueryRoot(QueryType.SELECT);
                    {
                        final JoinGroupNode whereClause1 = new JoinGroupNode();
                        final StatementPatternNode spoPattern = new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null, Scope.DEFAULT_CONTEXTS);
                        whereClause1.addChild(spoPattern);
        
                        final ProjectionNode p = new ProjectionNode();
                        p.addProjectionVar(new VarNode("*"));
                        selectQuery.setProjection(p);
                        selectQuery.setWhereClause(whereClause1);
                    }
        
                    final SubqueryRoot sliceQuery = new SubqueryRoot(QueryType.SELECT);
                    {
                        final ProjectionNode p = new ProjectionNode();
                        p.addProjectionVar(new VarNode("*"));
                        sliceQuery.setProjection(p);
        
                        final JoinGroupNode whereClause = new JoinGroupNode();
                        whereClause.addChild(selectQuery);
        
                        sliceQuery.setSlice(new SliceNode(0, 21));
                    }
        
                    final FunctionNode countNode = new FunctionNode(
                            FunctionRegistry.COUNT,
                            Collections.EMPTY_MAP,
                            new VarNode("*"));
        
                    final ProjectionNode countProjection = new ProjectionNode();
                    countProjection.addProjectionExpression(new AssignmentNode(new VarNode("c"), countNode));
        
                    JoinGroupNode countWhere = new JoinGroupNode();
                    countWhere.addChild(sliceQuery);
        
                    given.setProjection(countProjection);
                    given.setWhereClause(countWhere);
                }
        
                final QueryRoot expected = new QueryRoot(QueryType.SELECT);
                {
                    final SubqueryRoot selectQuery = new SubqueryRoot(QueryType.SELECT);
                    {
                        final JoinGroupNode whereClause1 = new JoinGroupNode();
                        final StatementPatternNode spoPattern = new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null, Scope.DEFAULT_CONTEXTS);
                        whereClause1.addChild(spoPattern);
        
                        final ProjectionNode p = new ProjectionNode();
                        p.addProjectionVar(new VarNode("s"));
                        p.addProjectionVar(new VarNode("p"));
                        p.addProjectionVar(new VarNode("o"));
                        selectQuery.setProjection(p);
                        selectQuery.setWhereClause(whereClause1);
                    }
        
                    final SubqueryRoot sliceQuery = new SubqueryRoot(QueryType.SELECT);
                    {
                        final ProjectionNode p = new ProjectionNode();
                        p.addProjectionVar(new VarNode("s"));
                        p.addProjectionVar(new VarNode("p"));
                        p.addProjectionVar(new VarNode("o"));
        
                        sliceQuery.setProjection(p);
        
                        final JoinGroupNode whereClause = new JoinGroupNode();
                        whereClause.addChild(selectQuery);
        
                        sliceQuery.setSlice(new SliceNode(0, 21));
                    }
        
                    final FunctionNode countNode = new FunctionNode(
                            FunctionRegistry.COUNT,
                            Collections.EMPTY_MAP,
                            new VarNode("*"));
        
                    final ProjectionNode countProjection = new ProjectionNode();
                    countProjection.addProjectionExpression(new AssignmentNode(new VarNode("c"), countNode));
        
                    JoinGroupNode countWhere = new JoinGroupNode();
                    countWhere.addChild(sliceQuery);
        
                    expected.setProjection(countProjection);
                    expected.setWhereClause(countWhere);
                }
        
                final IASTOptimizer rewriter = new ASTWildcardProjectionOptimizer();
        
                final IQueryNode actual = rewriter.optimize(null/* AST2BOpContext */,
                        given/* queryNode */, bsets);
        
                assertSameAST(expected, actual);
        
            }
        
        
        Show
        bryanthompson bryanthompson added a comment - Re-opening to look at this test (from list). The test might or might not be good. The query that fails the rewrite is below. The optimizer fails to rewrite the SELECT * with the LIMIT/OFFSET. SELECT (COUNT(*) as ?c) { SELECT * { SELECT * WHERE { ?s ?p ?o } } LIMIT 21 OFFSET 0 } The proposed test is: public void test_wildcardProjectionOptimizer03() { /* * Note: DO NOT share structures in this test!!!! */ final IBindingSet[] bsets = new IBindingSet[] {}; // The source AST. final QueryRoot given = new QueryRoot(QueryType.SELECT); { final SubqueryRoot selectQuery = new SubqueryRoot(QueryType.SELECT); { final JoinGroupNode whereClause1 = new JoinGroupNode(); final StatementPatternNode spoPattern = new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null, Scope.DEFAULT_CONTEXTS); whereClause1.addChild(spoPattern); final ProjectionNode p = new ProjectionNode(); p.addProjectionVar(new VarNode("*")); selectQuery.setProjection(p); selectQuery.setWhereClause(whereClause1); } final SubqueryRoot sliceQuery = new SubqueryRoot(QueryType.SELECT); { final ProjectionNode p = new ProjectionNode(); p.addProjectionVar(new VarNode("*")); sliceQuery.setProjection(p); final JoinGroupNode whereClause = new JoinGroupNode(); whereClause.addChild(selectQuery); sliceQuery.setSlice(new SliceNode(0, 21)); } final FunctionNode countNode = new FunctionNode( FunctionRegistry.COUNT, Collections.EMPTY_MAP, new VarNode("*")); final ProjectionNode countProjection = new ProjectionNode(); countProjection.addProjectionExpression(new AssignmentNode(new VarNode("c"), countNode)); JoinGroupNode countWhere = new JoinGroupNode(); countWhere.addChild(sliceQuery); given.setProjection(countProjection); given.setWhereClause(countWhere); } final QueryRoot expected = new QueryRoot(QueryType.SELECT); { final SubqueryRoot selectQuery = new SubqueryRoot(QueryType.SELECT); { final JoinGroupNode whereClause1 = new JoinGroupNode(); final StatementPatternNode spoPattern = new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null, Scope.DEFAULT_CONTEXTS); whereClause1.addChild(spoPattern); final ProjectionNode p = new ProjectionNode(); p.addProjectionVar(new VarNode("s")); p.addProjectionVar(new VarNode("p")); p.addProjectionVar(new VarNode("o")); selectQuery.setProjection(p); selectQuery.setWhereClause(whereClause1); } final SubqueryRoot sliceQuery = new SubqueryRoot(QueryType.SELECT); { final ProjectionNode p = new ProjectionNode(); p.addProjectionVar(new VarNode("s")); p.addProjectionVar(new VarNode("p")); p.addProjectionVar(new VarNode("o")); sliceQuery.setProjection(p); final JoinGroupNode whereClause = new JoinGroupNode(); whereClause.addChild(selectQuery); sliceQuery.setSlice(new SliceNode(0, 21)); } final FunctionNode countNode = new FunctionNode( FunctionRegistry.COUNT, Collections.EMPTY_MAP, new VarNode("*")); final ProjectionNode countProjection = new ProjectionNode(); countProjection.addProjectionExpression(new AssignmentNode(new VarNode("c"), countNode)); JoinGroupNode countWhere = new JoinGroupNode(); countWhere.addChild(sliceQuery); expected.setProjection(countProjection); expected.setWhereClause(countWhere); } final IASTOptimizer rewriter = new ASTWildcardProjectionOptimizer(); final IQueryNode actual = rewriter.optimize(null/* AST2BOpContext */, given/* queryNode */, bsets); assertSameAST(expected, actual); }
        Hide
        bryanthompson bryanthompson added a comment -

        Fix for BLZG-843 (wildcard project not rewritten in nested subqueries and nested named subqueries)

        Commit 4472f6699635ae6fcb2d9a383d5f3d7f6ebadedc to github master.

        Show
        bryanthompson bryanthompson added a comment - Fix for BLZG-843 (wildcard project not rewritten in nested subqueries and nested named subqueries) Commit 4472f6699635ae6fcb2d9a383d5f3d7f6ebadedc to github master.
        Hide
        bryanthompson bryanthompson added a comment -

        A second code change is required to get the original query to execute.

                /*
                 * NAMED SUBQUERIES
                 * 
                 * Rewrite the named subquery projections before the where clause.
                 */
                for (NamedSubqueryRoot subqueryRoot : queryRoot
                            .getNamedSubqueries()) {
        
                        rewriteProjection(sa, subqueryRoot);
               }
        

        needs to be replaced with:

                /*
                 * NAMED SUBQUERIES
                 * 
                 * Rewrite the named subquery projections before the where clause.
                 */
                if (queryRoot.getNamedSubqueries() != null) {
        
                    for (NamedSubqueryRoot subqueryRoot : queryRoot
                            .getNamedSubqueries()) {
        
                       @SuppressWarnings("unchecked")
                       final Iterator<QueryBase> itr = (Iterator<QueryBase>) new Striterator(
                               BOpUtility.postOrderIteratorWithAnnotations((BOp) subqueryRoot
                                       .getWhereClause())).addTypeFilter(QueryBase.class);
        
                       while (itr.hasNext()) {
        
                           final QueryBase queryBase = itr.next();
        
                           rewriteProjection(sa, queryBase);
        
                       }
        
                     rewriteProjection(sa, subqueryRoot);
                       
                    }
        
                }
        

        With this change, the original query now runs.

        Show
        bryanthompson bryanthompson added a comment - A second code change is required to get the original query to execute. /* * NAMED SUBQUERIES * * Rewrite the named subquery projections before the where clause. */ for (NamedSubqueryRoot subqueryRoot : queryRoot .getNamedSubqueries()) { rewriteProjection(sa, subqueryRoot); } needs to be replaced with: /* * NAMED SUBQUERIES * * Rewrite the named subquery projections before the where clause. */ if (queryRoot.getNamedSubqueries() != null) { for (NamedSubqueryRoot subqueryRoot : queryRoot .getNamedSubqueries()) { @SuppressWarnings("unchecked") final Iterator<QueryBase> itr = (Iterator<QueryBase>) new Striterator( BOpUtility.postOrderIteratorWithAnnotations((BOp) subqueryRoot .getWhereClause())).addTypeFilter(QueryBase.class); while (itr.hasNext()) { final QueryBase queryBase = itr.next(); rewriteProjection(sa, queryBase); } rewriteProjection(sa, subqueryRoot); } } With this change, the original query now runs.
        Hide
        bryanthompson bryanthompson added a comment -

        The fix is to ASTWildcardProjectionOptimizer.optimize(). Replace:

                    @SuppressWarnings("unchecked")
                    final Iterator<QueryBase> itr = (Iterator<QueryBase>) new Striterator(
                            BOpUtility.postOrderIterator((BOp) queryRoot
                                    .getWhereClause())).addTypeFilter(QueryBase.class);
        

        with

                    @SuppressWarnings("unchecked")
                    final Iterator<QueryBase> itr = (Iterator<QueryBase>) new Striterator(
                            BOpUtility.postOrderIteratorWithAnnotations((BOp) queryRoot
                                    .getWhereClause())).addTypeFilter(QueryBase.class);
        

        I have also added a test case for this in TestASTWildcardProjectionOptimizer.

           /**
            * <pre>
            * SELECT * 
            *   JoinGroupNode {
            *     SELECT (*) {
            *       JoinGroupNode {
            *         StatementPatternNode(VarNode(s), ConstantNode(TermId(2U)[http://example/p]), VarNode(o), DEFAULT_CONTEXTS)
            *       }
            *     }
            *    StatementPatternNode(VarNode(s), ConstantNode(TermId(3U)[http://example/q]), VarNode(x), DEFAULT_CONTEXTS)
            *   }
            * </pre>
            * 
            * @see <a href="http://trac.bigdata.com/ticket/757" > Wildcard projection
            *      was not rewritten. </a>
            */
           public void test_wildcard_nestedSubquery() {
        
              /*
               * Note: DO NOT share structures in this test!!!!
               */
              final IBindingSet[] bsets = new IBindingSet[] {};
        
              @SuppressWarnings("rawtypes")
              final IV p = makeIV(new URIImpl("http://example/p"));
        
              @SuppressWarnings("rawtypes")
              final IV q = makeIV(new URIImpl("http://example/q"));
        
              // The source AST.
              final QueryRoot given = new QueryRoot(QueryType.SELECT);
              {
        
                 final ProjectionNode projection1 = new ProjectionNode();
                 given.setProjection(projection1);
                 projection1.addProjectionVar(new VarNode("s"));
                 projection1.addProjectionVar(new VarNode("o"));
                 projection1.addProjectionVar(new VarNode("x"));
        
                 final JoinGroupNode whereClause1 = new JoinGroupNode();
                 given.setWhereClause(whereClause1);
        
                 final SubqueryRoot subSelect = new SubqueryRoot(QueryType.SELECT);
                 {
                    final ProjectionNode projection2 = new ProjectionNode();
                    subSelect.setProjection(projection2);
                    projection2.addProjectionVar(new VarNode("*"));
                    final JoinGroupNode whereClause2 = new JoinGroupNode();
                    subSelect.setWhereClause(whereClause2);
                    whereClause2.addChild(new StatementPatternNode(new VarNode("s"),
                          new ConstantNode(p), new VarNode("o"), null/* c */,
                          Scope.DEFAULT_CONTEXTS));
                 }
        
                 whereClause1.addChild(subSelect);
        
                 whereClause1.addChild(new StatementPatternNode(new VarNode("s"),
                       new ConstantNode(q), new VarNode("x"), null/* c */,
                       Scope.DEFAULT_CONTEXTS));
        
              }
        
              // The expected AST after the rewrite.
              final QueryRoot expected = new QueryRoot(QueryType.SELECT);
              {
        
                 final ProjectionNode projection1 = new ProjectionNode();
                 expected.setProjection(projection1);
                 projection1.addProjectionVar(new VarNode("s"));
                 projection1.addProjectionVar(new VarNode("o"));
                 projection1.addProjectionVar(new VarNode("x"));
        
                 final JoinGroupNode whereClause1 = new JoinGroupNode();
                 expected.setWhereClause(whereClause1);
        
                 final SubqueryRoot subSelect = new SubqueryRoot(QueryType.SELECT);
                 {
                    final ProjectionNode projection2 = new ProjectionNode();
                    subSelect.setProjection(projection2);
                    projection2.addProjectionVar(new VarNode("s"));
                    projection2.addProjectionVar(new VarNode("o"));
                    final JoinGroupNode whereClause2 = new JoinGroupNode();
                    subSelect.setWhereClause(whereClause2);
                    whereClause2.addChild(new StatementPatternNode(new VarNode("s"),
                          new ConstantNode(p), new VarNode("o"), null/* c */,
                          Scope.DEFAULT_CONTEXTS));
                 }
        
                 whereClause1.addChild(subSelect);
        
                 whereClause1.addChild(new StatementPatternNode(new VarNode("s"),
                       new ConstantNode(q), new VarNode("x"), null/* c */,
                       Scope.DEFAULT_CONTEXTS));
        
              }
        
              final IASTOptimizer rewriter = new ASTWildcardProjectionOptimizer();
        
              final IQueryNode actual = rewriter.optimize(null/* AST2BOpContext */,
                    given/* queryNode */, bsets);
        
              assertSameAST(expected, actual);
        
           }
        
        

        With this change, the following query now executes:

        SELECT (COUNT(*) as ?c) {
          SELECT ?uri ?graph where {
                  {
                    SELECT * WHERE {
                      GRAPH ?graph {
                        ?uri a <http://object> .
                        ?uri <http://purl.org/dc/terms/title> ?title . 
                      }
                      MINUS {
                        ?uri a <http://other>
                      }
                    }
                    ORDER BY ?title
                  }
                }
        }
        
        Show
        bryanthompson bryanthompson added a comment - The fix is to ASTWildcardProjectionOptimizer.optimize(). Replace: @SuppressWarnings("unchecked") final Iterator<QueryBase> itr = (Iterator<QueryBase>) new Striterator( BOpUtility.postOrderIterator((BOp) queryRoot .getWhereClause())).addTypeFilter(QueryBase.class); with @SuppressWarnings("unchecked") final Iterator<QueryBase> itr = (Iterator<QueryBase>) new Striterator( BOpUtility.postOrderIteratorWithAnnotations((BOp) queryRoot .getWhereClause())).addTypeFilter(QueryBase.class); I have also added a test case for this in TestASTWildcardProjectionOptimizer. /** * <pre> * SELECT * * JoinGroupNode { * SELECT (*) { * JoinGroupNode { * StatementPatternNode(VarNode(s), ConstantNode(TermId(2U)[http://example/p]), VarNode(o), DEFAULT_CONTEXTS) * } * } * StatementPatternNode(VarNode(s), ConstantNode(TermId(3U)[http://example/q]), VarNode(x), DEFAULT_CONTEXTS) * } * </pre> * * @see <a href="http://trac.bigdata.com/ticket/757" > Wildcard projection * was not rewritten. </a> */ public void test_wildcard_nestedSubquery() { /* * Note: DO NOT share structures in this test!!!! */ final IBindingSet[] bsets = new IBindingSet[] {}; @SuppressWarnings("rawtypes") final IV p = makeIV(new URIImpl("http://example/p")); @SuppressWarnings("rawtypes") final IV q = makeIV(new URIImpl("http://example/q")); // The source AST. final QueryRoot given = new QueryRoot(QueryType.SELECT); { final ProjectionNode projection1 = new ProjectionNode(); given.setProjection(projection1); projection1.addProjectionVar(new VarNode("s")); projection1.addProjectionVar(new VarNode("o")); projection1.addProjectionVar(new VarNode("x")); final JoinGroupNode whereClause1 = new JoinGroupNode(); given.setWhereClause(whereClause1); final SubqueryRoot subSelect = new SubqueryRoot(QueryType.SELECT); { final ProjectionNode projection2 = new ProjectionNode(); subSelect.setProjection(projection2); projection2.addProjectionVar(new VarNode("*")); final JoinGroupNode whereClause2 = new JoinGroupNode(); subSelect.setWhereClause(whereClause2); whereClause2.addChild(new StatementPatternNode(new VarNode("s"), new ConstantNode(p), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS)); } whereClause1.addChild(subSelect); whereClause1.addChild(new StatementPatternNode(new VarNode("s"), new ConstantNode(q), new VarNode("x"), null/* c */, Scope.DEFAULT_CONTEXTS)); } // The expected AST after the rewrite. final QueryRoot expected = new QueryRoot(QueryType.SELECT); { final ProjectionNode projection1 = new ProjectionNode(); expected.setProjection(projection1); projection1.addProjectionVar(new VarNode("s")); projection1.addProjectionVar(new VarNode("o")); projection1.addProjectionVar(new VarNode("x")); final JoinGroupNode whereClause1 = new JoinGroupNode(); expected.setWhereClause(whereClause1); final SubqueryRoot subSelect = new SubqueryRoot(QueryType.SELECT); { final ProjectionNode projection2 = new ProjectionNode(); subSelect.setProjection(projection2); projection2.addProjectionVar(new VarNode("s")); projection2.addProjectionVar(new VarNode("o")); final JoinGroupNode whereClause2 = new JoinGroupNode(); subSelect.setWhereClause(whereClause2); whereClause2.addChild(new StatementPatternNode(new VarNode("s"), new ConstantNode(p), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS)); } whereClause1.addChild(subSelect); whereClause1.addChild(new StatementPatternNode(new VarNode("s"), new ConstantNode(q), new VarNode("x"), null/* c */, Scope.DEFAULT_CONTEXTS)); } final IASTOptimizer rewriter = new ASTWildcardProjectionOptimizer(); final IQueryNode actual = rewriter.optimize(null/* AST2BOpContext */, given/* queryNode */, bsets); assertSameAST(expected, actual); } With this change, the following query now executes: SELECT (COUNT(*) as ?c) { SELECT ?uri ?graph where { { SELECT * WHERE { GRAPH ?graph { ?uri a <http://object> . ?uri <http://purl.org/dc/terms/title> ?title . } MINUS { ?uri a <http://other> } } ORDER BY ?title } } }
        Hide
        bryanthompson bryanthompson added a comment -

        This is probably a problem to correctly recurse into the subqueries in ASTWildcardProjectionOptimizer. I just looked at that class, and it is attempting to do this recursion. It enumerates the named subqueries and then traverses the main query and looks for any sub-selects.

        I would create a test for the case above in TestASTWildcardProjectionOptimizer. That class currently provides coverage for queries with SELECT *, SELECT DISTINCT *, and SELECT REDUCED *. It does not have any unit tests that involve either named subqueries or nested subqueries. There is probably a simple error in the ASTWildcardProjectionOptimizer leading to a failure to rewrite either the named or the nested subquery.

        Show
        bryanthompson bryanthompson added a comment - This is probably a problem to correctly recurse into the subqueries in ASTWildcardProjectionOptimizer. I just looked at that class, and it is attempting to do this recursion. It enumerates the named subqueries and then traverses the main query and looks for any sub-selects. I would create a test for the case above in TestASTWildcardProjectionOptimizer. That class currently provides coverage for queries with SELECT *, SELECT DISTINCT *, and SELECT REDUCED *. It does not have any unit tests that involve either named subqueries or nested subqueries. There is probably a simple error in the ASTWildcardProjectionOptimizer leading to a failure to rewrite either the named or the nested subquery.
        Hide
        jeremycarroll jeremycarroll added a comment -

        The query can be further simplified to

        prefix eg: <http://example.org/>
        SELECT *
        WITH {
        SELECT *
        WHERE {
           {  SELECT *
              WHERE {
              }  
        }
        }} AS %__FullQuery
        
        WHERE {
         INCLUDE %__FullQuery
        }
        
        Show
        jeremycarroll jeremycarroll added a comment - The query can be further simplified to prefix eg: <http://example.org/> SELECT * WITH { SELECT * WHERE { { SELECT * WHERE { } } }} AS %__FullQuery WHERE { INCLUDE %__FullQuery }

          People

          • Assignee:
            jeremycarroll jeremycarroll
            Reporter:
            jeremycarroll jeremycarroll
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: