# QueryEval: Logical service query cannot be evaluated

**URL:** <https://community.stardog.com/t/queryeval-logical-service-query-cannot-be-evaluated/2129>\
**Category:** Support\
**Created:** [December 3, 2019, 6:38pm UTC](https://community.stardog.com/t/queryeval-logical-service-query-cannot-be-evaluated/2129 "2019-12-03T18:38:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![s5uybw](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@s5uybw](https://community.stardog.com/u/s5uybw)\
**Post date:** [December 3, 2019, 6:38pm UTC](https://community.stardog.com/t/queryeval-logical-service-query-cannot-be-evaluated/2129/1 "2019-12-03T18:38:50Z")

</div>

Hi, I got exception error thrown out as  
QueryEval: Logical service query cannot be evaluated  
when I am trying to query from virtual graph and join with another sparql endpoint using service.  
Is this type of query not supported by Stardog?  
Query:

```auto
SELECT ?child ?name ?lei ?country ?city ?street ?type ?ultiparent
{
   graph <virtual://db1> {
      ?ultiparent ^relationship:UltimateParent ?child;
          party:hasName "Everest Re Group, Ltd." .
     ?child party:hasName ?name .
     ?child ^relationship:hasChild ?Relation.
     ?Relation relationship:hasParent ?directparent.
     ?directparent party:hasName ?directparentname .
     ?Relation a ?type.
   optional {
      {
        ?child owl:sameAs ?lei.
            {
                SERVICE <https://lei.info/sparql> {
                    GRAPH ?g {
 
                         ?lei voc-l1:legalName ?legalName .
                         ?lei voc-l1:legalAddress ?legalAddress .
                         ?legalAddress voc-l1:country ?country . 
                         ?legalAddress voc-l1:city ?city .
                         ?legalAddress voc-l1:streetAddress ?street .
                         ?legalAddress voc-l1:postalCode ?postalCode .
                    }
                 }
             }
         }  
      }  
    }
}

```

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [December 6, 2019, 6:18pm UTC](https://community.stardog.com/t/queryeval-logical-service-query-cannot-be-evaluated/2129/2 "2019-12-06T18:18:10Z")

</div>

Hi Vivian,

Stardog does not support a `SERVICE` block inside a virtual graph block. Is the `owl:sameAs` coming from the virtual graph? You will have to move that pattern to a separate block to join in an OPTIONAL, eg:

```auto
graph <virtual://...> {
   ?child ..
}
OPTIONAL {
  graph <virtual://...> { 
    ?child owl:sameAs ?lei
  }
  service <...> { 
    ?lei ...
  }
}

```

Jess

---

<div class="post-metadata">

**Author:** ![s5uybw](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@s5uybw](https://community.stardog.com/u/s5uybw)\
**Post date:** [December 7, 2019, 2:23am UTC](https://community.stardog.com/t/queryeval-logical-service-query-cannot-be-evaluated/2129/3 "2019-12-07T02:23:07Z")

</div>

Jess, thanks. I put the service to a separate block, this time no error, but no return result. I did a quick test trying to isolate the problem.

1. Create a db using studio with all default setting.

2. Insert 1 triple for lei id.

```auto
@prefix lei-info: <http://lei.info/> .
@prefix party: <http://example.com/data/> .

party:12345 owl:sameAs lei-info:549300N24XF2VV0B3570 .

```

1. Run following query, return the result

```auto
prefix lei-info: <http://lei.info/> 
PREFIX voc-l1: <http://lei.info/voc/l1/>
PREFIX voc-l2: <http://lei.info/voc/l2/>
prefix party: <http://example.com/data/> 

SELECT ?party ?lei ?country ?city ?street 
{  
      party:12345 owl:sameAs ?lei. 
     { SERVICE <https://lei.info/sparql> {
                    GRAPH ?g {
                         ?lei voc-l1:legalName ?legalName .
                         ?lei voc-l1:legalAddress ?legalAddress .
                         ?legalAddress voc-l1:country ?country . 
                         ?legalAddress voc-l1:city ?city .
                         ?legalAddress voc-l1:streetAddress ?street .
                         ?legalAddress voc-l1:postalCode ?postalCode .
                    }
                 }
             }
         }  

```

1. Run the same query #3 again. The query hung and return with error: 000012: org.apache.http.client.ClientProtocolException

Do you see this kind of issues? what could cause? It can be duplicated.

---

<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:** [December 21, 2019, 2:23am UTC](https://community.stardog.com/t/queryeval-logical-service-query-cannot-be-evaluated/2129/4 "2019-12-21T02:23:07Z")

</div>

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