PREFIX schema: <https://schema.org/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX sioc: <http://rdfs.org/sioc/ns#>
SELECT DISTINCT ?employee ?reportsToEmployee ?reportsToEmployeeLabel
WHERE
{ GRAPH ?docGraph
{ ?doc sioc:has_container <https://localhost:4443/employees/> ;
foaf:primaryTopic ?employee
OPTIONAL
{ ?employee schema:sponsor ?reportsToEmployee }
}
OPTIONAL
{ GRAPH ?reportsToEmployeeLabelGraph
{ ?reportsToEmployee
<http://purl.org/dc/terms/title> ?reportsToEmployeeLabel
}
}
}
ORDER BY ?doc
Fuseki --engine=ref: 2417 results
Fuseki --optimize=off: 2417 results
Dydra: 9 results
RDF4J: 2417 results
PREFIX schema: <https://schema.org/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX sioc: <http://rdfs.org/sioc/ns#>
SELECT DISTINCT ?employee ?reportsToEmployee ?reportsToEmployeeLabel
WHERE
{ GRAPH ?docGraph
{ ?doc sioc:has_container <https://localhost:4443/employees/> ;
foaf:primaryTopic ?employee
OPTIONAL
{ ?employee schema:sponsor ?reportsToEmployee }
}
OPTIONAL
{ { SELECT DISTINCT ?reportsToEmployee ?reportsToEmployeeLabel
WHERE
{ { ?reportsToEmployee <http://purl.org/dc/terms/title>
?reportsToEmployeeLabel }
UNION
{ GRAPH ?reportsToEmployeeLabelGraph
{ ?reportsToEmployee
<http://purl.org/dc/terms/title> ?reportsToEmployeeLabel }
}
}
}
}
}
ORDER BY ?doc
Fuseki --engine=ref: 2417 results
Fuseki --optimize=off: 2417 results
Dydra: 9 results
RDF4J: 9 results
On Tue, Nov 24, 2020 at 4:43 PM Andy Seaborne <[email protected]> wrote:
>
> Try the reference query engine.
>
> sparql --engine=ref ...
>
> and also without optimization on the the general engine --optimize=off
>
> Andy
>
> On 24/11/2020 14:19, Martynas Jusevičius wrote:
> > I've just tried a third implementation (RDF4J 3.4.4) which produces
> > the same result as Fuseki (2419 rows):
> >
> > employee,reportsToEmployee,reportsToEmployeeLabel
> > https://localhost:4443/employees/1/#this,https://localhost:4443/employees/2/#this,Fuller
> > https://localhost:4443/employees/2/#this,https://localhost:4443/,Root
> > https://localhost:4443/employees/2/#this,https://localhost:4443/categories/,Categories
> > https://localhost:4443/employees/2/#this,https://localhost:4443/categories/1/,Beverages
> > https://localhost:4443/employees/2/#this,https://localhost:4443/categories/1/#this,Beverages
> > https://localhost:4443/employees/2/#this,https://localhost:4443/categories/2/,Condiments
> > https://localhost:4443/employees/2/#this,https://localhost:4443/categories/2/#this,Condiments
> > https://localhost:4443/employees/2/#this,https://localhost:4443/categories/3/,Confections
> > https://localhost:4443/employees/2/#this,https://localhost:4443/categories/3/#this,Confections
> > ....
> >
> > Which would suggest that Dydra is the outlier here.
> >
> > On Tue, Nov 24, 2020 at 2:27 PM Martynas Jusevičius
> > <[email protected]> wrote:
> >>
> >> Hi,
> >>
> >> despite using SPARQL for years, cases where different implementations
> >> return different results leave me scratching my head. Can someone help
> >> me out with this?
> >>
> >> I have a rather simple query:
> >>
> >> PREFIX schema: <https://schema.org/>
> >> PREFIX foaf: <http://xmlns.com/foaf/0.1/>
> >> PREFIX sioc: <http://rdfs.org/sioc/ns#>
> >>
> >> SELECT * WHERE {
> >> GRAPH ?docGraph {
> >> ?doc sioc:has_container <https://localhost:4443/employees/>;
> >> foaf:primaryTopic ?employee.
> >> OPTIONAL { ?employee schema:sponsor ?reportsToEmployee. }
> >> }
> >> }
> >> ORDER BY ?doc
> >>
> >> Dydra returns 9 results:
> >>
> >> employee,reportsToEmployee
> >> https://localhost:4443/employees/1/#this,https://localhost:4443/employees/2/#this
> >> https://localhost:4443/employees/2/#this,
> >> https://localhost:4443/employees/3/#this,https://localhost:4443/employees/2/#this
> >> https://localhost:4443/employees/4/#this,https://localhost:4443/employees/2/#this
> >> https://localhost:4443/employees/5/#this,https://localhost:4443/employees/2/#this
> >> https://localhost:4443/employees/6/#this,https://localhost:4443/employees/5/#this
> >> https://localhost:4443/employees/7/#this,https://localhost:4443/employees/5/#this
> >> https://localhost:4443/employees/8/#this,https://localhost:4443/employees/2/#this
> >> https://localhost:4443/employees/9/#this,https://localhost:4443/employees/5/#this
> >>
> >> Fuseki 3.16.0 returns 9 results:
> >>
> >> employee,reportsToEmployee
> >> https://localhost:4443/employees/1/#this,https://localhost:4443/employees/2/#this
> >> https://localhost:4443/employees/2/#this,
> >> https://localhost:4443/employees/3/#this,https://localhost:4443/employees/2/#this
> >> https://localhost:4443/employees/4/#this,https://localhost:4443/employees/2/#this
> >> https://localhost:4443/employees/5/#this,https://localhost:4443/employees/2/#this
> >> https://localhost:4443/employees/6/#this,https://localhost:4443/employees/5/#this
> >> https://localhost:4443/employees/7/#this,https://localhost:4443/employees/5/#this
> >> https://localhost:4443/employees/8/#this,https://localhost:4443/employees/2/#this
> >> https://localhost:4443/employees/9/#this,https://localhost:4443/employees/5/#this
> >>
> >> So far so good -- the results are identical. Now I append an OPTIONAL
> >> to the end of the query:
> >>
> >> PREFIX schema: <https://schema.org/>
> >> PREFIX foaf: <http://xmlns.com/foaf/0.1/>
> >> PREFIX sioc: <http://rdfs.org/sioc/ns#>
> >>
> >> SELECT ?employee ?reportsToEmployee ?reportsToEmployeeLabel WHERE {
> >> GRAPH ?docGraph {
> >> ?doc sioc:has_container <https://localhost:4443/employees/>;
> >> foaf:primaryTopic ?employee.
> >> OPTIONAL { ?employee schema:sponsor ?reportsToEmployee. }
> >> }
> >> OPTIONAL {
> >> GRAPH ?reportsToEmployeeLabelGraph { ?reportsToEmployee
> >> <http://purl.org/dc/terms/title> ?reportsToEmployeeLabel. }
> >> }
> >> }
> >> ORDER BY ?doc
> >>
> >> Dydra returns 9 results:
> >>
> >> employee,reportsToEmployee,reportsToEmployeeLabel
> >> https://localhost:4443/employees/1/#this,https://localhost:4443/employees/2/#this,Fuller
> >> https://localhost:4443/employees/2/#this,,
> >> https://localhost:4443/employees/3/#this,https://localhost:4443/employees/2/#this,Fuller
> >> https://localhost:4443/employees/4/#this,https://localhost:4443/employees/2/#this,Fuller
> >> https://localhost:4443/employees/5/#this,https://localhost:4443/employees/2/#this,Fuller
> >> https://localhost:4443/employees/6/#this,https://localhost:4443/employees/5/#this,Buchanan
> >> https://localhost:4443/employees/7/#this,https://localhost:4443/employees/5/#this,Buchanan
> >> https://localhost:4443/employees/8/#this,https://localhost:4443/employees/2/#this,Fuller
> >> https://localhost:4443/employees/9/#this,https://localhost:4443/employees/5/#this,Buchanan
> >>
> >> Fuseki 3.16.0 returns 2400+ results:
> >>
> >> employee,reportsToEmployee,reportsToEmployeeLabel
> >> https://localhost:4443/employees/1/#this,https://localhost:4443/employees/2/#this,Fuller
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/,Root
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/categories/,Categories
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/categories/1/,Beverages
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/categories/1/#this,Beverages
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/categories/2/,Condiments
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/categories/2/#this,Condiments
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/categories/3/,Confections
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/categories/3/#this,Confections
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/categories/4/,Dairy
> >> Products
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/categories/4/#this,Dairy
> >> Products
> >> https://localhost:4443/employees/2/#this,https://localhost:4443/categories/5/,Grains/Cereals
> >> ....
> >>
> >> Dydra's result is the one I'm going after, and is based on my
> >> understanding of OPTIONAL. But is it actually correct?
> >>
> >> And if Dydra is correct, what is Fuseki doing here? I would have
> >> expected the ?reportsToEmployee bindings from the appended OPTIONAL to
> >> be joined against the first result (without OPTIONAL), but that is not
> >> the case?
> >>
> >> Thanks.
> >>
> >> Martynas