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

Variable Scoping Issues

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Jena 3.0.0
    • Fix Version/s: Jena 3.0.1
    • Component/s: Optimizer
    • Labels:
      None

      Description

      Consider the sample data

      <http://example.com/Alice> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/Person> .
      <http://example.com/Flipper> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/Animal> .
      

      and the following three queries:

      SELECT ?s ?type WHERE { 
        BIND("http://example.com/" AS ?typeBase)
        {
          BIND(URI(CONCAT(?typeBase,"Person")) AS ?type)
         ?s ?p ?o
         FILTER(?o=?type)
        }
      }
      
      SELECT ?s ?type WHERE { 
        BIND("http://example.com/" AS ?typeBase)
        {
          BIND(URI(CONCAT(?typeBase,"Person")) AS ?type)
          ?s ?p ?o
          FILTER(?o=?type)
        }
        UNION
        {
          BIND(URI(CONCAT(?typeBase,"Animal")) AS ?type)
          ?s ?p ?o
          FILTER(?o=?type)
        }
      }
      
       SELECT ?s ?type WHERE {
         {
           BIND(URI(CONCAT(?typeBase,"Person")) AS ?type)
           ?s a ?o
           FILTER(?o=?type)
         }
         UNION
         {
           BIND(URI(CONCAT(?typeBase,"Animal")) AS ?type)
           ?s a ?o
           FILTER(?o=?type)
         }
       } VALUES (?typeBase) { ("http://example.com/") }
      

      As discussed in thread https://lists.w3.org/Archives/Public/public-sparql-dev/2015JulSep/0026.html, in all cases variable ?typeBase is not in scope when binding variable ?type. As a consequence, all queries should return the empty result. However, with apache-jena-3.0.0 (tested with sparql batch script) all of them yield non-empty results.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                andy Andy Seaborne
                Reporter:
                mschmidt00 Michael Schmidt
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: