On 24/08/2024 18:33, Bob DuCharme wrote:
Thanks Andy! I understand a bit, but have some followup questions. For one thing, I  couldn't figure out which part of https://jena.apache.org/ about_jena/security-advisories.html was relevant to this.

"Jena (tested with Fuseki 4.6.1)" -- always good to keep up-to-date. Hint, hint.

Is it oversimplifying if I said:

-  many triplestores treat the default graph to be the union of all named groups with the triples in any unnamed graphs

- Jena does not do this by default but can be configured to

and that other triplestores do not support the full range that the specs allow especially update.

This query shows the six triples from the original example in Fuseki but shows ten rows of results in GraphDB (and, I will assume in the other triplestores I tried before sending my original email):

    SELECT DISTINCT ?s ?p ?o {
       { ?s ?p ?o }
       UNION
       { GRAPH ?g {?s ?p ?o }
    }

That query is "all triples" in default and named graphs.

Given there are only 6 "?s ?p ?o" anywhere in your example data I don't see how "DISTINCT ?s ?p ?o" can be 10.

If it's 10, then there must be duplicates after DISTINCT.

GraphDB finds triples via two routes - default graph and named graph - hence 10 in quads ?g/?s/?p/?o

Please try in other stores.

This is more verbose but got consistent results with the two triplestores. Any comments or suggestions?

SELECT ?g ?s ?p ?o
WHERE
{
     { ?s ?p ?o
       MINUS { GRAPH ?g {?s ?p ?o} }
     }
   UNION
   { GRAPH ?g { ?s ?p ?o } }
}

More expensive.  BTW it has ?g in the projection. Do you get rows with
?g undefined?


Thanks,

Bob


On 8/24/24 10:40 AM, Andy Seaborne wrote:


On 24/08/2024 15:20, Bob DuCharme wrote:
Imagine running the short INSERT query at https:// www.learningsparql.com/2ndeditionexamples/ex338.ru on an empty dataset. It inserts six triples: two in the default graph and two each into two named graphs, for a total of six triples.

Next, we run the query SELECT * WHERE {?s ?p ?o}. In some triplestores this returns a row for each of the six triples in the dataset, but Jena (tested with Fuseki 4.6.1)

Don't forget:
https://jena.apache.org/about_jena/security-advisories.html

> only returns rows for the two triples in the > default graph.

It depends on the setup.

The default graph is a separate graph unless the setup configures it to be viewed as the union of all named graphs.

In your example, you'll get 4 triples.

e.g. for TDB2:

:dataset_tdb2 rdf:type  tdb2:DatasetTDB2 ;
    tdb2:location "DB2" ;
    ## Optional - with union default
    ## for query and update WHERE matching.
    tdb2:unionDefaultGraph true ;
    .

Note - there still is a storage-level default graph. unionDefaultGraph is a view.

I can't find anything in the Recommendation about what should happen here.

The specs don't say much about how the dataset to be queried come into being without any FROM's.

This is intentional because treating the default graph as the union of named graphs has been a pattern since before the SPARQL 1.0.

In some systems, the default is really a named graph

It looks like https://www.w3.org/TR/sparql11-query/ #namedAndDefaultGraph would have been the place to clarify this. Is the issue of proper behavior in this case just up to the implementer, like what DESCRIBE is supposed to return? Or is it something that the sparql12 group should clarify and document? (Or maybe they have and I missed it...)

https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0004/sep-0004.md
https://github.com/w3c/sparql-dev/issues/43

There should be three names for the three cases:

DEFAULT
UNION (of named graphs)
ALL - a set view of all triples:
   SELECT DISTINCT ?s ?p ?o {
      { ?s ?p ?o }
      UNION
      { GRAPH ?g {?s ?p ?o }
   }

    Andy


Thanks,

Bob




Reply via email to