gjhiggins/rdfextras — Issue #7: assert in SPARQL query when two OPTIONAL are followed by non-OPTIONAL
Author: gjhiggins
Created: 2011-10-19 02:58:37+00:00
State: open

Originally filed by gjhigg...@gmail.com on 2010-09-14T22:20:34

Issue 90, migrated from rdflib

from rdflib.Graph import *
# This code generate an assert
Graph().query("""select * {
optional { ?a ?b ?c }
optional { ?d ?e ?f }
?x ?y ?z
}""")

# This is OK
Graph().query("""select * {
?x ?y ?z
optional { ?a ?b ?c }
optional { ?d ?e ?f }
}""")

# This is OK
Graph().query("""select * {
optional { ?a ?b ?c }
?x ?y ?z
optional { ?d ?e ?f }
}""")

All three queries now consistently cause an assert failure:

AssertionError: EmptyGraphPatternExpression(..)
function ReduceToAlgebra in Algebra.py at line 166
assert isinstance(left,(Join,BasicGraphPattern)),repr(left)

## Full SPARQL Algebra expression ##
LeftJoin(LeftJoin(BGP((?x,?y,?z)),BGP((?a,?b,?c))),BGP((?d,?e,?f)))
###################################
## Full SPARQL Algebra expression ##
LeftJoin(LeftJoin(BGP((?x,?y,?z)),BGP((?a,?b,?c))),BGP((?d,?e,?f)))
###################################
eval(
LeftJoin
(LeftJoin(BGP( (?x,?y,?z)),
BGP((?a,?b,?c))),
BGP((?d,?e,?f))),
{},
[a rdfg:Graph;rdflib:storage [a rdflib:Store;rdfs:label 'IOMemory']].)

eval(
LeftJoin(BGP((?x,?y,?z)),
BGP((?a,?b,?c))),
{},
[a rdfg:Graph;rdflib:storage [a rdflib:Store;rdfs:label 'IOMemory']].)
## Full SPARQL Algebra expression ##
LeftJoin(EmptyGraphPatternExpression(..),BGP((?d,?e,?f)))
###################################
## Full SPARQL Algebra expression ##
LeftJoin(EmptyGraphPatternExpression(..),BGP((?d,?e,?f)))
###################################
eval(
LeftJoin(EmptyGraphPatternExpression(..),
BGP((?d,?e,?f))),
{},
[a rdfg:Graph;rdflib:storage [a rdflib:Store;rdfs:label 'IOMemory']].)

eval(
EmptyGraphPatternExpression(..),
{},
[a rdfg:Graph;rdflib:storage [a rdflib:Store;rdfs:label 'IOMemory']].)