A SPARQL query that runs with fuseki but not with stardog, what am I doing wrong?

The following query runs with fuseki, but returns error with stardog

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX eco: <http://pid.bayer.com/kos/19014/>
  prefix kge:   <https://pid.bayer.com/kge/> 
  construct {
    <https://pid.bayer.com/kge/CwidDB> kge:namedGraphs ?g
    graph <https://pid.bayer.com/kge/triplestores>{
      <https://pid.bayer.com/kge/CwidDB>            kge:password    ?password ;
          kge:queryPath   ?queryPath ;
          kge:runsOn      ?triplestroreSystem ;
          kge:updatePath  ?updatePath ;
          kge:user        ?username ;
      rdfs:label ?triplestoreLabel .
    graph <https://pid.bayer.com/kge/triplestoreSystems> {
          kge:host      ?host ;
          kge:port      ?port ;
          kge:protocol  ?protocol .
    bind ( uri(concat(str(?protocol),"://",?username,":",?password,"@",str(?host),":",str(?port),str(?queryPath))) as ?connectionURI )
    Service ?connectionURI{
      Select ?g {
        graph ?g{
          ?s ?p ?o
    graph <https://pid.bayer.com/kge/virtualGraphs> {
     ?vg  kge:belongsToDB <https://pid.bayer.com/kge/CwidDB>;
          kge:vGraphName  ?g

here is the error message

with query plan
N/A against database kgeConfiguration
java.lang.IllegalArgumentException: Unable to bind input variables (connectionURI) while keeping output variables () unbound for 
Service ?connectionURI  {
`\u2500 {
   `\u2500 Scan[SPO](?s, ?p, ?o){?g, Named}

Any idea what I can do?


Could you try to change this line:

bind ( uri(concat(str(?protocol),"://",?username,":",?password,"@",str(?host),":",str(?port),str(?queryPath))) as ?connectionURI )


bind ( coalesce(uri(concat(str(?protocol),"://",?username,":",?password,"@",str(?host),":",str(?port),str(?queryPath))), "") as ?connectionURI )

SERVICEes with a variable in the service IRI position are not quite standardised so there could be differences in behaviour. Since ?connectionURI is bound to an expression, and the expression evaluation could in principle result in an error (thus leaving the variable without a value), Stardog cannot immediately use it as the service IRI. Admittedly, the error message isn't clear enough.

If it doesn't solve it, we'll try to reproduce locally,

1 Like

Hi Pavel,

that solved the problem. Thanks a lot.

The result had some duplicates. I added "distinct" in front of ?g in the select part of the federated part. And now I have the expected outcome.

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