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

BIND that creates variable required for SERVICE is reordered after SERVICE

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Wikidata Query Service
    • Labels:
      None

      Description

      When running a query with SERVICE, BIND that produces required parameter is reordered after the service:

      SELECT * WHERE {
        BIND(wd:Q668563 as ?leinestr) # random item with picture
        ?leinestr wdt:P18 ?picture.
      
        BIND(STRAFTER(str(?picture), "Special:FilePath/") AS ?filename)
        BIND(CONCAT("File:", ?filename) AS ?file)
      
        SERVICE wikibase:mwapi {
          bd:serviceParam wikibase:api "Categories".
          bd:serviceParam wikibase:endpoint "commons.wikipedia.org".
          bd:serviceParam mwapi:titles ?file. # throws IllegalArgumentException: Could not find binding for parameter titles
          ?cat wikibase:apiOutput mwapi:category.
        }
      }
      

      This query fails because ?file is not bound when entering the service. The AST before optimization is:

      SELECT * 
        JoinGroupNode {
          ( ConstantNode(TermId(0U)[http://www.wikidata.org/entity/Q668563]) AS VarNode(leinestr) )
          StatementPatternNode(VarNode(leinestr), ConstantNode(TermId(0U)[http://www.wikidata.org/prop/direct/P18]), VarNode(picture)) [scope=DEFAULT_CONTEXTS]
          ( com.bigdata.rdf.sparql.ast.FunctionNode(FunctionNode(null),ConstantNode(TermId(0L)[Special:FilePath/]))[ FunctionNode.scalarVals=null, FunctionNode.functionURI=http://www.w3.org/2005/xpath-functions#substring-after] AS VarNode(filename) )
          ( com.bigdata.rdf.sparql.ast.FunctionNode(ConstantNode(TermId(0L)[File:]),VarNode(filename))[ FunctionNode.scalarVals=null, FunctionNode.functionURI=http://www.w3.org/2006/sparql-functions#concat] AS VarNode(file) )
          SERVICE <ConstantNode(TermId(0U)[http://wikiba.se/ontology#mwapi])> {
            JoinGroupNode {
              StatementPatternNode(ConstantNode(TermId(0U)[http://www.bigdata.com/rdf#serviceParam]), ConstantNode(TermId(0U)[http://wikiba.se/ontology#api]), ConstantNode(TermId(0L)[Categories])) [scope=DEFAULT_CONTEXTS]
              StatementPatternNode(ConstantNode(TermId(0U)[http://www.bigdata.com/rdf#serviceParam]), ConstantNode(TermId(0U)[http://wikiba.se/ontology#endpoint]), ConstantNode(TermId(0L)[commons.wikipedia.org])) [scope=DEFAULT_CONTEXTS]
              StatementPatternNode(ConstantNode(TermId(0U)[http://www.bigdata.com/rdf#serviceParam]), ConstantNode(TermId(0U)[http://wikiba.se/ontology#api#titles]), VarNode(file)) [scope=DEFAULT_CONTEXTS]
              StatementPatternNode(VarNode(cat), ConstantNode(TermId(0U)[http://wikiba.se/ontology#apiOutput]), ConstantNode(TermId(0U)[http://wikiba.se/ontology#api#category])) [scope=DEFAULT_CONTEXTS]
            }
          }
        }
      

      and after:

      SELECT VarNode(leinestr) VarNode(picture) VarNode(filename) VarNode(file) VarNode(cat)
        JoinGroupNode {
          StatementPatternNode(ConstantNode(Vocab(2)[http://www.wikidata.org/entity/Q]:XSDUnsignedInt(668563)[var=leinestr]), ConstantNode(Vocab(6)[http://www.wikidata.org/prop/direct/P]:XSDUnsignedByte(18)), VarNode(picture)) [scope=DEFAULT_CONTEXTS]
            AST2BOpBase.estimatedCardinality=1
            AST2BOpBase.originalIndex=SPO
          ( com.bigdata.rdf.sparql.ast.FunctionNode(FunctionNode(com.bigdata.rdf.internal.constraints.StrBOp(picture)[ IVValueExpression.namespace=wdq.lex, IVValueExpression.timestamp=1498523995953]),ConstantNode(TermId(0L)[Special:FilePath/]))[ FunctionNode.scalarVals=null, FunctionNode.functionURI=http://www.w3.org/2005/xpath-functions#substring-after, valueExpr=com.bigdata.rdf.internal.constraints.StrAfterBOp(com.bigdata.rdf.internal.constraints.StrBOp(picture)[ IVValueExpression.namespace=wdq.lex, IVValueExpression.timestamp=1498523995953],TermId(0L)[Special:FilePath/])[ IVValueExpression.namespace=wdq.lex, IVValueExpression.timestamp=1498523995953]] AS VarNode(filename) )
          SERVICE <ConstantNode(TermId(0U)[http://wikiba.se/ontology#mwapi])> {
            JoinGroupNode {
              StatementPatternNode(ConstantNode(TermId(0U)[http://www.bigdata.com/rdf#serviceParam]), ConstantNode(TermId(0U)[http://wikiba.se/ontology#api]), ConstantNode(TermId(0L)[Categories])) [scope=DEFAULT_CONTEXTS]
              StatementPatternNode(ConstantNode(TermId(0U)[http://www.bigdata.com/rdf#serviceParam]), ConstantNode(TermId(0U)[http://wikiba.se/ontology#endpoint]), ConstantNode(TermId(0L)[commons.wikipedia.org])) [scope=DEFAULT_CONTEXTS]
              StatementPatternNode(ConstantNode(TermId(0U)[http://www.bigdata.com/rdf#serviceParam]), ConstantNode(TermId(0U)[http://wikiba.se/ontology#api#titles]), VarNode(file)) [scope=DEFAULT_CONTEXTS]
              StatementPatternNode(VarNode(cat), ConstantNode(TermId(0U)[http://wikiba.se/ontology#apiOutput]), ConstantNode(TermId(0U)[http://wikiba.se/ontology#api#category])) [scope=DEFAULT_CONTEXTS]
            }
          }
          ( com.bigdata.rdf.sparql.ast.FunctionNode(ConstantNode(TermId(0L)[File:]),VarNode(filename))[ FunctionNode.scalarVals=null, FunctionNode.functionURI=http://www.w3.org/2006/sparql-functions#concat, valueExpr=com.bigdata.rdf.internal.constraints.ConcatBOp(TermId(0L)[File:],filename)[ IVValueExpression.namespace=wdq.lex, IVValueExpression.timestamp=1498523995953]] AS VarNode(file) )
        }
      
      with static (exogeneous) bindings defined as follows: 
      {
        { leinestr=Vocab(2)[http://www.wikidata.org/entity/Q]:XSDUnsignedInt(668563) }
      
      

      Note how the clause for ?file has been moved after the service. This is despite code for the service specifically declaring ?file as incoming via getRequiredBound().

      Maybe related to BLZG-8990.

        Attachments

          Activity

            People

            Assignee:
            thompsonbry thompsonbry
            Reporter:
            stasmalyshev stasmalyshev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: