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

**URL:** <https://community.stardog.com/t/a-sparql-query-that-runs-with-fuseki-but-not-with-stardog-what-am-i-doing-wrong/3248>\
**Category:** Support\
**Created:** [September 8, 2021, 9:41am UTC](https://community.stardog.com/t/a-sparql-query-that-runs-with-fuseki-but-not-with-stardog-what-am-i-doing-wrong/3248 "2021-09-08T09:41:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gcoskun](https://avatars.discourse-cdn.com/v4/letter/g/a587f6/32.png) [@gcoskun](https://community.stardog.com/u/gcoskun)\
**Post date:** [September 8, 2021, 9:41am UTC](https://community.stardog.com/t/a-sparql-query-that-runs-with-fuseki-but-not-with-stardog-what-am-i-doing-wrong/3248/1 "2021-09-08T09:41:13Z")

</div>

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

```auto
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
  } 
  WHERE {
    {
    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> {
      ?triplestroreSystem 
          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
        }
  }
  }
  }
  UNION {
    graph <https://pid.bayer.com/kge/virtualGraphs> {
     ?vg kge:belongsToDB <https://pid.bayer.com/kge/CwidDB>;
          kge:vGraphName ?g
    }
    }
  }

```

**here is the error message**

```auto
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 {
Projection(?g)
`\u2500 {
   `\u2500 Scan[SPO](?s, ?p, ?o){?g, Named}
   }
}

```

**Any idea what I can do?**

---

<div class="post-metadata">

**Author:** ![pavel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pavel/32/18_2.png) [@pavel](https://community.stardog.com/u/pavel)\
**Post date:** [September 8, 2021, 10:46am UTC](https://community.stardog.com/t/a-sparql-query-that-runs-with-fuseki-but-not-with-stardog-what-am-i-doing-wrong/3248/2 "2021-09-08T10:46:39Z")

</div>

Hi,

Could you try to change this line:

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

```

to

```auto
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,  
Pavel

---

<div class="post-metadata">

**Author:** ![gcoskun](https://avatars.discourse-cdn.com/v4/letter/g/a587f6/32.png) [@gcoskun](https://community.stardog.com/u/gcoskun)\
**Post date:** [September 8, 2021, 11:45am UTC](https://community.stardog.com/t/a-sparql-query-that-runs-with-fuseki-but-not-with-stardog-what-am-i-doing-wrong/3248/3 "2021-09-08T11:45:32Z")

</div>

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.  
Thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [September 22, 2021, 11:45am UTC](https://community.stardog.com/t/a-sparql-query-that-runs-with-fuseki-but-not-with-stardog-what-am-i-doing-wrong/3248/4 "2021-09-22T11:45:37Z")

</div>

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