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

ORDER BY variable not in results set fails

    Details

      Description

      Some queries that use an ORDER BY clause where the variable used for the ORDER BY is not in the result set do not order their results correctly. This is illustrated by the following testcase (which fails on the first assert: expected <s:2>, but was <s:1>):

          @Test
          @Transactional
          public void orderByNotInResults() throws OpenRDFException {
              //This fails with BigData trunk of 21-07-2010
              URI s1 = vf.createURI("s:1");
              URI s2 = vf.createURI("s:2");
              URI s3 = vf.createURI("s:3");
              URI pred1 = vf.createURI("p:1");
              URI pred2 = vf.createURI("p:2");
              conn.add(s1, pred1, vf.createLiteral(3));
              conn.add(s1, pred2, vf.createLiteral("a"));
              conn.add(s2, pred1, vf.createLiteral(1));
              conn.add(s2, pred2, vf.createLiteral("b"));
              conn.add(s3, pred1, vf.createLiteral(2));
              conn.add(s3, pred2, vf.createLiteral("c"));
              TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, "SELECT ?s ?lit WHERE { ?s <p:1> ?val. ?s <p:2> ?lit } ORDER BY ?val");
              TupleQueryResult result = tq.evaluate();
              try {
                  Assert.assertEquals(s2, result.next().getValue("s"));
                  Assert.assertEquals(s3, result.next().getValue("s"));
                  Assert.assertEquals(s1, result.next().getValue("s"));
                  Assert.assertFalse(result.hasNext());
              } finally {
                  result.close();
              }
          }
      

      In this testcase conn is a RepositoryConnection for a BigdataSail with the following settings:

      <prop key="com.bigdata.rdf.sail.isolatableIndices">true</prop>
      <prop key="com.bigdata.rdf.store.AbstractTripleStore.axiomsClass">com.bigdata.rdf.axioms.NoAxioms</prop>
      <prop key="com.bigdata.rdf.sail.truthMaintenance">false</prop>
      <prop key="com.bigdata.rdf.store.AbstractTripleStore.vocabularyClass">com.bigdata.rdf.vocab.NoVocabulary</prop>
      <prop key="com.bigdata.rdf.store.AbstractTripleStore.justify">false</prop><prop key="com.bigdata.journal.AbstractJournal.createTempFile">true</prop>
      <prop key="com.bigdata.journal.AbstractJournal.deleteOnClose">true</prop>
      <prop key="com.bigdata.journal.AbstractJournal.deleteOnExit">true</prop>
      <prop key="com.bigdata.rdf.sail.allowAutoCommit">true</prop>
      

      And vf is the ValueFactory for that connection.

      If I add ?val to the result set (SELECT ?s ?lit ? val { ...) the results are correctly ordered.

        Activity

        Hide
        bryanthompson bryanthompson added a comment -

        Mike,

        Please take a look at this. It is probably related to the logic to eliminate variable bindings which are not used by the downstream joins.

        Thanks,
        Bryan

        Show
        bryanthompson bryanthompson added a comment - Mike, Please take a look at this. It is probably related to the logic to eliminate variable bindings which are not used by the downstream joins. Thanks, Bryan
        Hide
        mikepersonick mikepersonick added a comment -

        variables used in ORDER BY were being pruned incorrectly from downstream binding sets. fixed this in the trunk.

        Show
        mikepersonick mikepersonick added a comment - variables used in ORDER BY were being pruned incorrectly from downstream binding sets. fixed this in the trunk.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: