(rdf4j-stardog) CONSTRUCT query bringing default contexts

Hi all, I am performing the following CONSTRUCT query using the RDF4J connector:

    CONSTRUCT {
    	?s ?p ?o .
    }
    WHERE {
    	VALUES( ?g ){
    		( <http://my-test.com/test/> )
    	}

    	GRAPH ?g {
    		?s ?p ?o .
    	}
    }

When performing the exact same query with Stardog Studio no contexts are returned, as expected. However, executing it programmatically retrieves statements that contain a default Stardog context; which, in this case, is not desired.

Is retrieving contexts with CONSTRUCT queries the expected behaviour? If so, can this be disabled in any way to prevent it from happening?

Thanks in advanced for your help

Hi,

Could you share a data set that shows what you are experiencing? I recreated with some dummy data and I see what appear to be the right results:

try (RepositoryConnection c = repo.getConnection()) {
            final IRI aGraph = vf.createIRI("http://my-test.com/test/");
            c.begin();
            c.add(vf.createStatement(vf.createIRI("urn:a"), vf.createIRI("urn:b"), vf.createIRI("urn:c")));
            c.add(vf.createStatement(vf.createIRI("urn:d"), vf.createIRI("urn:e"), vf.createIRI("urn:f"), aGraph));
            c.commit();

            final String aQuery = "CONSTRUCT {\n" +
                                          "    \t?s ?p ?o .\n" +
                                          "    }\n" +
                                          "    WHERE {\n" +
                                          "    \tVALUES( ?g ){\n" +
                                          "    \t\t( <http://my-test.com/test/> )\n" +
                                          "    \t}\n" +
                                          "\n" +
                                          "    \tGRAPH ?g {\n" +
                                          "    \t\t?s ?p ?o .\n" +
                                          "    \t}\n" +
                                          "    }" ;

            try (GraphQueryResult res = c.prepareGraphQuery(aQuery).evaluate()) {
                while(res.hasNext()) {
                    System.out.println(res.next().toString());
                }
            }
        }
(urn:d, urn:e, urn:f) [tag:stardog:api:context:default]

Only the triple I inserted into the graph is displayed. It itself has the default context because CONSTRUCT { ?s ?p ?o } dictates that.

Hi Stephen, thanks for your response.

Your example is exactly the behavior I am encountering, my question revolves around the fact that executing the same query in Stardog Studio returns the requested triples without an added context, not even the default, hence my confusion. Finally, I would just like to know: if this is the expected behavior when using the connector, is there a way to disable it?

Stardog doesn't have the notion of a triple with NO context; having the default context is the same idea. The RDF produced by Studio is simply leaving the default context out because it doesn't need to be there.

Ok, got it.

I was wondering, since this behavior was not present in version 5, and it deviates from the SPARQL standard's expected behavior, is there a chance that a future release might implement a way for users to manage that configuration?

Thanks for your support!

Hi again,

As a matter of fact, upon further review this IS a bug, and it will be addressed in the next Stardog release. Thanks for reporting it!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.