You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Daniel Hernández <da...@degu.cl> on 2014/12/23 15:34:02 UTC

[offtopic] An SPARQL question about service and variable scoping

Hello,

Let us consider a service <s> which default dataset contains the default
graph:

<a> <p> <b> .
<a> <q> <c> .

Let us consider the following query to be evaluated with the service <s>
described above:

SELECT *
WHERE { { <a> <p> ?x } FILTER ( EXISTS ( ?x <p> <c> ) ) }

I suppose that in this case the filter clause is evaluated for each
solution of the graph pattern on the left. Thus, it is evaluated for
{?x:<b>} and {?x:<c>}. Then the clauses will be:

{?x:<b>} --> EXISTS ( <b> <p> <c> )    (FALSE)
{?x:<c>} --> EXISTS ( <c> <p> <c> )    (FALSE)

Then, the result of this query will be empty.

Let us to consider the following query:

SELECT *
WHERE { { <a> <p> ?x }
        FILTER ( EXISTS ( SERVICE <s> { ?x <p> <c> } ) ) }

What will be the result of this query?

Regards,
Daniel


Re: [offtopic] An SPARQL question about service and variable scoping

Posted by james anderson <ja...@dydra.com>.
On 2014-12-24, at 17:38, Andy Seaborne <an...@apache.org> wrote:

> On 24/12/14 12:29, james anderson wrote:
>> good afternoon,
>> 
>> On 2014-12-24, at 11:43, Andy Seaborne <an...@apache.org> wrote:
>> 
>>> That would better.  VALUES (?x) causes there to be a solution set
>>> to be joined in the algebra expression. VALUES is syntax,
>>> substitute() works on algebra expressions.
>>> 
>>> substitute() is also affected by scoping which the definition
>>> ignores and shouldn't.  Inner SELECTs and a WHERE with
>>> non-projected ?x is really a different variable.
>> 
>> this brings up the point which would benefit from more careful
>> wording: how does the semantics of a service clause compare to that
>> of a subselect. in particular, given the discussion in the federated
>> query recommendation regarding the evaluation as a select and the
>> suggested means to propagate bindings, the binding environment for
>> the bgp within the service clause is somewhat less than
>> self-evident.
>> 
>> best regards from berlin,
>> 
> 
> Hi there,
> 
> The evaluation is defined, like everything else in SPARQL (or any
> algebra) to be bottom up, that is, strict functional evaluation.

which, with respect to the comment earlier in the thread - with reference to the substitution rule, leads to confusion.

> SERVICE looks like a remote SELECT *, specifically no projection Section 3 in the federated query spec:
> 
> Join(G, Service(IRI, Transform(P), SilentOp))
> 
> It may be better to evaluate using unscoped index joins and in the SERVICE do this by sending over bindings.  ARQ prefers index joins but does not collect multiple bindings in VALUES for SERVICE.
> 
> (contributions welcome - maybe even an MSc project - I'm not aware of a huge amount of coverage looking at the issues of operation on the web but I haven't necessary been tracking it closely in recent years.  There is prior work - not web-related - for example, the work of the IBM Research Garlic project on bind joins.)
> 
> You have to be careful about scoping and you can't always evaluate a query solely in the style of binding propagating but the outer VALUES clause should be correctly handled by any engine in this regard.

which can mean only, that it could limit the cardinality of the returned solution field (as suggested in the federation recommendation), but not that there should be any substitution of the form which the comment earlier in the thread implies.

>  There isn't anything fundamentally special about SERVICE here.  SPARQL 1.0 has the case of nested optionals; there are others in 1.1 such as projection+inner SELECT.

indeed. the federation recommendation describes the semantics in terms of select - which it must given the permitted syntax, rather than leaving room for the suggestion that the exists clause contains just a bgp, to which one might have argued, substitution would apply.

> 
> The benefits of rewriting and executing something more efficient for SERVICE can be magnified by the network.  So can doing the wrong optimization! This is an implementation issue, not the semantics of the query.
> 
> James - what would be most helpful is to post to SPARQL comments explaining where the text can be improved.  It will then at least make sure it gets recorded for any future group.

i had not seen the text itself as requiring improvement until i read you comments about substitution, which suggested that they would apply to the service clause. did i mis-read?
our current implementation does perform the sidewards-information-passing (aka substitution) which is described in the sparql recommendation, subject to contour constraints of the kind which you describe, above, but my experience is that the practical performance consequences for "(not) exists” are unfortunate and a concrete goal is to re-implement those based on joins. at that point, it might be appropriate to offer suggestions and i will.

best regards, from berlin,



---
james anderson | james@dydra.com | http://dydra.com






Re: [offtopic] An SPARQL question about service and variable scoping

Posted by Andy Seaborne <an...@apache.org>.
On 24/12/14 12:29, james anderson wrote:
> good afternoon,
>
> On 2014-12-24, at 11:43, Andy Seaborne <an...@apache.org> wrote:
>
>> That would better.  VALUES (?x) causes there to be a solution set
>> to be joined in the algebra expression. VALUES is syntax,
>> substitute() works on algebra expressions.
>>
>> substitute() is also affected by scoping which the definition
>> ignores and shouldn't.  Inner SELECTs and a WHERE with
>> non-projected ?x is really a different variable.
>
> this brings up the point which would benefit from more careful
> wording: how does the semantics of a service clause compare to that
> of a subselect. in particular, given the discussion in the federated
> query recommendation regarding the evaluation as a select and the
> suggested means to propagate bindings, the binding environment for
> the bgp within the service clause is somewhat less than
> self-evident.
>
> best regards from berlin,
>

Hi there,

The evaluation is defined, like everything else in SPARQL (or any
algebra) to be bottom up, that is, strict functional evaluation. 
SERVICE looks like a remote SELECT *, specifically no projection Section 
3 in the federated query spec:

Join(G, Service(IRI, Transform(P), SilentOp))

It may be better to evaluate using unscoped index joins and in the 
SERVICE do this by sending over bindings.  ARQ prefers index joins but 
does not collect multiple bindings in VALUES for SERVICE.

(contributions welcome - maybe even an MSc project - I'm not aware of a 
huge amount of coverage looking at the issues of operation on the web 
but I haven't necessary been tracking it closely in recent years.  There 
is prior work - not web-related - for example, the work of the IBM 
Research Garlic project on bind joins.)

You have to be careful about scoping and you can't always evaluate a 
query solely in the style of binding propagating but the outer VALUES 
clause should be correctly handled by any engine in this regard.  There 
isn't anything fundamentally special about SERVICE here.  SPARQL 1.0 has 
the case of nested optionals; there are others in 1.1 such as 
projection+inner SELECT.

The benefits of rewriting and executing something more efficient for 
SERVICE can be magnified by the network.  So can doing the wrong 
optimization! This is an implementation issue, not the semantics of the 
query.

James - what would be most helpful is to post to SPARQL comments 
explaining where the text can be improved.  It will then at least make 
sure it gets recorded for any future group.

	Andy


> --- james anderson | james@dydra.com | http://dydra.com
>
>
>
>
>
>


Re: [offtopic] An SPARQL question about service and variable scoping

Posted by james anderson <ja...@dydra.com>.
good afternoon,

On 2014-12-24, at 11:43, Andy Seaborne <an...@apache.org> wrote:

> That would better.  VALUES (?x) causes there to be a solution set to be joined in the algebra expression. VALUES is syntax, substitute() works on algebra expressions.
> 
> substitute() is also affected by scoping which the definition ignores and shouldn't.  Inner SELECTs and a WHERE with non-projected ?x is really a different variable.

this brings up the point which would benefit from more careful wording: how does the semantics of a service clause compare to that of a subselect. in particular, given the discussion in the federated query recommendation regarding the evaluation as a select and the suggested means to propagate bindings, the binding environment for the bgp within the service clause is somewhat less than self-evident.

best regards from berlin,

> 
> I've put these the W3C SPARQL errata to be fixed whenever.
> 
> 	Thanks
> 	Andy
> 
> On 23/12/14 20:55, Daniel Hernández wrote:
>> The specification says "EVERY occurrence":
>> 
>> substitute(pattern, μ) = the pattern formed by replacing every
>> occurrence of a variable v in pattern by μ(v) for each v in dom(μ)
>> 
>> However,  I guest that it must be only occurrences in basic graph
>> patterns. For example, let us to consider the pattern:
>> 
>> P =  VALUES (?x) { ("a") }
>> 
>> What is the result of substitute(P, {?x: "x"})?
>> 
>> If I substitute every occurrence, then I will get:
>> 
>> VALUES ("x") { ("a") }
>> 
>> But the domain of mappings is limited to variables. So I guest that the
>> result must be:
>> 
>> VALUES (?x) { ("a") }
>> 
>> Lets consider P2 = {:s :p ?x} . VALUES (?x) { ("a") }. Then, I guest
>> that substitue(P2, {?x: "x"}) must be:
>> 
>> {:s :p "x"} . VALUES (?x) { ("a") }
>> 
>> 
>> On Tue, 2014-12-23 at 20:22 +0000, Andy Seaborne wrote:
>>> The formal description is the helper operation 'Substitute'
>>> 
>>> http://www.w3.org/TR/sparql11-query/#defn_substitute
>>> 
>>> and the evaluation text just below that.  SERVICE isn't special in
>>> anyway (whether it should be is whole different question!).
>>> 
>>> 	Andy
>>> 
>>> On 23/12/14 19:50, Daniel Hernández wrote:
>>>> The motivation of my question was to confirm that occurrences of ?x must
>>>> be replaced by bindings in each of the solutions before sending the
>>>> query to another service. But I do not found a simpler way to write that
>>>> question. That's all.
>>>> 
>>>> Thanks!
>>>> Daniel
>>>> 
>>>> On Tue, 2014-12-23 at 18:49 +0000, Andy Seaborne wrote:
>>>>>   >> What will be the result of this query?
>>>>> 
>>>>> Empty.
>>>>> 
>>>>> Firstly - the <a> in the query is highly unlikely to be the same <a> as
>>>>> the data because the query and data have different base URIs. thsi
>>>>> appies to the SERVICE and non-SERVICE cases.
>>>>> 
>>>>> The URI resolution of the query is at parse time so <p> inside the
>>>>> SERVICE is the same <p> in the triple pattern
>>>>> 
>>>>> Adding a stable BASE, I get no results with Fuseki2 because the EXISTS
>>>>> ?x is substituted from the pattern.
>>>>> 
>>>>> The Fuseki2 log shows a call back of:
>>>>> 
>>>>> Query = SELECT  * WHERE   { <http://example/b> <http://example/p>
>>>>> <http://example/c>}
>>>>> 
>>>>> which I guess is the core of your question?
>>>>> 
>>>>> 	Andy
>>>>> 
>>>>> ----------------------------
>>>>> BASE <http://example/>
>>>>> <a> <p> <b> .
>>>>> <a> <q> <c> .
>>>>> ----------------------------
>>>>> BASE <http://example/>
>>>>> 
>>>>> SELECT *
>>>>> WHERE {
>>>>>      { <a> <p> ?x }
>>>>>      FILTER (
>>>>>        EXISTS { SERVICE <http://localhost:3030/ds/query> { ?x <p> <c> } }
>>>>>        )
>>>>> }
>>>>> ----------------------------
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> On 23/12/14 15:04, Miguel Bento Alves wrote:
>>>>>> Daniel,
>>>>>> 
>>>>>> what is the point?
>>>>>> 
>>>>>> You didn’t clear if you have also a local dataset, but I think that the answer is the same, the result is empty. Why should be different?
>>>>>> 
>>>>>> (in this situations, normally, I test. Seeing is believing :) ).
>>>>>> 
>>>>>> In your dataset, instead of <a> <q> <c> you mean <a> <p> <c>?
>>>>>> 
>>>>>> Miguel
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> On 23 Dec 2014, at 14:34, Daniel Hernández <da...@degu.cl> wrote:
>>>>>>> 
>>>>>>> Hello,
>>>>>>> 
>>>>>>> Let us consider a service <s> which default dataset contains the default
>>>>>>> graph:
>>>>>>> 
>>>>>>> <a> <p> <b> .
>>>>>>> <a> <q> <c> .
>>>>>>> 
>>>>>>> Let us consider the following query to be evaluated with the service <s>
>>>>>>> described above:
>>>>>>> 
>>>>>>> SELECT *
>>>>>>> WHERE { { <a> <p> ?x } FILTER ( EXISTS ( ?x <p> <c> ) ) }
>>>>>>> 
>>>>>>> I suppose that in this case the filter clause is evaluated for each
>>>>>>> solution of the graph pattern on the left. Thus, it is evaluated for
>>>>>>> {?x:<b>} and {?x:<c>}. Then the clauses will be:
>>>>>>> 
>>>>>>> {?x:<b>} --> EXISTS ( <b> <p> <c> )    (FALSE)
>>>>>>> {?x:<c>} --> EXISTS ( <c> <p> <c> )    (FALSE)
>>>>>>> 
>>>>>>> Then, the result of this query will be empty.
>>>>>>> 
>>>>>>> Let us to consider the following query:
>>>>>>> 
>>>>>>> SELECT *
>>>>>>> WHERE { { <a> <p> ?x }
>>>>>>>          FILTER ( EXISTS ( SERVICE <s> { ?x <p> <c> } ) ) }
>>>>>>> 
>>>>>>> What will be the result of this query?
>>>>>>> 
>>>>>>> Regards,
>>>>>>> Daniel
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>> 
>> 
> 



---
james anderson | james@dydra.com | http://dydra.com






Re: [offtopic] An SPARQL question about service and variable scoping

Posted by Andy Seaborne <an...@apache.org>.
That would better.  VALUES (?x) causes there to be a solution set to be 
joined in the algebra expression. VALUES is syntax, substitute() works 
on algebra expressions.

substitute() is also affected by scoping which the definition ignores 
and shouldn't.  Inner SELECTs and a WHERE with non-projected ?x is 
really a different variable.

I've put these the W3C SPARQL errata to be fixed whenever.

	Thanks
	Andy

On 23/12/14 20:55, Daniel Hernández wrote:
> The specification says "EVERY occurrence":
>
> substitute(pattern, μ) = the pattern formed by replacing every
> occurrence of a variable v in pattern by μ(v) for each v in dom(μ)
>
> However,  I guest that it must be only occurrences in basic graph
> patterns. For example, let us to consider the pattern:
>
> P =  VALUES (?x) { ("a") }
>
> What is the result of substitute(P, {?x: "x"})?
>
> If I substitute every occurrence, then I will get:
>
> VALUES ("x") { ("a") }
>
> But the domain of mappings is limited to variables. So I guest that the
> result must be:
>
> VALUES (?x) { ("a") }
>
> Lets consider P2 = {:s :p ?x} . VALUES (?x) { ("a") }. Then, I guest
> that substitue(P2, {?x: "x"}) must be:
>
> {:s :p "x"} . VALUES (?x) { ("a") }
>
>
> On Tue, 2014-12-23 at 20:22 +0000, Andy Seaborne wrote:
>> The formal description is the helper operation 'Substitute'
>>
>> http://www.w3.org/TR/sparql11-query/#defn_substitute
>>
>> and the evaluation text just below that.  SERVICE isn't special in
>> anyway (whether it should be is whole different question!).
>>
>> 	Andy
>>
>> On 23/12/14 19:50, Daniel Hernández wrote:
>>> The motivation of my question was to confirm that occurrences of ?x must
>>> be replaced by bindings in each of the solutions before sending the
>>> query to another service. But I do not found a simpler way to write that
>>> question. That's all.
>>>
>>> Thanks!
>>> Daniel
>>>
>>> On Tue, 2014-12-23 at 18:49 +0000, Andy Seaborne wrote:
>>>>    >> What will be the result of this query?
>>>>
>>>> Empty.
>>>>
>>>> Firstly - the <a> in the query is highly unlikely to be the same <a> as
>>>> the data because the query and data have different base URIs. thsi
>>>> appies to the SERVICE and non-SERVICE cases.
>>>>
>>>> The URI resolution of the query is at parse time so <p> inside the
>>>> SERVICE is the same <p> in the triple pattern
>>>>
>>>> Adding a stable BASE, I get no results with Fuseki2 because the EXISTS
>>>> ?x is substituted from the pattern.
>>>>
>>>> The Fuseki2 log shows a call back of:
>>>>
>>>> Query = SELECT  * WHERE   { <http://example/b> <http://example/p>
>>>> <http://example/c>}
>>>>
>>>> which I guess is the core of your question?
>>>>
>>>> 	Andy
>>>>
>>>> ----------------------------
>>>> BASE <http://example/>
>>>> <a> <p> <b> .
>>>> <a> <q> <c> .
>>>> ----------------------------
>>>> BASE <http://example/>
>>>>
>>>> SELECT *
>>>> WHERE {
>>>>       { <a> <p> ?x }
>>>>       FILTER (
>>>>         EXISTS { SERVICE <http://localhost:3030/ds/query> { ?x <p> <c> } }
>>>>         )
>>>> }
>>>> ----------------------------
>>>>
>>>>
>>>>
>>>>
>>>> On 23/12/14 15:04, Miguel Bento Alves wrote:
>>>>> Daniel,
>>>>>
>>>>> what is the point?
>>>>>
>>>>> You didn’t clear if you have also a local dataset, but I think that the answer is the same, the result is empty. Why should be different?
>>>>>
>>>>> (in this situations, normally, I test. Seeing is believing :) ).
>>>>>
>>>>> In your dataset, instead of <a> <q> <c> you mean <a> <p> <c>?
>>>>>
>>>>> Miguel
>>>>>
>>>>>
>>>>>
>>>>>> On 23 Dec 2014, at 14:34, Daniel Hernández <da...@degu.cl> wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> Let us consider a service <s> which default dataset contains the default
>>>>>> graph:
>>>>>>
>>>>>> <a> <p> <b> .
>>>>>> <a> <q> <c> .
>>>>>>
>>>>>> Let us consider the following query to be evaluated with the service <s>
>>>>>> described above:
>>>>>>
>>>>>> SELECT *
>>>>>> WHERE { { <a> <p> ?x } FILTER ( EXISTS ( ?x <p> <c> ) ) }
>>>>>>
>>>>>> I suppose that in this case the filter clause is evaluated for each
>>>>>> solution of the graph pattern on the left. Thus, it is evaluated for
>>>>>> {?x:<b>} and {?x:<c>}. Then the clauses will be:
>>>>>>
>>>>>> {?x:<b>} --> EXISTS ( <b> <p> <c> )    (FALSE)
>>>>>> {?x:<c>} --> EXISTS ( <c> <p> <c> )    (FALSE)
>>>>>>
>>>>>> Then, the result of this query will be empty.
>>>>>>
>>>>>> Let us to consider the following query:
>>>>>>
>>>>>> SELECT *
>>>>>> WHERE { { <a> <p> ?x }
>>>>>>           FILTER ( EXISTS ( SERVICE <s> { ?x <p> <c> } ) ) }
>>>>>>
>>>>>> What will be the result of this query?
>>>>>>
>>>>>> Regards,
>>>>>> Daniel
>>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
>


Re: [offtopic] An SPARQL question about service and variable scoping

Posted by Daniel Hernández <da...@degu.cl>.
The specification says "EVERY occurrence":

substitute(pattern, μ) = the pattern formed by replacing every
occurrence of a variable v in pattern by μ(v) for each v in dom(μ)

However,  I guest that it must be only occurrences in basic graph
patterns. For example, let us to consider the pattern:

P =  VALUES (?x) { ("a") }

What is the result of substitute(P, {?x: "x"})?

If I substitute every occurrence, then I will get:

VALUES ("x") { ("a") }

But the domain of mappings is limited to variables. So I guest that the
result must be:

VALUES (?x) { ("a") }

Lets consider P2 = {:s :p ?x} . VALUES (?x) { ("a") }. Then, I guest
that substitue(P2, {?x: "x"}) must be:

{:s :p "x"} . VALUES (?x) { ("a") }


On Tue, 2014-12-23 at 20:22 +0000, Andy Seaborne wrote:
> The formal description is the helper operation 'Substitute'
> 
> http://www.w3.org/TR/sparql11-query/#defn_substitute
> 
> and the evaluation text just below that.  SERVICE isn't special in 
> anyway (whether it should be is whole different question!).
> 
> 	Andy
> 
> On 23/12/14 19:50, Daniel Hernández wrote:
> > The motivation of my question was to confirm that occurrences of ?x must
> > be replaced by bindings in each of the solutions before sending the
> > query to another service. But I do not found a simpler way to write that
> > question. That's all.
> >
> > Thanks!
> > Daniel
> >
> > On Tue, 2014-12-23 at 18:49 +0000, Andy Seaborne wrote:
> >>   >> What will be the result of this query?
> >>
> >> Empty.
> >>
> >> Firstly - the <a> in the query is highly unlikely to be the same <a> as
> >> the data because the query and data have different base URIs. thsi
> >> appies to the SERVICE and non-SERVICE cases.
> >>
> >> The URI resolution of the query is at parse time so <p> inside the
> >> SERVICE is the same <p> in the triple pattern
> >>
> >> Adding a stable BASE, I get no results with Fuseki2 because the EXISTS
> >> ?x is substituted from the pattern.
> >>
> >> The Fuseki2 log shows a call back of:
> >>
> >> Query = SELECT  * WHERE   { <http://example/b> <http://example/p>
> >> <http://example/c>}
> >>
> >> which I guess is the core of your question?
> >>
> >> 	Andy
> >>
> >> ----------------------------
> >> BASE <http://example/>
> >> <a> <p> <b> .
> >> <a> <q> <c> .
> >> ----------------------------
> >> BASE <http://example/>
> >>
> >> SELECT *
> >> WHERE {
> >>      { <a> <p> ?x }
> >>      FILTER (
> >>        EXISTS { SERVICE <http://localhost:3030/ds/query> { ?x <p> <c> } }
> >>        )
> >> }
> >> ----------------------------
> >>
> >>
> >>
> >>
> >> On 23/12/14 15:04, Miguel Bento Alves wrote:
> >>> Daniel,
> >>>
> >>> what is the point?
> >>>
> >>> You didn’t clear if you have also a local dataset, but I think that the answer is the same, the result is empty. Why should be different?
> >>>
> >>> (in this situations, normally, I test. Seeing is believing :) ).
> >>>
> >>> In your dataset, instead of <a> <q> <c> you mean <a> <p> <c>?
> >>>
> >>> Miguel
> >>>
> >>>
> >>>
> >>>> On 23 Dec 2014, at 14:34, Daniel Hernández <da...@degu.cl> wrote:
> >>>>
> >>>> Hello,
> >>>>
> >>>> Let us consider a service <s> which default dataset contains the default
> >>>> graph:
> >>>>
> >>>> <a> <p> <b> .
> >>>> <a> <q> <c> .
> >>>>
> >>>> Let us consider the following query to be evaluated with the service <s>
> >>>> described above:
> >>>>
> >>>> SELECT *
> >>>> WHERE { { <a> <p> ?x } FILTER ( EXISTS ( ?x <p> <c> ) ) }
> >>>>
> >>>> I suppose that in this case the filter clause is evaluated for each
> >>>> solution of the graph pattern on the left. Thus, it is evaluated for
> >>>> {?x:<b>} and {?x:<c>}. Then the clauses will be:
> >>>>
> >>>> {?x:<b>} --> EXISTS ( <b> <p> <c> )    (FALSE)
> >>>> {?x:<c>} --> EXISTS ( <c> <p> <c> )    (FALSE)
> >>>>
> >>>> Then, the result of this query will be empty.
> >>>>
> >>>> Let us to consider the following query:
> >>>>
> >>>> SELECT *
> >>>> WHERE { { <a> <p> ?x }
> >>>>          FILTER ( EXISTS ( SERVICE <s> { ?x <p> <c> } ) ) }
> >>>>
> >>>> What will be the result of this query?
> >>>>
> >>>> Regards,
> >>>> Daniel
> >>>>
> >>>
> >>
> >
> >
> 



Re: [offtopic] An SPARQL question about service and variable scoping

Posted by Andy Seaborne <an...@apache.org>.
The formal description is the helper operation 'Substitute'

http://www.w3.org/TR/sparql11-query/#defn_substitute

and the evaluation text just below that.  SERVICE isn't special in 
anyway (whether it should be is whole different question!).

	Andy

On 23/12/14 19:50, Daniel Hernández wrote:
> The motivation of my question was to confirm that occurrences of ?x must
> be replaced by bindings in each of the solutions before sending the
> query to another service. But I do not found a simpler way to write that
> question. That's all.
>
> Thanks!
> Daniel
>
> On Tue, 2014-12-23 at 18:49 +0000, Andy Seaborne wrote:
>>   >> What will be the result of this query?
>>
>> Empty.
>>
>> Firstly - the <a> in the query is highly unlikely to be the same <a> as
>> the data because the query and data have different base URIs. thsi
>> appies to the SERVICE and non-SERVICE cases.
>>
>> The URI resolution of the query is at parse time so <p> inside the
>> SERVICE is the same <p> in the triple pattern
>>
>> Adding a stable BASE, I get no results with Fuseki2 because the EXISTS
>> ?x is substituted from the pattern.
>>
>> The Fuseki2 log shows a call back of:
>>
>> Query = SELECT  * WHERE   { <http://example/b> <http://example/p>
>> <http://example/c>}
>>
>> which I guess is the core of your question?
>>
>> 	Andy
>>
>> ----------------------------
>> BASE <http://example/>
>> <a> <p> <b> .
>> <a> <q> <c> .
>> ----------------------------
>> BASE <http://example/>
>>
>> SELECT *
>> WHERE {
>>      { <a> <p> ?x }
>>      FILTER (
>>        EXISTS { SERVICE <http://localhost:3030/ds/query> { ?x <p> <c> } }
>>        )
>> }
>> ----------------------------
>>
>>
>>
>>
>> On 23/12/14 15:04, Miguel Bento Alves wrote:
>>> Daniel,
>>>
>>> what is the point?
>>>
>>> You didn’t clear if you have also a local dataset, but I think that the answer is the same, the result is empty. Why should be different?
>>>
>>> (in this situations, normally, I test. Seeing is believing :) ).
>>>
>>> In your dataset, instead of <a> <q> <c> you mean <a> <p> <c>?
>>>
>>> Miguel
>>>
>>>
>>>
>>>> On 23 Dec 2014, at 14:34, Daniel Hernández <da...@degu.cl> wrote:
>>>>
>>>> Hello,
>>>>
>>>> Let us consider a service <s> which default dataset contains the default
>>>> graph:
>>>>
>>>> <a> <p> <b> .
>>>> <a> <q> <c> .
>>>>
>>>> Let us consider the following query to be evaluated with the service <s>
>>>> described above:
>>>>
>>>> SELECT *
>>>> WHERE { { <a> <p> ?x } FILTER ( EXISTS ( ?x <p> <c> ) ) }
>>>>
>>>> I suppose that in this case the filter clause is evaluated for each
>>>> solution of the graph pattern on the left. Thus, it is evaluated for
>>>> {?x:<b>} and {?x:<c>}. Then the clauses will be:
>>>>
>>>> {?x:<b>} --> EXISTS ( <b> <p> <c> )    (FALSE)
>>>> {?x:<c>} --> EXISTS ( <c> <p> <c> )    (FALSE)
>>>>
>>>> Then, the result of this query will be empty.
>>>>
>>>> Let us to consider the following query:
>>>>
>>>> SELECT *
>>>> WHERE { { <a> <p> ?x }
>>>>          FILTER ( EXISTS ( SERVICE <s> { ?x <p> <c> } ) ) }
>>>>
>>>> What will be the result of this query?
>>>>
>>>> Regards,
>>>> Daniel
>>>>
>>>
>>
>
>


Re: [offtopic] An SPARQL question about service and variable scoping

Posted by Daniel Hernández <da...@degu.cl>.
The motivation of my question was to confirm that occurrences of ?x must
be replaced by bindings in each of the solutions before sending the
query to another service. But I do not found a simpler way to write that
question. That's all.

Thanks!
Daniel

On Tue, 2014-12-23 at 18:49 +0000, Andy Seaborne wrote:
>  >> What will be the result of this query?
> 
> Empty.
> 
> Firstly - the <a> in the query is highly unlikely to be the same <a> as 
> the data because the query and data have different base URIs. thsi 
> appies to the SERVICE and non-SERVICE cases.
> 
> The URI resolution of the query is at parse time so <p> inside the 
> SERVICE is the same <p> in the triple pattern
> 
> Adding a stable BASE, I get no results with Fuseki2 because the EXISTS 
> ?x is substituted from the pattern.
> 
> The Fuseki2 log shows a call back of:
> 
> Query = SELECT  * WHERE   { <http://example/b> <http://example/p> 
> <http://example/c>}
> 
> which I guess is the core of your question?
> 
> 	Andy
> 
> ----------------------------
> BASE <http://example/>
> <a> <p> <b> .
> <a> <q> <c> .
> ----------------------------
> BASE <http://example/>
> 
> SELECT *
> WHERE {
>     { <a> <p> ?x }
>     FILTER (
>       EXISTS { SERVICE <http://localhost:3030/ds/query> { ?x <p> <c> } }
>       )
> }
> ----------------------------
> 
> 
> 
> 
> On 23/12/14 15:04, Miguel Bento Alves wrote:
> > Daniel,
> >
> > what is the point?
> >
> > You didn’t clear if you have also a local dataset, but I think that the answer is the same, the result is empty. Why should be different?
> >
> > (in this situations, normally, I test. Seeing is believing :) ).
> >
> > In your dataset, instead of <a> <q> <c> you mean <a> <p> <c>?
> >
> > Miguel
> >
> >
> >
> >> On 23 Dec 2014, at 14:34, Daniel Hernández <da...@degu.cl> wrote:
> >>
> >> Hello,
> >>
> >> Let us consider a service <s> which default dataset contains the default
> >> graph:
> >>
> >> <a> <p> <b> .
> >> <a> <q> <c> .
> >>
> >> Let us consider the following query to be evaluated with the service <s>
> >> described above:
> >>
> >> SELECT *
> >> WHERE { { <a> <p> ?x } FILTER ( EXISTS ( ?x <p> <c> ) ) }
> >>
> >> I suppose that in this case the filter clause is evaluated for each
> >> solution of the graph pattern on the left. Thus, it is evaluated for
> >> {?x:<b>} and {?x:<c>}. Then the clauses will be:
> >>
> >> {?x:<b>} --> EXISTS ( <b> <p> <c> )    (FALSE)
> >> {?x:<c>} --> EXISTS ( <c> <p> <c> )    (FALSE)
> >>
> >> Then, the result of this query will be empty.
> >>
> >> Let us to consider the following query:
> >>
> >> SELECT *
> >> WHERE { { <a> <p> ?x }
> >>         FILTER ( EXISTS ( SERVICE <s> { ?x <p> <c> } ) ) }
> >>
> >> What will be the result of this query?
> >>
> >> Regards,
> >> Daniel
> >>
> >
> 



Re: [offtopic] An SPARQL question about service and variable scoping

Posted by Andy Seaborne <an...@apache.org>.
 >> What will be the result of this query?

Empty.

Firstly - the <a> in the query is highly unlikely to be the same <a> as 
the data because the query and data have different base URIs. thsi 
appies to the SERVICE and non-SERVICE cases.

The URI resolution of the query is at parse time so <p> inside the 
SERVICE is the same <p> in the triple pattern

Adding a stable BASE, I get no results with Fuseki2 because the EXISTS 
?x is substituted from the pattern.

The Fuseki2 log shows a call back of:

Query = SELECT  * WHERE   { <http://example/b> <http://example/p> 
<http://example/c>}

which I guess is the core of your question?

	Andy

----------------------------
BASE <http://example/>
<a> <p> <b> .
<a> <q> <c> .
----------------------------
BASE <http://example/>

SELECT *
WHERE {
    { <a> <p> ?x }
    FILTER (
      EXISTS { SERVICE <http://localhost:3030/ds/query> { ?x <p> <c> } }
      )
}
----------------------------




On 23/12/14 15:04, Miguel Bento Alves wrote:
> Daniel,
>
> what is the point?
>
> You didn’t clear if you have also a local dataset, but I think that the answer is the same, the result is empty. Why should be different?
>
> (in this situations, normally, I test. Seeing is believing :) ).
>
> In your dataset, instead of <a> <q> <c> you mean <a> <p> <c>?
>
> Miguel
>
>
>
>> On 23 Dec 2014, at 14:34, Daniel Hernández <da...@degu.cl> wrote:
>>
>> Hello,
>>
>> Let us consider a service <s> which default dataset contains the default
>> graph:
>>
>> <a> <p> <b> .
>> <a> <q> <c> .
>>
>> Let us consider the following query to be evaluated with the service <s>
>> described above:
>>
>> SELECT *
>> WHERE { { <a> <p> ?x } FILTER ( EXISTS ( ?x <p> <c> ) ) }
>>
>> I suppose that in this case the filter clause is evaluated for each
>> solution of the graph pattern on the left. Thus, it is evaluated for
>> {?x:<b>} and {?x:<c>}. Then the clauses will be:
>>
>> {?x:<b>} --> EXISTS ( <b> <p> <c> )    (FALSE)
>> {?x:<c>} --> EXISTS ( <c> <p> <c> )    (FALSE)
>>
>> Then, the result of this query will be empty.
>>
>> Let us to consider the following query:
>>
>> SELECT *
>> WHERE { { <a> <p> ?x }
>>         FILTER ( EXISTS ( SERVICE <s> { ?x <p> <c> } ) ) }
>>
>> What will be the result of this query?
>>
>> Regards,
>> Daniel
>>
>


Re: [offtopic] An SPARQL question about service and variable scoping

Posted by Miguel Bento Alves <mb...@gmail.com>.
Daniel, 

what is the point?

You didn’t clear if you have also a local dataset, but I think that the answer is the same, the result is empty. Why should be different?

(in this situations, normally, I test. Seeing is believing :) ). 

In your dataset, instead of <a> <q> <c> you mean <a> <p> <c>?

Miguel



> On 23 Dec 2014, at 14:34, Daniel Hernández <da...@degu.cl> wrote:
> 
> Hello,
> 
> Let us consider a service <s> which default dataset contains the default
> graph:
> 
> <a> <p> <b> .
> <a> <q> <c> .
> 
> Let us consider the following query to be evaluated with the service <s>
> described above:
> 
> SELECT *
> WHERE { { <a> <p> ?x } FILTER ( EXISTS ( ?x <p> <c> ) ) }
> 
> I suppose that in this case the filter clause is evaluated for each
> solution of the graph pattern on the left. Thus, it is evaluated for
> {?x:<b>} and {?x:<c>}. Then the clauses will be:
> 
> {?x:<b>} --> EXISTS ( <b> <p> <c> )    (FALSE)
> {?x:<c>} --> EXISTS ( <c> <p> <c> )    (FALSE)
> 
> Then, the result of this query will be empty.
> 
> Let us to consider the following query:
> 
> SELECT *
> WHERE { { <a> <p> ?x }
>        FILTER ( EXISTS ( SERVICE <s> { ?x <p> <c> } ) ) }
> 
> What will be the result of this query?
> 
> Regards,
> Daniel
>