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

VALUES keyword in subquery ignored in some cases.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Fuseki 0.2.7, Fuseki 1.0.0
    • Fix Version/s: Jena 2.11.0, Fuseki 1.0.0
    • Component/s: Fuseki
    • Labels:
      None
    • Environment:

      Ubuntu 13.04 x64
      OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)

      Description

      Given the following data set in the graph "http://test.com":

      data.ttl
      @prefix : <http://example.com/>
      
      :s1 :type :thing .
      :s1 :p1 :o1 .
      
      :s2 :type :thing .
      :s2 :p1 :o1, :o2 .
      
      :s3 :type :thing .
      :s3 :p1 :o2 .
      
      s-put http://localhost:3030/ds/data http://test.com data.ttl

      Suppose, as part of a subquery, we want to find all subjects that have (:p1 :o1):

      PREFIX : <http://example.com/>
      
      SELECT *
      WHERE {
      
      SELECT DISTINCT ?s WHERE {
        GRAPH <http://test.com> {
           ?s :p1 ?obj .
           VALUES ?obj { :o1 }
        }
      }
      
      }
      

      This returns the expected result (?s={:s1, :s2}). However when the GRAPH statement is outside the subquery:

      PREFIX : <http://example.com/>
      
      SELECT *
      WHERE {
      
      GRAPH <http://test.com> {
        SELECT DISTINCT ?s WHERE {
           ?s :p1 ?obj .
           VALUES ?obj { :o1 }
        }
      }
      
      }
      

      this returns ?s={:p1, :p2, :p3} - the VALUES block is ignored by the query, and removing the VALUES block gives the same result.

      Going back to the first query, let's try to select all triples with subjects restricted by the subquery:

      PREFIX : <http://example.com/>
      
      SELECT ?s ?p ?o
      WHERE {
      
      {SELECT DISTINCT ?s WHERE {
        GRAPH <http://test.com> {
               ?s :p1 ?obj .
           
               VALUES ?obj { :o1 }
        }
      }}
      
      GRAPH <http://test.com> { ?s ?p ?o }
      
      }
      

      I expected the subquery to restrict ?s to {:s1, :s2} and the triple at the bottom to select all triples with that subject. This behaviour works as expected in OpenRDF Sesame. However, once again the VALUES keyword is ignored and the following output is observed:

      s	p	o
      :s1	:type	:thing
      :s1	:p1	:o1
      :s2	:type	:thing
      :s2	:p1	:o1
      :s2	:p1	:o2
      :s3	:type	:thing
      :s3	:p1	:o2
      

      I have tried this with other triples in the subquery, and the behaviour is as expected. It seems to be variables restricted with the VALUES keyword that misbehave.

      Another curiousity I found while trying to find a workaround. If I add the VALUES variable to the SELECT, changing the line

      {SELECT DISTINCT ?s WHERE {

      to

      {SELECT DISTINCT ?s ?obj WHERE {

      then I get the expected result of only :s1 and :s2 being selected. However, this is not suitable as a workaround because if there is more than one value in the VALUES block, there will be duplicate values for ?s.

      Sorry for the long bug report, I'm not exactly sure of what the problem is so thought I would give as much detail as possible. I discovered this first on 0.2.7 but ran most of these tests on the 0.2.8 build from jena-fuseki-0.2.8-20130804.075208-67-distribution.tar.gz.

      Regards,
      Barry

        Attachments

          Activity

            People

            • Assignee:
              andy Andy Seaborne
              Reporter:
              bcoughlan Barry Coughlan
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: