Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-633

optimizer sequences instead of joins / subqueries with limits project more results than they should

    XMLWordPrintableJSON

    Details

      Description

      A subquery with `limit 1` specified can `leak` more values to the surrounding query. Rob Vesse tracked this down to a difference between the basic algebra and the optimized algebra [1] . One query has the following basic and optimized Ops; the "join" in the former shouldn't get turned into a "sequence" in the latter.

      Basic:
      (join
        (bgp (triple ?resource <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <urn:ex:Thing>))
        (slice _ 1
          (project (?resource ?p)
            (order (?p)
              (bgp (triple ?resource <urn:ex:p> ?p))))))
      
      Optimized:
      (sequence
        (bgp (triple ?resource <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <urn:ex:Thing>))
        (project (?resource ?p)
          (top (1 ?p)
            (bgp (triple ?resource <urn:ex:p> ?p)))))
      

      [1] http://answers.semanticweb.com/questions/26343/outer-query-results-include-more-values-than-subquery-with-limit-n-produces/26344

        Attachments

        1. SubqueryLimitBug.java
          3 kB
          Joshua Taylor

          Issue Links

            Activity

              People

              • Assignee:
                andy Andy Seaborne
                Reporter:
                taylorj Joshua Taylor
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: