[redland-dev] Trouble with UNION query: RedlandWarning: Triple with unbound subject skipped
Josh Mandel
Joshua.Mandel at childrens.harvard.edu
Fri Jul 30 22:16:59 CEST 2010
I've been seeing what seems like unexpected behavior when I run a
SPARQL query involving a UNION: I get only one clause's worth of
results, and then a:
/usr/lib/python2.6/dist-packages/RDF.py:1373: RedlandWarning: Triple
with unbound subject skipped
I'm running Python 2.6.5 and the python-librdf package distributed
with Ubuntu 10.04. Here's a snippet of code to reproduce the
problem...
What does this mean? Is my query flawed? Any advice would be much appreciated!
-Josh
---
import RDF
breaks = """<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:test="http://test/">
<rdf:Description>
<rdf:type rdf:resource="http://test/a"/>
<test:property>happy</test:property>
<test:property>thoughts</test:property>
</rdf:Description>
<rdf:Description>
<rdf:type rdf:resource="http://test/b"/>
<test:property>sadmess</test:property>
</rdf:Description>
</rdf:RDF>"""
model = RDF.Model()
parser = RDF.Parser()
parser.parse_string_into_model(model, breaks, "base")
model_size = len(model)
q1 = RDF.SPARQLQuery("""
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
CONSTRUCT {?s ?p ?o.}
WHERE
{
{
?s rdf:type <http://test/a>.
?s ?p ?o.
}
UNION
{
?s rdf:type <http://test/b>.
?s ?p ?o.
}
}
""")
r1 = q1.execute(model)
s1 = r1.as_stream()
c1 = 0
for v in s1:
c1 += 1
print v, c1
assert(c1 == model_size), "Query did not find all rows."
More information about the redland-dev
mailing list