You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Michael Brunnbauer <br...@netestate.de> on 2013/07/17 14:10:46 UTC
Federation/Subquery bug ?
hi all,
this query with Fuseki 0.2.7 on a TDB with named graphs yields 2 for ?c:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select (count(*) as ?c) where { graph ?g {
SERVICE <http://127.0.0.1:3030/datasets/query> {
?d rdfs:subClassOf <example>
}
?s ?p ?d
} }
But as soon as I wrap it as subquery, ?c is 9436 - the number of all triples
from all named graphs:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?c where {
select (count(*) as ?c) where { graph ?g {
SERVICE <http://127.0.0.1:3030/datasets/query> {
?d rdfs:subClassOf <example>
}
?s ?p ?d
} }
}
(The federated subquery on http://127.0.0.1:3030/datasets/query has one
subclass as result)
Is this a bug or a misunderstanding ?
Regards,
Michael Brunnbauer
--
++ Michael Brunnbauer
++ netEstate GmbH
++ Geisenhausener Straße 11a
++ 81379 München
++ Tel +49 89 32 19 77 80
++ Fax +49 89 32 19 77 89
++ E-Mail brunni@netestate.de
++ http://www.netestate.de/
++
++ Sitz: München, HRB Nr.142452 (Handelsregister B München)
++ USt-IdNr. DE221033342
++ Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
++ Prokurist: Dipl. Kfm. (Univ.) Markus Hendel
Re: Federation/Subquery bug ?
Posted by Andy Seaborne <an...@apache.org>.
Recorded as
https://issues.apache.org/jira/browse/JENA-494
Andy
Re: Federation/Subquery bug ?
Posted by Michael Brunnbauer <br...@netestate.de>.
Hello Andy,
On Thu, Jul 25, 2013 at 04:34:55PM +0100, Andy Seaborne wrote:
> My bad - I used "head" to label them.
Ah.
> But do these two queries, when complete, capture the issue?
Yes
> query 2 adds nothing?
Yes. Q2 and Q4 just demonstrate that "distinct ?g" does not solve the issue
(you suggested distinct ?g in an earlier mail). Sorry if this made things
complicated.
> This one, with 4 queries:
>
> http://mail-archives.apache.org/mod_mbox/jena-users/201307.mbox/%3C20130717190649.GA25207%40netestate.de%3E
>
> and we are taking about queries 1 and 3 ?
Yes.
> It's a bug - rewriting the scopes does not get propagated correctly to
> and from the SERVICE when there is a nested scope introduced by the
> additional projection.
I am very relieved to hear this ;-)
Regards,
Michael Brunnbauer
--
++ Michael Brunnbauer
++ netEstate GmbH
++ Geisenhausener Straße 11a
++ 81379 München
++ Tel +49 89 32 19 77 80
++ Fax +49 89 32 19 77 89
++ E-Mail brunni@netestate.de
++ http://www.netestate.de/
++
++ Sitz: München, HRB Nr.142452 (Handelsregister B München)
++ USt-IdNr. DE221033342
++ Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
++ Prokurist: Dipl. Kfm. (Univ.) Markus Hendel
Re: Federation/Subquery bug ?
Posted by Andy Seaborne <an...@apache.org>.
On 25/07/13 15:43, Michael Brunnbauer wrote:
>
> Hello Andy,
>
> On Thu, Jul 25, 2013 at 02:24:44PM +0100, Andy Seaborne wrote:
>> Can we agree on the test case?
>>
>> I don't get he same numbers as you (data changing?)
>> but do queries 1 and 3 represent the issue?
>
> No. They are truncated.
My bad - I used "head" to label them.
But do these two queries, when complete, capture the issue? query 2
adds nothing?
>
>> Reformatted for email:
>>
>> ==> Q1.rq <==
>> PREFIX :
>> <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/>
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>
>> SELECT (count(*) AS ?c)
>> WHERE
>> { GRAPH ?g
>> { SERVICE <http://www.imagesnippets.com/sparql/datasets>
>> { ?d rdfs:subClassOf :aidkjfsdf }
>> ?s ?p ?d
>> }
>>
>
> There is a "}" missing at the end.
>
>> ==> Q3.rq <==
>> PREFIX :
>> <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/>
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>
>> SELECT ?c
>> WHERE
>> { SELECT (count(*) AS ?c)
>> WHERE
>> { GRAPH ?g
>> { SERVICE <http://www.imagesnippets.com/sparql/datasets>
>> { ?d rdfs:subClassOf :aidkjfsdf }
>>
>>
>> Andy
>
> And here, "?s ?p ?d } } }" is missing at the end.
>
> My archived mail from Jul 17 contains the untruncated queries:
>
> http://mail-archives.apache.org/mod_mbox/jena-users/201307.mbox/browser
There are two messages from you:
This one, with 4 queries:
http://mail-archives.apache.org/mod_mbox/jena-users/201307.mbox/%3C20130717190649.GA25207%40netestate.de%3E
and we are taking about queries 1 and 3 ?
>
> If I add the missing stuff and execute those queries against our public endpoint
> http://www.imagesnippets.com/sparql/dbpedia, I currently get 1 for Q1 and
> 38188 for Q3. The result should be 1 for both.
>
> Regards,
>
> Michael Brunnbauer
>
It's a bug - rewriting the scopes does not get propagated correctly to
and from the SERVICE when there is a nested scope introduced by the
additional projection.
Andy
Re: Federation/Subquery bug ?
Posted by Michael Brunnbauer <br...@netestate.de>.
Hello Andy,
On Thu, Jul 25, 2013 at 02:24:44PM +0100, Andy Seaborne wrote:
> Can we agree on the test case?
>
> I don't get he same numbers as you (data changing?)
> but do queries 1 and 3 represent the issue?
No. They are truncated.
> Reformatted for email:
>
> ==> Q1.rq <==
> PREFIX :
> <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>
> SELECT (count(*) AS ?c)
> WHERE
> { GRAPH ?g
> { SERVICE <http://www.imagesnippets.com/sparql/datasets>
> { ?d rdfs:subClassOf :aidkjfsdf }
> ?s ?p ?d
> }
>
There is a "}" missing at the end.
> ==> Q3.rq <==
> PREFIX :
> <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>
> SELECT ?c
> WHERE
> { SELECT (count(*) AS ?c)
> WHERE
> { GRAPH ?g
> { SERVICE <http://www.imagesnippets.com/sparql/datasets>
> { ?d rdfs:subClassOf :aidkjfsdf }
>
>
> Andy
And here, "?s ?p ?d } } }" is missing at the end.
My archived mail from Jul 17 contains the untruncated queries:
http://mail-archives.apache.org/mod_mbox/jena-users/201307.mbox/browser
If I add the missing stuff and execute those queries against our public endpoint
http://www.imagesnippets.com/sparql/dbpedia, I currently get 1 for Q1 and
38188 for Q3. The result should be 1 for both.
Regards,
Michael Brunnbauer
--
++ Michael Brunnbauer
++ netEstate GmbH
++ Geisenhausener Straße 11a
++ 81379 München
++ Tel +49 89 32 19 77 80
++ Fax +49 89 32 19 77 89
++ E-Mail brunni@netestate.de
++ http://www.netestate.de/
++
++ Sitz: München, HRB Nr.142452 (Handelsregister B München)
++ USt-IdNr. DE221033342
++ Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
++ Prokurist: Dipl. Kfm. (Univ.) Markus Hendel
Re: Federation/Subquery bug ?
Posted by Andy Seaborne <an...@apache.org>.
> can you confirm that this is a bug ? Should I contruct a minimal
example ?
Can we agree on the test case?
I don't get he same numbers as you (data changing?) but do queries 1 and
3 represent the issue?
Reformatted for email:
==> Q1.rq <==
PREFIX :
<http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT (count(*) AS ?c)
WHERE
{ GRAPH ?g
{ SERVICE <http://www.imagesnippets.com/sparql/datasets>
{ ?d rdfs:subClassOf :aidkjfsdf }
?s ?p ?d
}
==> Q3.rq <==
PREFIX :
<http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?c
WHERE
{ SELECT (count(*) AS ?c)
WHERE
{ GRAPH ?g
{ SERVICE <http://www.imagesnippets.com/sparql/datasets>
{ ?d rdfs:subClassOf :aidkjfsdf }
Andy
>
> Hello Andy,
>
> On Wed, Jul 24, 2013 at 02:22:31PM +0100, Andy Seaborne wrote:
>> Line 8 sends the a request to the endpoint - GRAPH does not carry over
>> machines. Only the endpoint matters. So the SERVICE is on the default
>> graph (or union in this case).
>>
>> SELECT *
>> { ?d rdfs:subClassOf
>> <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf> }
>> ?s ?p ?d
>> }
>>
>> ?s ?p ?d is all triples - if the rdfs:subClassOf has one hit, then there
>> are #triples in all named graphs.
>
> But ?s ?p ?d is *outside* of the SERVICE in my query.
>
> And however my query is evaluated - adding a "select ?c where {" and "}"
> around it should not change the results - which is the case.
>
> Regards,
>
> Michael Brunnbauer
>
Re: Federation/Subquery bug ?
Posted by Michael Brunnbauer <br...@netestate.de>.
Hello Andy,
On Wed, Jul 24, 2013 at 02:22:31PM +0100, Andy Seaborne wrote:
> Line 8 sends the a request to the endpoint - GRAPH does not carry over
> machines. Only the endpoint matters. So the SERVICE is on the default
> graph (or union in this case).
>
> SELECT *
> { ?d rdfs:subClassOf
> <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf> }
> ?s ?p ?d
> }
>
> ?s ?p ?d is all triples - if the rdfs:subClassOf has one hit, then there
> are #triples in all named graphs.
But ?s ?p ?d is *outside* of the SERVICE in my query.
And however my query is evaluated - adding a "select ?c where {" and "}"
around it should not change the results - which is the case.
Regards,
Michael Brunnbauer
--
++ Michael Brunnbauer
++ netEstate GmbH
++ Geisenhausener Straße 11a
++ 81379 München
++ Tel +49 89 32 19 77 80
++ Fax +49 89 32 19 77 89
++ E-Mail brunni@netestate.de
++ http://www.netestate.de/
++
++ Sitz: München, HRB Nr.142452 (Handelsregister B München)
++ USt-IdNr. DE221033342
++ Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
++ Prokurist: Dipl. Kfm. (Univ.) Markus Hendel
Re: Federation/Subquery bug ?
Posted by Andy Seaborne <an...@apache.org>.
On 24/07/13 11:56, Michael Brunnbauer wrote:
>
> Hello Andy,
>
> can you confirm that this is a bug ? Should I contruct a minimal example ?
Not a bug that I can see.
Please format for email
1 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
2
3 SELECT ?c
4 WHERE
5 { SELECT (count(*) AS ?c)
6 WHERE
7 { GRAPH ?g
8 { SERVICE <http://www.imagesnippets.com/sparql/datasets>
9 { ?d rdfs:subClassOf
<http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf> }
10 ?s ?p ?d
11 }
12 }
13 }
Line 8 sends the a request to the endpoint - GRAPH does not carry over
machines. Only the endpoint matters. So the SERVICE is on the default
graph (or union in this case).
SELECT *
{ ?d rdfs:subClassOf
<http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf> }
?s ?p ?d
}
?s ?p ?d is all triples - if the rdfs:subClassOf has one hit, then there
are #triples in all named graphs.
Andy
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>> select ?c where {
>> select (count(*) as ?c) where { graph ?g {
>> SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d
rdfs:subClassOf
<http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
>> ?s ?p ?d.
>> }
>> }
>> }
>>
>> Result: 12347 (=The number of all triples in all named graphs)
>
> Regards,
>
> Michael Brunnbauer
>
> On Wed, Jul 17, 2013 at 09:06:49PM +0200, Michael Brunnbauer wrote:
>>
>> Hello Andy,
>>
>> the second query is the first query with "select ?c where {" and "}" around it.
>> I don't understand why it should return something else.
>>
>> Our SPARQL endpoints are public anyway so you can see yourself. The numbers
>> may change a bit due to user activity:
>>
>> http://www.imagesnippets.com/sparql/dbpedia
>>
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>> select (count(*) as ?c) where { graph ?g {
>> SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
>> ?s ?p ?d.
>> }
>> }
>>
>> Result: 1
>>
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>> select (count(distinct ?g) as ?c) where { graph ?g {
>> SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
>> ?s ?p ?d.
>> }
>> }
>>
>> Result: 1
>>
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>> select ?c where {
>> select (count(*) as ?c) where { graph ?g {
>> SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
>> ?s ?p ?d.
>> }
>> }
>> }
>>
>> Result: 12347 (=The number of all triples in all named graphs)
>>
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>> select ?c where {
>> select (count(distinct ?g) as ?c) where { graph ?g {
>> SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
>> ?s ?p ?d.
>> }
>> }
>> }
>>
>> Result: 1160 (=The number of named graphs)
>>
>> Should I have a close look at the SPARQL standard or is there a bug ?
>>
>> Regards,
>>
>> Michael Brunnbauer
>>
>> On Wed, Jul 17, 2013 at 07:10:14PM +0100, Andy Seaborne wrote:
>>> On 17/07/13 13:10, Michael Brunnbauer wrote:
>>>>
>>>> hi all,
>>>>
>>>> this query with Fuseki 0.2.7 on a TDB with named graphs yields 2 for ?c:
>>>>
>>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>>> select (count(*) as ?c) where { graph ?g {
>>>> SERVICE <http://127.0.0.1:3030/datasets/query> {
>>>> ?d rdfs:subClassOf <example>
>>>> }
>>>> ?s ?p ?d
>>>> } }
>>>>
>>>> But as soon as I wrap it as subquery, ?c is 9436 - the number of all
>>>> triples
>>> >from all named graphs:
>>>>
>>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>>> select ?c where {
>>>>
>>>> select (count(*) as ?c) where { graph ?g {
>>>> SERVICE <http://127.0.0.1:3030/datasets/query> {
>>>> ?d rdfs:subClassOf <example>
>>>> }
>>>> ?s ?p ?d
>>>> } }
>>>>
>>>> }
>>>>
>>>> (The federated subquery on http://127.0.0.1:3030/datasets/query has one
>>>> subclass as result)
>>>>
>>>> Is this a bug or a misunderstanding ?
>>>
>>> It's not a bug as far as I can see.
>>>
>>> To debug, try "SELECT * ... LIMIT 100"
>>>
>>> COUNT(*) is the number of rows in the answers. In your first query,
>>> there must be either two ?g and the { ?d rdfs:subClassOf <example> }
>>> matches once, or one ?g and { ?d rdfs:subClassOf <example> } matches twice.
>>>
>>> In the second query, that is joined with "?s ?p ?d" in the named graph
>>> of the local machine which has 4718 triples with the same ?d.
>>>
>>> select (count(distinct ?g) as ?c)
>>>
>>> would count the named graphs only (inefficiently!)
>>>
>>> Andy
>>>
>>>>
>>>> Regards,
>>>>
>>>> Michael Brunnbauer
>>>>
>>
>> --
>> ++ Michael Brunnbauer
>> ++ netEstate GmbH
>> ++ Geisenhausener Straße 11a
>> ++ 81379 München
>> ++ Tel +49 89 32 19 77 80
>> ++ Fax +49 89 32 19 77 89
>> ++ E-Mail brunni@netestate.de
>> ++ http://www.netestate.de/
>> ++
>> ++ Sitz: München, HRB Nr.142452 (Handelsregister B München)
>> ++ USt-IdNr. DE221033342
>> ++ Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
>> ++ Prokurist: Dipl. Kfm. (Univ.) Markus Hendel
>
>
>
Re: Federation/Subquery bug ?
Posted by Michael Brunnbauer <br...@netestate.de>.
Hello Andy,
can you confirm that this is a bug ? Should I contruct a minimal example ?
Regards,
Michael Brunnbauer
On Wed, Jul 17, 2013 at 09:06:49PM +0200, Michael Brunnbauer wrote:
>
> Hello Andy,
>
> the second query is the first query with "select ?c where {" and "}" around it.
> I don't understand why it should return something else.
>
> Our SPARQL endpoints are public anyway so you can see yourself. The numbers
> may change a bit due to user activity:
>
> http://www.imagesnippets.com/sparql/dbpedia
>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> select (count(*) as ?c) where { graph ?g {
> SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
> ?s ?p ?d.
> }
> }
>
> Result: 1
>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> select (count(distinct ?g) as ?c) where { graph ?g {
> SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
> ?s ?p ?d.
> }
> }
>
> Result: 1
>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> select ?c where {
> select (count(*) as ?c) where { graph ?g {
> SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
> ?s ?p ?d.
> }
> }
> }
>
> Result: 12347 (=The number of all triples in all named graphs)
>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> select ?c where {
> select (count(distinct ?g) as ?c) where { graph ?g {
> SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
> ?s ?p ?d.
> }
> }
> }
>
> Result: 1160 (=The number of named graphs)
>
> Should I have a close look at the SPARQL standard or is there a bug ?
>
> Regards,
>
> Michael Brunnbauer
>
> On Wed, Jul 17, 2013 at 07:10:14PM +0100, Andy Seaborne wrote:
> > On 17/07/13 13:10, Michael Brunnbauer wrote:
> > >
> > >hi all,
> > >
> > >this query with Fuseki 0.2.7 on a TDB with named graphs yields 2 for ?c:
> > >
> > >PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> > >select (count(*) as ?c) where { graph ?g {
> > > SERVICE <http://127.0.0.1:3030/datasets/query> {
> > > ?d rdfs:subClassOf <example>
> > > }
> > > ?s ?p ?d
> > >} }
> > >
> > >But as soon as I wrap it as subquery, ?c is 9436 - the number of all
> > >triples
> > >from all named graphs:
> > >
> > >PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> > >select ?c where {
> > >
> > >select (count(*) as ?c) where { graph ?g {
> > > SERVICE <http://127.0.0.1:3030/datasets/query> {
> > > ?d rdfs:subClassOf <example>
> > > }
> > > ?s ?p ?d
> > >} }
> > >
> > >}
> > >
> > >(The federated subquery on http://127.0.0.1:3030/datasets/query has one
> > >subclass as result)
> > >
> > >Is this a bug or a misunderstanding ?
> >
> > It's not a bug as far as I can see.
> >
> > To debug, try "SELECT * ... LIMIT 100"
> >
> > COUNT(*) is the number of rows in the answers. In your first query,
> > there must be either two ?g and the { ?d rdfs:subClassOf <example> }
> > matches once, or one ?g and { ?d rdfs:subClassOf <example> } matches twice.
> >
> > In the second query, that is joined with "?s ?p ?d" in the named graph
> > of the local machine which has 4718 triples with the same ?d.
> >
> > select (count(distinct ?g) as ?c)
> >
> > would count the named graphs only (inefficiently!)
> >
> > Andy
> >
> > >
> > >Regards,
> > >
> > >Michael Brunnbauer
> > >
>
> --
> ++ Michael Brunnbauer
> ++ netEstate GmbH
> ++ Geisenhausener Straße 11a
> ++ 81379 München
> ++ Tel +49 89 32 19 77 80
> ++ Fax +49 89 32 19 77 89
> ++ E-Mail brunni@netestate.de
> ++ http://www.netestate.de/
> ++
> ++ Sitz: München, HRB Nr.142452 (Handelsregister B München)
> ++ USt-IdNr. DE221033342
> ++ Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
> ++ Prokurist: Dipl. Kfm. (Univ.) Markus Hendel
--
++ Michael Brunnbauer
++ netEstate GmbH
++ Geisenhausener Straße 11a
++ 81379 München
++ Tel +49 89 32 19 77 80
++ Fax +49 89 32 19 77 89
++ E-Mail brunni@netestate.de
++ http://www.netestate.de/
++
++ Sitz: München, HRB Nr.142452 (Handelsregister B München)
++ USt-IdNr. DE221033342
++ Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
++ Prokurist: Dipl. Kfm. (Univ.) Markus Hendel
Re: Federation/Subquery bug ?
Posted by Michael Brunnbauer <br...@netestate.de>.
Hello Andy,
the second query is the first query with "select ?c where {" and "}" around it.
I don't understand why it should return something else.
Our SPARQL endpoints are public anyway so you can see yourself. The numbers
may change a bit due to user activity:
http://www.imagesnippets.com/sparql/dbpedia
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select (count(*) as ?c) where { graph ?g {
SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
?s ?p ?d.
}
}
Result: 1
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select (count(distinct ?g) as ?c) where { graph ?g {
SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
?s ?p ?d.
}
}
Result: 1
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?c where {
select (count(*) as ?c) where { graph ?g {
SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
?s ?p ?d.
}
}
}
Result: 12347 (=The number of all triples in all named graphs)
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?c where {
select (count(distinct ?g) as ?c) where { graph ?g {
SERVICE <http://www.imagesnippets.com/sparql/datasets> { ?d rdfs:subClassOf <http://www.imagesnippets.com/imgtag/datasets/Michaels_Dataset/aidkjfsdf>. }
?s ?p ?d.
}
}
}
Result: 1160 (=The number of named graphs)
Should I have a close look at the SPARQL standard or is there a bug ?
Regards,
Michael Brunnbauer
On Wed, Jul 17, 2013 at 07:10:14PM +0100, Andy Seaborne wrote:
> On 17/07/13 13:10, Michael Brunnbauer wrote:
> >
> >hi all,
> >
> >this query with Fuseki 0.2.7 on a TDB with named graphs yields 2 for ?c:
> >
> >PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> >select (count(*) as ?c) where { graph ?g {
> > SERVICE <http://127.0.0.1:3030/datasets/query> {
> > ?d rdfs:subClassOf <example>
> > }
> > ?s ?p ?d
> >} }
> >
> >But as soon as I wrap it as subquery, ?c is 9436 - the number of all
> >triples
> >from all named graphs:
> >
> >PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> >select ?c where {
> >
> >select (count(*) as ?c) where { graph ?g {
> > SERVICE <http://127.0.0.1:3030/datasets/query> {
> > ?d rdfs:subClassOf <example>
> > }
> > ?s ?p ?d
> >} }
> >
> >}
> >
> >(The federated subquery on http://127.0.0.1:3030/datasets/query has one
> >subclass as result)
> >
> >Is this a bug or a misunderstanding ?
>
> It's not a bug as far as I can see.
>
> To debug, try "SELECT * ... LIMIT 100"
>
> COUNT(*) is the number of rows in the answers. In your first query,
> there must be either two ?g and the { ?d rdfs:subClassOf <example> }
> matches once, or one ?g and { ?d rdfs:subClassOf <example> } matches twice.
>
> In the second query, that is joined with "?s ?p ?d" in the named graph
> of the local machine which has 4718 triples with the same ?d.
>
> select (count(distinct ?g) as ?c)
>
> would count the named graphs only (inefficiently!)
>
> Andy
>
> >
> >Regards,
> >
> >Michael Brunnbauer
> >
--
++ Michael Brunnbauer
++ netEstate GmbH
++ Geisenhausener Straße 11a
++ 81379 München
++ Tel +49 89 32 19 77 80
++ Fax +49 89 32 19 77 89
++ E-Mail brunni@netestate.de
++ http://www.netestate.de/
++
++ Sitz: München, HRB Nr.142452 (Handelsregister B München)
++ USt-IdNr. DE221033342
++ Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
++ Prokurist: Dipl. Kfm. (Univ.) Markus Hendel
Re: Federation/Subquery bug ?
Posted by Andy Seaborne <an...@apache.org>.
On 17/07/13 13:10, Michael Brunnbauer wrote:
>
> hi all,
>
> this query with Fuseki 0.2.7 on a TDB with named graphs yields 2 for ?c:
>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> select (count(*) as ?c) where { graph ?g {
> SERVICE <http://127.0.0.1:3030/datasets/query> {
> ?d rdfs:subClassOf <example>
> }
> ?s ?p ?d
> } }
>
> But as soon as I wrap it as subquery, ?c is 9436 - the number of all triples
> from all named graphs:
>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> select ?c where {
>
> select (count(*) as ?c) where { graph ?g {
> SERVICE <http://127.0.0.1:3030/datasets/query> {
> ?d rdfs:subClassOf <example>
> }
> ?s ?p ?d
> } }
>
> }
>
> (The federated subquery on http://127.0.0.1:3030/datasets/query has one
> subclass as result)
>
> Is this a bug or a misunderstanding ?
It's not a bug as far as I can see.
To debug, try "SELECT * ... LIMIT 100"
COUNT(*) is the number of rows in the answers. In your first query,
there must be either two ?g and the { ?d rdfs:subClassOf <example> }
matches once, or one ?g and { ?d rdfs:subClassOf <example> } matches twice.
In the second query, that is joined with "?s ?p ?d" in the named graph
of the local machine which has 4718 triples with the same ?d.
select (count(distinct ?g) as ?c)
would count the named graphs only (inefficiently!)
Andy
>
> Regards,
>
> Michael Brunnbauer
>