Hi Gokhan

Gokhan Soydan wrote:
> Hello,
> 
> Using a BIND in a nested graph pattern (a basic, OPTIONAL or UNION
> pattern) with an input argument that was assigned in the parent graph
> pattern doesn't work. The following example query returns no value for
> ?x, whereas it should return the value of ?s assigned to ?x
> 
> SELECT ?x
> WHERE {
>     ?s ?p ?o
>     {
>         BIND( ?s AS ?x )
>     }
> }
> 
> 
> This is the case both in ARQ 2.8.1 and ARQ 2.8.7.

The latest stable release of ARQ is 2.8.8:
http://repo1.maven.org/maven2/com/hp/hpl/jena/arq/2.8.8/

Have you tried using the latest stable release?

There is also a SNAPSHOT on the Apache Maven repository:
https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-arq/2.8.9-incubating-SNAPSHOT/

Have you tried testing this SNAPSHOT as well?

I tried using:
ARQ 2.8.9-incubating-SNAPSHOT (the new Apache SNAPSHOT) and ARQ 2.8.9-SNAPSHOT 
(the old SNAPSHOT).

The both have the behavior you described, some results are there (i.e. the 
correct number)
but it seems the variable ?x is not bound to the value of ?s.

-----
| x |
=====
|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |
-----

I suspected a bug, but I wanted to double check.
So, I went to check the SPARQL 1.1 Query Language spec:
http://www.w3.org/TR/sparql11-query/#bind

It says:

  "Use of BIND is a separate element of a group graph pattern and it ends any 
basic graph pattern."

So, I tried this instead:
SELECT ?x { ?s ?p ?o  BIND ( ?s AS ?x )  }

Bingo! I got my results:

-----------------------------------
| x                               |
===================================
| <http://example.org/book/book1> |
| <http://example.org/book/book1> |
| <http://example.org/book/book2> |
| <http://example.org/book/book2> |
| _:b0                            |
| _:b0                            |
| <http://example.org/book/book3> |
| <http://example.org/book/book3> |
| <http://example.org/book/book4> |
| <http://example.org/book/book5> |
| <http://example.org/book/book5> |
| <http://example.org/book/book6> |
| <http://example.org/book/book6> |
| <http://example.org/book/book7> |
| <http://example.org/book/book7> |
| _:b1                            |
| _:b1                            |
-----------------------------------


I hope it helps,
Paolo

> 
> Thanks,
> Gokhan

Reply via email to