Bcc: public-sparql-comments
because that list is where any next working group should check for comments.
Added to
http://www.w3.org/2013/sparql-errata
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 18.2.2.6. 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:
extend(
join({},
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.
Join(
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
Thanks
Andy