- From: Olivier Corby <Olivier.Corby@sophia.inria.fr>
- Date: Mon, 28 Jun 2010 17:21:43 +0200
- To: SPARQL Working Group <public-rdf-dawg@w3.org>
- Message-ID: <4C28BE07.7080909@sophia.inria.fr>
Here is a first set of sub query test case. Best regards Olivier
ACTION 193: Subquery test case
graph and select
graph ?g is current graph
data:
g1 {
a p b
c p g1
}
query:
select * where {
graph ?g {
{select * where {?x ?p ?y}}
}
}
result:
?g=g1; ?x=a; ?p=p; ?y=b
?g=g1; ?x=c; ?p=p; ?y=g1
___________________________________
graph and select
graph ?g is current graph
inner variable ?g is bound to outer ?g
data:
g1 {
a p b
c p g1
}
query:
select * where {
graph ?g {
{select * where {?x ?p ?g}}
}
}
result:
?g=g1; ?x=c; ?p=p
___________________________________________________
graph and select
graph ?g is current graph
inner variable ?g is not bound to outer ?g
data:
g1 {
a p b
c p g1
}
query:
select * where {
graph ?g {
{select ?x where {?x ?p ?g}}
}
}
result:
?g=g1; ?x=a
?g=g1; ?x=c;
_____________________________________________________
from graph and select
the from does not apply to sub query because the graph pattern applies
data:
g1 {
a p b
c p g1
}
query:
select *
from <g2>
where {
graph ?g {
{select * where {?x ?p ?y}}
}
}
results:
?g=g1; ?x=a; ?p=p; ?y=b
?g=g1; ?x=c; ?p=p; ?y=g1
________________________________________________________
the from apply to sub query because the graph pattern applies
data:
g1 {
a p b
c p g1
}
query:
select *
from named <g1>
where {
graph ?g {
{select * where {?x ?p ?y}}
}
}
results:
?g=g1; ?x=a; ?p=p; ?y=b
?g=g1; ?x=c; ?p=p; ?y=g1
________________________________
the from apply to sub query
data:
g1 {
a p b
c p g1
}
query:
select *
from <g1>
where {
{select * where {?x ?p ?y}}
}
results:
?x=a; ?p=p; ?y=b
?x=c; ?p=p; ?y=g1
___________________________________
the from apply to sub query
data:
g1 {
a p b
c p g1
}
query:
select *
from named <g1>
where {
{select * where {graph ?g {?x ?p ?y}}}
}
results:
?g=g1; ?x=a; ?p=p; ?y=b
?g=g1; ?x=c; ?p=p; ?y=g1
_____________________________________
aggregate in subquery
data:
a p 1
a p 2
b p 2
query:
select * where {
{select max(?y) as ?max where {?x p ?y} }
?x p ?max
}
result:
?x=a; ?max=2
?x=b; ?max=2
_______________________________________
Nested subquery
data:
a p b
a q c
d p e
query:
select * where {
{select * where {
{select ?x where {?x q ?t}}
}}
?x p ?y
}
results:
?x=a; ?y=b
_____________________________________
subquery and exists
data:
a p b
query:
select * where {
{select * where {?x p ?y}}
filter(! exists {?x p ?y})
}
result empty
Received on Monday, 28 June 2010 15:22:23 UTC