W3C home > Mailing lists > Public > public-sparql-dev@w3.org > October to December 2014

Re: Pattern involving BIND from 18.2.3 Examples of Mapped Graph Patterns

From: Andy Seaborne <andy@apache.org>
Date: Mon, 06 Oct 2014 18:41:06 +0100
Message-ID: <5432D432.7020301@apache.org>
To: public-sparql-dev@w3.org
Bcc: public-sparql-comments
because that list is where any next working group should check for comments.

Added to

Hi Rory - thank you for the report.

Yes, the example is wrong and your correction is right.

On 03/10/14 00:41, Rory Rother wrote:
> Hello,
> I was working through some of the spec to get a better understanding 
> of translating queries to SPARQL algebra and had a question about the 
> eleventh example in section 18.2.3 
> (http://www.w3..org/TR/2013/REC-sparql11-query-20130321/#sparqlAlgebraExamples 
> <http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#sparqlAlgebraExamples>).
> The example is
> { ?s :p ?v . {} BIND (2*?v AS ?v2) }
> and the given translation to SPARQL algebra is
> Join(
>    BGP(?s :p ?v), ?v2, 2*?v) ,
>    Extend({}, ?v2, 2*?v)
> )
This is wrong in several ways:

 1. BGP(?s :p ?v), ?v2, 2*?v)   is nonsense.
 2. Extend operates on the group so far as you have noticed.

> I am having a hard time seeing how to get that translation.  From my 
> understanding, I am starting with a  GroupGraphPattern so I look to 
> the relevant box in section  I believe my GroupGraphPattern 
> has three elements: the triple pattern, the empty GroupGraphPattern, 
> and the BIND clause.  I set G equal to the Join identity.  Now I enter 
> the For loop by first setting E equal to the triple pattern.  At the 
> end of the first loop, I just have G=BGP(?s :p ?v).  At the start of 
> the second loop, I set E equal to {}.  That satisfies the last If 
> statement so I set A equal to Translate({}).  That should give me A 
> equal to the Join identity.  Then G=Join( BGP(?s :p ?v, (the join 
> identity) ). So, at the end of the second loop, I just have G=BGP(?s 
> :p ?v).  At the start of the third loop, I set E equal to the BIND 
> clause.  That satisfies the third If statement, so I set G equal to 
> Extend(BGP(?s :p ?v), ?v2, 2*?v).  Thatís the end of the For loop so I 
> end up with
> Extend( BGP(?s :p ?v), ?v2, 2*?v )

Yes.  The only difference I would note is that spec description builds 
the whole expression then it is simplifed, not simplifying as the group 
elements are are collected.  It creates the same algebra expression.

So the correct result is via the unsimplified:

             BGP(?s :p ?v)),
        ?v2, (2*?v))

> as the result.  I believe the above translation gives solution 
> mappings different from those coming from the translation provided in 
> the spec.  In fact, I believe the translation found in the spec would 
> give solution mappings to the pattern
> {
>    {}
>    BIND(2*?v AS ?v2)
>    ?s :p ?v
> }

I think the spec would build the join in the other other, not that it 
matters to execution semantics.

     Extend({}, ?v2, 2*?v) ,
     BGP(?s :p ?v), ?v2, 2*?v)

I recorded this pattern in the errata to stress the empty element 
starting point of a group that applies.
{ BIND(2*?v AS ?v2) ?s :p ?v }

> Any insight you can provide is much appreciated.  If this is not the 
> proper forum for such a question, then please accept my apologies (and 
> maybe let me know where I should be asking J).
> Rory

Received on Monday, 6 October 2014 17:41:36 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:15:52 UTC