Re: [ISSUE-8] subqueries and datasets

On 8 May 2009, at 15:12, Lee Feigenbaum wrote:

> Steve Harris wrote:
>> On 8 May 2009, at 05:40, Lee Feigenbaum wrote:
>>> It seems to me that ARQ's behavior is simple and avoids this  
>>> problem, but I'm not sure at what cost. My natural inclination is  
>>> that its valuable for queries & their subqueries to be able to  
>>> target different graphs.
>>>
>>> Current recommendation? Unsure.
>>>
>>> Suggested next steps? Determine whether we have reasonable use  
>>> cases to require that subqueries can target different datastes  
>>> from parent queries.
>> Good summary.
>> For the record, I think it makes most sense to ban FROM in  
>> subqueries.
>> The specification of FROM is a little unclear in my mind, but by my  
>> understanding it should be possible to rewrite any sub-FROM'd query  
>> using GRAPH, eg. if you want to ask something like:
>> FROM <a>
>> SELECT ?x WHERE {
>>  ?x a :Person .
>>  {
>>    FROM <b>
>>    SELECT ?x, ?z WHERE {
>>      ?x :knows ?z
>>    }
>>  }
>> }
>> you could also write something like:
>> FROM <a>, <b>
>> SELECT ?x WHERE {
>>  GRAPH <a> { ?x a :Person }
>>  {
>>    SELECT ?x, ?z WHERE {
>>      GRAPH <b> { ?x :knows ?z }
>>    }
>>  }
>> }
>> Possibly you need to use FROM NAMED, not FROM.
>
> In this case, yes, but I think if your subquery is relying on the  
> FROM merging together multiple graphs, then you can't recast it in  
> this way.
>
> (I can try to come up with an example later, but the key point is  
> that FROM lets you write down triple patterns that can span multiple  
> 'input' graphs without knowing ahead of time which triple patterns  
> match from which graph. FROM NAMED and GRAPH end up requiring that  
> the triple patterns inside GRAPH { ... } all match a single named  
> graph.

Yes, that's true, I avoid doing a hard case for that reason, it would  
be horribly verbose in the worst case, something like:

    SELECT ?x, ?z WHERE {
      GRAPH ?g1 { ?x :knows ?z }
      GRAPH ?g2 { ?x :foo :bar }
      FILTER(?g1 IN (<a>, <b>, <c>) && ?g2 IN (<a>, <b>, <c>))
    }

and so on. I never said it was pretty :)

- Steve

Received on Friday, 8 May 2009 14:21:29 UTC