You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Holger Knublauch <ho...@knublauch.com> on 2012/08/13 02:50:17 UTC

Is FROM inside of SERVICE legal?

The following query is not valid (verified with Jena 2.7.3):

SELECT *
WHERE
{
    SERVICE <http://example.org:8890/sparql>
    {  SELECT *
        FROM <http://ex.com/base>
        WHERE
        {   ?s a <http://ex.com/resource/Batch> .
             ?s <http://ex.com/resource/id> ?id .
        }
    }
}

The parser complains about the FROM. Is this supposed to work, or are we 
limited to using GRAPH instead?

Thanks
Holger


Re: Is FROM inside of SERVICE legal?

Posted by Andy Seaborne <an...@apache.org>.
On 14/08/12 14:35, Gary King wrote:
> FROM isn't legal inside of a sub-select (at least, it's not according to the grammer at http://www.w3.org/TR/sparql11-query/):
>
> [8]  	SubSelect	  ::=  	SelectClause WhereClause SolutionModifier ValuesClause
>
> maybe that's an oversight or worth changing...

It's by design.

Put the SERVICE clause aside for a moment and consider a sub-SELECT in 
single-site query.

The dataset does not change in the middle of query.

GRAPH is used to choose a graph to access.

FROM/FROM NAMED describes what data to query.

Now to SERVICE:

The design goal of SERVICE was access to remote data, not general 
computation.  The endpoint determines the data to be queried; it is nto 
a client choice.

You can construct use cases where this simple model is not good enough 
but that is not the goal of basic federated query (and also given the 
varity of interpretation of FROM, it's going to difficult to agree fixed 
semantics).

The main thing FROM gives you is the ability to merge several graphs and 
query the resultant graph.  That is not web friendly - if there is a 
large datasets, the last thing it wants is to create (virtual or 
materialized) so one-off specialised combination.  If it was valuable, 
providing the data as either a different endpoint or as a named graph 
would be sensible.

There is one hole -

SERVICE <http://host/endpoint?default-graph-uri=http://example/>
{
    ...
}

works in ARQ - additional query parameters are handled - if the remote 
endpoint does do arbitrary graph query (few do) then it will work.

This is

https://issues.apache.org/jira/browse/JENA-195

	Andy

The query could be:

SELECT *
WHERE
{
    SERVICE <http://example.org:8890/sparql>
    {  GRAPH <http://ex.com/base>
        {   ?s a <http://ex.com/resource/Batch> .
             ?s <http://ex.com/resource/id> ?id .
        }
    }
}



>
>
> On Aug 13, 2012, at 8:24 PM, Holger Knublauch <ho...@knublauch.com> wrote:
>
>> On 8/13/2012 14:14, Macedo Maia wrote:
>>> Sorry, now i understand your question. Do you want to acess any data in a
>>> virtuoso graph? If yes, you can try this query:
>>
>> Yes, but Jena doesn't accept the FROM clause inside the nested SELECT and that's what my question is about (probably to Andy).
>>
>> Thanks
>> Holger
>>
>>
>>>
>>> SELECT *
>>> WHERE
>>> {
>>>         SERVICE <http://example.org:8890/sparql>
>>>          {
>>>                SELECT ?s ?id
>>>                from <http://ex.com/base>
>>>                WHERE {
>>>                       GRAPH ?g{?s a <http://ex.com/resource/Batch> .
>>>                                        ?s <http://ex.com/resource/id> ?id .}
>>>                 }
>>>      }
>>> }
>>>
>>>
>>>> 2012/8/12 Holger Knublauch <ho...@knublauch.com>
>>>>>> The following query is not valid (verified with Jena 2.7.3):
>>>>>>
>>>>>> SELECT *
>>>>>> WHERE
>>>>>> {
>>>>>>     SERVICE <http://example.org:8890/sparql>
>>>>>>     {  SELECT *
>>>>>>         FROM <http://ex.com/base>
>>>>>>         WHERE
>>>>>>         {   ?s a <http://ex.com/resource/Batch> .
>>>>>>              ?s <http://ex.com/resource/id> ?id .
>>>>>>         }
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>> The parser complains about the FROM. Is this supposed to work, or are we
>>>>>> limited to using GRAPH instead?
>>>>>>
>>>>>> Thanks
>>>>>> Holger
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> *Macedo Sousa Maia*
>>>>> *Bacharel em Computação
>>>>> Mestrando em Computação
>>>>> ARIDA(Advanced Research in Database)
>>>>> *
>>>>> *Universidade Federal do Ceará(UFC)*
>>>>>
>>>>>
>>>>
>>>> --
>>>> *Macedo Sousa Maia*
>>>> *Bacharel em Computação
>>>> Mestrando em Computação
>>>> ARIDA(Advanced Research in Database)
>>>> *
>>>> *Universidade Federal do Ceará(UFC)*
>>>>
>>>>
>>>
>>>
>>
>
> --
> Gary Warren King, metabang.com
> Cell: (413) 559 8738
> Fax: (206) 338-4052
> gwkkwg on Skype * garethsan on AIM * gwking on twitter
>


Re: Is FROM inside of SERVICE legal?

Posted by Gary King <gw...@metabang.com>.
FROM isn't legal inside of a sub-select (at least, it's not according to the grammer at http://www.w3.org/TR/sparql11-query/):

[8]  	SubSelect	  ::=  	SelectClause WhereClause SolutionModifier ValuesClause

maybe that's an oversight or worth changing...


On Aug 13, 2012, at 8:24 PM, Holger Knublauch <ho...@knublauch.com> wrote:

> On 8/13/2012 14:14, Macedo Maia wrote:
>> Sorry, now i understand your question. Do you want to acess any data in a
>> virtuoso graph? If yes, you can try this query:
> 
> Yes, but Jena doesn't accept the FROM clause inside the nested SELECT and that's what my question is about (probably to Andy).
> 
> Thanks
> Holger
> 
> 
>> 
>> SELECT *
>> WHERE
>> {
>>        SERVICE <http://example.org:8890/sparql>
>>         {
>>               SELECT ?s ?id
>>               from <http://ex.com/base>
>>               WHERE {
>>                      GRAPH ?g{?s a <http://ex.com/resource/Batch> .
>>                                       ?s <http://ex.com/resource/id> ?id .}
>>                }
>>     }
>> }
>> 
>> 
>>> 2012/8/12 Holger Knublauch <ho...@knublauch.com>
>>>>> The following query is not valid (verified with Jena 2.7.3):
>>>>> 
>>>>> SELECT *
>>>>> WHERE
>>>>> {
>>>>>    SERVICE <http://example.org:8890/sparql>
>>>>>    {  SELECT *
>>>>>        FROM <http://ex.com/base>
>>>>>        WHERE
>>>>>        {   ?s a <http://ex.com/resource/Batch> .
>>>>>             ?s <http://ex.com/resource/id> ?id .
>>>>>        }
>>>>>    }
>>>>> }
>>>>> 
>>>>> The parser complains about the FROM. Is this supposed to work, or are we
>>>>> limited to using GRAPH instead?
>>>>> 
>>>>> Thanks
>>>>> Holger
>>>>> 
>>>>> 
>>>> 
>>>> --
>>>> *Macedo Sousa Maia*
>>>> *Bacharel em Computação
>>>> Mestrando em Computação
>>>> ARIDA(Advanced Research in Database)
>>>> *
>>>> *Universidade Federal do Ceará(UFC)*
>>>> 
>>>> 
>>> 
>>> --
>>> *Macedo Sousa Maia*
>>> *Bacharel em Computação
>>> Mestrando em Computação
>>> ARIDA(Advanced Research in Database)
>>> *
>>> *Universidade Federal do Ceará(UFC)*
>>> 
>>> 
>> 
>> 
> 

--
Gary Warren King, metabang.com 
Cell: (413) 559 8738
Fax: (206) 338-4052
gwkkwg on Skype * garethsan on AIM * gwking on twitter


Re: Is FROM inside of SERVICE legal?

Posted by Holger Knublauch <ho...@knublauch.com>.
On 8/13/2012 14:14, Macedo Maia wrote:
> Sorry, now i understand your question. Do you want to acess any data in a
> virtuoso graph? If yes, you can try this query:

Yes, but Jena doesn't accept the FROM clause inside the nested SELECT 
and that's what my question is about (probably to Andy).

Thanks
Holger


>
> SELECT *
> WHERE
> {
>         SERVICE <http://example.org:8890/sparql>
>          {
>                SELECT ?s ?id
>                from <http://ex.com/base>
>                WHERE {
>                       GRAPH ?g{?s a <http://ex.com/resource/Batch> .
>                                        ?s <http://ex.com/resource/id> ?id .}
>                 }
>      }
> }
>
>
>> 2012/8/12 Holger Knublauch <ho...@knublauch.com>
>>>> The following query is not valid (verified with Jena 2.7.3):
>>>>
>>>> SELECT *
>>>> WHERE
>>>> {
>>>>     SERVICE <http://example.org:8890/sparql>
>>>>     {  SELECT *
>>>>         FROM <http://ex.com/base>
>>>>         WHERE
>>>>         {   ?s a <http://ex.com/resource/Batch> .
>>>>              ?s <http://ex.com/resource/id> ?id .
>>>>         }
>>>>     }
>>>> }
>>>>
>>>> The parser complains about the FROM. Is this supposed to work, or are we
>>>> limited to using GRAPH instead?
>>>>
>>>> Thanks
>>>> Holger
>>>>
>>>>
>>>
>>> --
>>> *Macedo Sousa Maia*
>>> *Bacharel em Computação
>>> Mestrando em Computação
>>> ARIDA(Advanced Research in Database)
>>> *
>>> *Universidade Federal do Ceará(UFC)*
>>>
>>>
>>
>> --
>> *Macedo Sousa Maia*
>> *Bacharel em Computação
>> Mestrando em Computação
>> ARIDA(Advanced Research in Database)
>> *
>> *Universidade Federal do Ceará(UFC)*
>>
>>
>
>


Re: Is FROM inside of SERVICE legal?

Posted by Macedo Maia <85...@gmail.com>.
Sorry, now i understand your question. Do you want to acess any data in a
virtuoso graph? If yes, you can try this query:

SELECT *
WHERE
{
       SERVICE <http://example.org:8890/sparql>
        {
              SELECT ?s ?id
              from <http://ex.com/base>
              WHERE {
                     GRAPH ?g{?s a <http://ex.com/resource/Batch> .
                                      ?s <http://ex.com/resource/id> ?id .}
               }
    }
}


> 2012/8/12 Holger Knublauch <ho...@knublauch.com>
>>
>>> The following query is not valid (verified with Jena 2.7.3):
>>>
>>> SELECT *
>>> WHERE
>>> {
>>>    SERVICE <http://example.org:8890/sparql>
>>>    {  SELECT *
>>>        FROM <http://ex.com/base>
>>>        WHERE
>>>        {   ?s a <http://ex.com/resource/Batch> .
>>>             ?s <http://ex.com/resource/id> ?id .
>>>        }
>>>    }
>>> }
>>>
>>> The parser complains about the FROM. Is this supposed to work, or are we
>>> limited to using GRAPH instead?
>>>
>>> Thanks
>>> Holger
>>>
>>>
>>
>>
>> --
>> *Macedo Sousa Maia*
>> *Bacharel em Computação
>> Mestrando em Computação
>> ARIDA(Advanced Research in Database)
>> *
>> *Universidade Federal do Ceará(UFC)*
>>
>>
>
>
> --
> *Macedo Sousa Maia*
> *Bacharel em Computação
> Mestrando em Computação
> ARIDA(Advanced Research in Database)
> *
> *Universidade Federal do Ceará(UFC)*
>
>



-- 
*Macedo Sousa Maia*
*Bacharel em Computação
Mestrando em Computação
ARIDA(Advanced Research in Database)
*
*Universidade Federal do Ceará(UFC)*

Re: Is FROM inside of SERVICE legal?

Posted by Macedo Maia <85...@gmail.com>.
2012/8/13 Macedo Maia <85...@gmail.com>

> You can try this query
>
>
> SELECT *
> WHERE
> {
>    SERVICE <http://example.org:8890/sparql>
>    {  SELECT *
>        WHERE
>        {   ?s a <http://ex.com/resource/Batch> .
>             ?s <http://ex.com/resource/id> ?id .
>        }
>    }
> }
>
> 2012/8/12 Holger Knublauch <ho...@knublauch.com>
>
>> The following query is not valid (verified with Jena 2.7.3):
>>
>> SELECT *
>> WHERE
>> {
>>    SERVICE <http://example.org:8890/**sparql<http://example.org:8890/sparql>
>> >
>>    {  SELECT *
>>        FROM <http://ex.com/base>
>>        WHERE
>>        {   ?s a <http://ex.com/resource/Batch> .
>>             ?s <http://ex.com/resource/id> ?id .
>>        }
>>    }
>> }
>>
>> The parser complains about the FROM. Is this supposed to work, or are we
>> limited to using GRAPH instead?
>>
>> Thanks
>> Holger
>>
>>
>
>
> --
> *Macedo Sousa Maia*
> *Bacharel em Computação
> Mestrando em Computação
> ARIDA(Advanced Research in Database)
> *
> *Universidade Federal do Ceará(UFC)*
>
>


-- 
*Macedo Sousa Maia*
*Bacharel em Computação
Mestrando em Computação
ARIDA(Advanced Research in Database)
*
*Universidade Federal do Ceará(UFC)*

Re: Is FROM inside of SERVICE legal?

Posted by Macedo Maia <85...@gmail.com>.
You can try this query

SELECT *
WHERE
{
   SERVICE <http://example.org:8890/sparql>
   {  SELECT *
       WHERE
       {   ?s a <http://ex.com/resource/Batch> .
            ?s <http://ex.com/resource/id> ?id .
       }
   }
}

2012/8/12 Holger Knublauch <ho...@knublauch.com>

> The following query is not valid (verified with Jena 2.7.3):
>
> SELECT *
> WHERE
> {
>    SERVICE <http://example.org:8890/**sparql<http://example.org:8890/sparql>
> >
>    {  SELECT *
>        FROM <http://ex.com/base>
>        WHERE
>        {   ?s a <http://ex.com/resource/Batch> .
>             ?s <http://ex.com/resource/id> ?id .
>        }
>    }
> }
>
> The parser complains about the FROM. Is this supposed to work, or are we
> limited to using GRAPH instead?
>
> Thanks
> Holger
>
>


-- 
*Macedo Sousa Maia*
*Bacharel em Computação
Mestrando em Computação
ARIDA(Advanced Research in Database)
*
*Universidade Federal do Ceará(UFC)*