Behaviour with federation and reasoning

I do not understand what is happening here. Anyone can enlighten me?

Following code works with reasoning enabled.

SELECT *
WHERE {
  {SERVICE <http://admin:admin@localhost:5820/vla/query>
  {?x a <http://example.org/eu#Thing>; rdfs:label ?v.}}
  
UNION
  {SERVICE <http://admin:admin@localhost:5820/wallon/query>
  {?x a <http://example.org/eu#Thing>; rdfs:label ?v.}}}

When changing the query to

SELECT *
    WHERE {
      {SERVICE <http://admin:admin@localhost:5820/vla/query>
      {?x a <http://example.org/eu#Thing>; ?p ?v.}}
      
    UNION
      {SERVICE <http://admin:admin@localhost:5820/wallon/query>
      {?x a <http://example.org/eu#Thing>; ?p ?v.}}}

replacing the predicate into a variable, I get a server error with in the log
Caused by: java.lang.IllegalArgumentException: Service clause contains a pattern not supported by reasoning: prefix : http://api.stardog.com/
prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
prefix rdfs: http://www.w3.org/2000/01/rdf-schema#
prefix xsd: http://www.w3.org/2001/XMLSchema#
prefix owl: http://www.w3.org/2002/07/owl#
prefix stardog: tag:stardog:api:

Property(?x, ?p, ?v)
`─ {
   `─ Singleton [#1]
   }

	at com.complexible.stardog.reasoning.blackout.BlackoutRewriter$1.transform(BlackoutRewriter.java:199) ~[stardog-reasoning-core-5.2.2.jar:?]
	at com.complexible.stardog.plan.TransformingPlanNodeVisitor.visit(TransformingPlanNodeVisitor.java:925) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.ServicePlanNodeImpl.accept(ServicePlanNodeImpl.java:90) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryVisit(TransformingPlanNodeVisitor.java:599) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryTransform(TransformingPlanNodeVisitor.java:80) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.TransformingPlanNodeVisitor.transform(TransformingPlanNodeVisitor.java:345) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.TransformingPlanNodeVisitor.visit(TransformingPlanNodeVisitor.java:837) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.ProjectionPlanNodeImpl.accept(ProjectionPlanNodeImpl.java:162) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryVisit(TransformingPlanNodeVisitor.java:599) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryTransform(TransformingPlanNodeVisitor.java:80) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.TransformingPlanNodeVisitor.transform(TransformingPlanNodeVisitor.java:355) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.TransformingPlanNodeVisitor.visit(TransformingPlanNodeVisitor.java:829) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.SlicePlanNodeImpl.accept(SlicePlanNodeImpl.java:103) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.TransformingPlanNodeVisitor.transform(TransformingPlanNodeVisitor.java:65) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.reasoning.blackout.RewriteVisitor.rewrite(RewriteVisitor.java:69) ~[stardog-reasoning-core-5.2.2.jar:?]
	at com.complexible.stardog.reasoning.blackout.BlackoutRewriter.optimize(BlackoutRewriter.java:104) ~[stardog-reasoning-core-5.2.2.jar:?]
	at com.complexible.stardog.plan.optimizer.OptimizationPipeline.execute(OptimizationPipeline.java:125) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.eval.ExecutablePlanFactory.optimizePlan(ExecutablePlanFactory.java:136) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.eval.ExecutablePlanFactory.lambda$createOptimized$0(ExecutablePlanFactory.java:101) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.cache.SimplePlanCache.get(SimplePlanCache.java:110) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.eval.ExecutablePlanFactory.createOptimized(ExecutablePlanFactory.java:101) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.eval.QueryEngine.getExecutablePlan(QueryEngine.java:333) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.eval.QueryEngine.getExecutablePlan(QueryEngine.java:279) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.plan.eval.QueryEngine.executeSelect(QueryEngine.java:215) ~[stardog-5.2.2.jar:?]
	at com.complexible.stardog.query.DefaultQueryFactory$TupleQuery.execute(DefaultQueryFactory.java:204) ~[stardog-5.2.2.jar:?]
	... 10 more

Hi Paul,

The issue here is that having variable predicates within a SERVICE clause when reasoning is enabled on the local query is disallowed.

To work around this, you can disable reasoning on the query itself, but add it to the endpoints in your SERVICE clauses:

SELECT *
    WHERE {
      {SERVICE <http://admin:admin@localhost:5820/vla/query/reasoning>
      {?x a <http://example.org/eu#Thing>; ?p ?v.}}
      
    UNION
      {SERVICE <http://admin:admin@localhost:5820/wallon/query/reasoning>
      {?x a <http://example.org/eu#Thing>; ?p ?v.}}}

Hi Stephen,

Thanks.

Do I understand your suggestion correctly that this only works if using also stardog on the federated endpoints.
The POC I wanted to make to a prospect customer was using whatever SPARQL endpoint.

I believe the only requirement for the federated endpoints is that it support SPARQL. Enabling reasoning on that endpoint would depend on the specific system servicing that endpoint.

Paul,

You are correct. This workaround specifically avoids local reasoning in favor of remote reasoning. It would not work if the remote endpoints are not Stardog instances.

Zach,

This is the only requirement in general but the current limitation is that we don’t rewrite variable predicate queries with reasoning (e.g. ?s ?p ?o) to pure SPARQL. This is something that we plan to address in a future release.

Jess

I’m a little confused. The work around where local reasoning is disabled and remote reasoning is enabled won’t work if the remote services are not Stardog?

I would have thought that in that case it would be a straight up service query. How would Stardog even know if the remote had reasoning enabled or disabled? Or are you referring to the construction of the endpoint as …/query/reasoning?

We can’t rewrite the query into pure SPARQL so we can’t rely on local reasoning and thus delegate to remote reasoning. The /query/reasoning endpoint makes this possible. Obviously this is dependent on the remote system performing the required reasoning which may not be possible in all cases.

Jess

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