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

Query solutions are duplicated and increase by adding graph patterns

    Details

      Description

      Given the following data:

      @prefix : <http://example.com/data/> .   
      @prefix base: <http://example.com/> .
      
      base:graph1
      {
      :person3                                                                                  
          a :Person ; 
          :age 3;                                                                     
          :name "Person 3 - graph1".
          
                                                                                        
      }
      
      base:graph2
      {
      :person3                                                                                  
          a :Person ; 
          :age 13;                                                                     
          :name "Person 3".
      }
      

      and the query:

      PREFIX  rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
      PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      PREFIX  xsd: <http://www.w3.org/2001/XMLSchema#>
      
      select  ?ps ?p ?o
      where { 
              GRAPH <http://example.com/graph1>
              {
                      ?ps ?p ?o.
                      select ?ps
                      where  
                      {
                              ?ps a  <http://example.com/data/Person>. 
                              BLZG-208 ?ps <http://example.com/data/age> ?age.
                              BLZG-209 ?ps <http://example.com/data/name> ?name.
                      }
              }
      }
      order by ?ps
      

      The result is triples for "Person 3
      - graph1" duplicated 3 times (9 triples). Further uncommenting BLZG-208, BLZG-209 reuslts in 6 and 12 triples.
      So the solutions increase by adding graph patterns.

      Expected result would be triples for selected person without the need to use distinct.

        Activity

        Hide
        michaelschmidt michaelschmidt added a comment -

        The problem was that the bindings for ?ps computed from the outer clause were flooded into the subquery while projecting for ?p in the result of evaluating (?ps, ?p, ?p), but no DISTINCT was applied. As a consequence, the binding set {

        { ?ps \-> P3 }

        , { ?ps -> P3 }, { ?ps -> P3 } } was passed inside the subquery, leading to wrong multiplicities in the final outcome (and an overhead in evaluation, of course).

        Included a DISTINCT operation with the projection, which fixes the problem. Note that similar approaches might be relevant for nested OPTIONAL groups. Opened a dedicated ticket for this (BLZG-1163). Actually, the latter issue is also related to BLZG-1119.

        Checked in the fix in branch ticket_835. Running final CI after minor fix related to a test cases, will issue pull requests once this goes through.

        Show
        michaelschmidt michaelschmidt added a comment - The problem was that the bindings for ?ps computed from the outer clause were flooded into the subquery while projecting for ?p in the result of evaluating (?ps, ?p, ?p), but no DISTINCT was applied. As a consequence, the binding set { { ?ps \-> P3 } , { ?ps -> P3 }, { ?ps -> P3 } } was passed inside the subquery, leading to wrong multiplicities in the final outcome (and an overhead in evaluation, of course). Included a DISTINCT operation with the projection, which fixes the problem. Note that similar approaches might be relevant for nested OPTIONAL groups. Opened a dedicated ticket for this ( BLZG-1163 ). Actually, the latter issue is also related to BLZG-1119 . Checked in the fix in branch ticket_835. Running final CI after minor fix related to a test cases, will issue pull requests once this goes through.
        Hide
        bryanthompson bryanthompson added a comment -

        staged for 1.5.1 release.

        Show
        bryanthompson bryanthompson added a comment - staged for 1.5.1 release.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: