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

Static analysis of variable bindings to constants in UNION escapes the UNION

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: BIGDATA_RELEASE_1_2_2
    • Fix Version/s: None
    • Component/s: Query Plan Generator
    • Labels:
      None

      Description

      Per an issue described at [1] and as documented below, the static analysis of variables inside of a UNION that are bound to constants appears to escape the UNION. In the given example, this results in both [s] and [o] becoming bound to constants in both sides of the UNION.

      Original query:

      prefix ebt:    <http://semantic.eb.com/ns/eb/thesaurus#> 
      prefix rdf:    <http://www.w3c.org/1999/02/22-rdf-syntax-ns#>
      prefix ebo:    <http://semantic.eb.com/ns/eb/object#> 
      select distinct ?s ?p ?o where { 
      {
      ?p rdf:type ebt:ThesaurusRelation .
      ?s ?p ebo:31171642-9757-45f3-b2d7-5f00c827b5db .  
      ?s ?p ?o . 
      FILTER(?o = ebo:31171642-9757-45f3-b2d7-5f00c827b5db) . 
      } 
      union 
      { 
      ebo:31171642-9757-45f3-b2d7-5f00c827b5db ?p ?o .  
      ?s ?p ?o . 
      FILTER(?s = ebo:31171642-9757-45f3-b2d7-5f00c827b5db) . 
      }  
      }
      

      In the Optimized AST, you can see that both [s] and [o] are bound to constants in both sides of the UNION (look for [var=s] and [var=o] in the ConstantNodes on both sides of the UNION.)

      Optimized AST
      
      PREFIX ebt: <http://semantic.eb.com/ns/eb/thesaurus#>
      PREFIX rdf: <http://www.w3c.org/1999/02/22-rdf-syntax-ns#>
      PREFIX ebo: <http://semantic.eb.com/ns/eb/object#>
      QueryType: SELECT
      includeInferred=true
      SELECT DISTINCT ( VarNode(s) AS VarNode(s) ) ( VarNode(p) AS VarNode(p) ) ( VarNode(o) AS VarNode(o) )
        UnionNode {
          JoinGroupNode [joinVars=[]] [projectInVars=[]] {
            StatementPatternNode(ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=s]), VarNode(p), ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db])) [scope=DEFAULT_CONTEXTS]
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=0
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=SOPC
            StatementPatternNode(ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=s]), VarNode(p), ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=o])) [scope=DEFAULT_CONTEXTS] [#filters=1]
              FILTER( com.bigdata.rdf.sparql.ast.FunctionNode(ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=o]),ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db]))[ com.bigdata.rdf.sparql.ast.FunctionNode.scalarVals=null, com.bigdata.rdf.sparql.ast.FunctionNode.functionURI=http://www.w3.org/2005/xpath-functions#equal-to, valueExpr=com.bigdata.rdf.internal.constraints.CompareBOp(o,TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db])[ com.bigdata.rdf.internal.constraints.CompareBOp.op=EQ]] )
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=0
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=SOPC
            StatementPatternNode(VarNode(p), ConstantNode(TermId(825U)[http://www.w3c.org/1999/02/22-rdf-syntax-ns#type]), ConstantNode(TermId(801U)[http://semantic.eb.com/ns/eb/thesaurus#ThesaurusRelation])) [scope=DEFAULT_CONTEXTS]
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=37
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=POCS
          } JOIN ON ()
          JoinGroupNode [joinVars=[]] [projectInVars=[]] {
            StatementPatternNode(ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db]), VarNode(p), ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=o])) [scope=DEFAULT_CONTEXTS]
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=0
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=SOPC
            StatementPatternNode(ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=s]), VarNode(p), ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=o])) [scope=DEFAULT_CONTEXTS] [#filters=1]
              FILTER( com.bigdata.rdf.sparql.ast.FunctionNode(ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=s]),ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db]))[ com.bigdata.rdf.sparql.ast.FunctionNode.scalarVals=null, com.bigdata.rdf.sparql.ast.FunctionNode.functionURI=http://www.w3.org/2005/xpath-functions#equal-to, valueExpr=com.bigdata.rdf.internal.constraints.CompareBOp(s,TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db])[ com.bigdata.rdf.internal.constraints.CompareBOp.op=EQ]] )
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.estimatedCardinality=0
              com.bigdata.rdf.sparql.ast.eval.AST2BOpBase.originalIndex=SOPC
          } JOIN ON ()
        }
      

      Specifically:

      Left : StatementPatternNode(ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=s]), VarNode(p), ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=o]))
      Right: StatementPatternNode(ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db]), VarNode(p), ConstantNode(TermId(410U)[http://semantic.eb.com/ns/eb/object#31171642-9757-45f3-b2d7-5f00c827b5db][var=o]))
      

      Also see the attached "explain" of the query.

      [1] https://sourceforge.net/projects/bigdata/forums/forum/676946/topic/8506787/index/page/1

        Attachments

          Activity

            People

            Assignee:
            mikepersonick mikepersonick
            Reporter:
            bryanthompson bryanthompson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: