BIND syntax

50 views
Skip to first unread message

Robert Syme

unread,
May 15, 2012, 9:18:48 AM5/15/12
to 4store-...@googlegroups.com
Not the segfaults I promised, but some behaviour that I was not expecting. This might just a SPARQL misunderstanding on my part, but I thought I'd post it here just in case it's not what we would expect.

sudo 4s-backend-setup test
sudo 4s-backend test
sudo 4s-import test.rdf
4s-query demo -f tsv "PREFIX eg: <http://example.org/>
SELECT * WHERE {
  ?gene eg:start ?start .
  ?gene eg:stop ?stop
  BIND(?stop - ?start AS ?length)
}" | column -t

I was hoping that ?length would be evaluated for each solution to the query, but instead ?length is bound to the first solution (120) for all three genes:
?gene                         ?start  ?stop  ?length
<http://example.org/gene_01>  300     420    120
<http://example.org/gene_00>  100     200    120
<http://example.org/gene_02>  150     180    120

Is this the expected result?

Steve Harris

unread,
May 15, 2012, 9:59:09 AM5/15/12
to 4store-...@googlegroups.com
Nope, that's a bug.

There's a test for this case though - does the bind test pass for you? cd tests/httpd ; ./run.pl bind

One thing of note is that you use two different KB in your test below (test and demo) but the result is still wrong.

- Steve

--
You received this message because you are subscribed to the Google Groups "4store-support" group.
To view this discussion on the web visit https://groups.google.com/d/msg/4store-support/-/OOXy7_XOnBkJ.
To post to this group, send email to 4store-...@googlegroups.com.
To unsubscribe from this group, send email to 4store-suppor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/4store-support?hl=en.

-- 
Steve Harris, CTO
Garlik, a part of Experian 
1-3 Halford Road, Richmond, TW10 6AW, UK
+44 20 8439 8203  http://www.garlik.com/
Registered in England and Wales 653331 VAT # 887 1335 93
Registered office: Landmark House, Experian Way, NG2 Business Park, Nottingham, Nottinghamshire, England NG80 1ZZ

Rob Syme

unread,
May 16, 2012, 2:56:17 AM5/16/12
to 4store-...@googlegroups.com
All tests pass:

Just bind:
$ sudo ./run.pl bind
4store[2411]: backend-setup.c:186 erased files for KB http_test_root
4store[2411]: backend-setup.c:318 created RDF metadata for KB http_test_root
../../src/http/4s-httpd -c ../tests_4store.conf -X -D -p 13579 http_test_root
4s-httpd running on PID 2416
[PASS] bind
Tests completed: passed 1/1 (0 fails)

`sudo make test` from the 4store repo root also looks clean.

I've had a look through some of httpd/scripts and I didn't see a test that uses the arithmetic supported by sparql (+ - / * etc). Perhaps the subtraction inside bind is my issue? This is some pretty wild speculation on my part though. I just wish my C was better so I could help.
-r

Robert Syme

unread,
May 16, 2012, 10:45:05 PM5/16/12
to 4store-...@googlegroups.com
Also, the KB mixup was just a copy/paste error on my part. The tenacious ?length binding persists without the typo.

Also, when 4store doesn't seem to like it when it is forced to cast an http://www.w3.org/2001/XMLSchema#integer into something else. Using the same test dataset from before, division of an integer returns a variable with datatype "¡resource e73e2da015326373 not found!". See below.

I'm submitting unexpected results not because I demand they be fixed, but rather to try and expand the test suite. I hope they help. Would you prefer I submit them to the githup repo as "Issues" to keep the mailing list clean?

$ 4s-query test "SELECT * WHERE {?gene <http://example.org/start> ?start BIND(?start / 2 AS ?bound)}"
<?xml version="1.0"?>
  <head>
    <variable name="gene"/>
    <variable name="start"/>
    <variable name="bound"/>
  </head>
  <results>
    <result>
      <binding name="gene"><uri>http://example.org/gene_00</uri></binding>
      <binding name="start"><literal datatype="http://www.w3.org/2001/XMLSchema#integer">100</literal></binding>
      <binding name="bound"><literal datatype="¡resource e73e2da015326373 not found!">49.99999999999999999</literal></binding>
    </result>
    <result>
      <binding name="gene"><uri>http://example.org/gene_01</uri></binding>
      <binding name="start"><literal datatype="http://www.w3.org/2001/XMLSchema#integer">300</literal></binding>
      <binding name="bound"><literal datatype="¡resource e73e2da015326373 not found!">49.99999999999999999</literal></binding>
    </result>
    <result>
      <binding name="gene"><uri>http://example.org/gene_02</uri></binding>
      <binding name="start"><literal datatype="http://www.w3.org/2001/XMLSchema#integer">150</literal></binding>
      <binding name="bound"><literal datatype="¡resource e73e2da015326373 not found!">49.99999999999999999</literal></binding>
    </result>
  </results>
</sparql>

-r
To post to this group, send email to 4store-support@googlegroups.com.
To unsubscribe from this group, send email to 4store-support+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/4store-support?hl=en.
-- 
Steve Harris, CTO
Garlik, a part of Experian 
1-3 Halford Road, Richmond, TW10 6AW, UK
+44 20 8439 8203  http://www.garlik.com/
Registered in England and Wales 653331 VAT # 887 1335 93
Registered office: Landmark House, Experian Way, NG2 Business Park, Nottingham, Nottinghamshire, England NG80 1ZZ

--
You received this message because you are subscribed to the Google Groups "4store-support" group.
To post to this group, send email to 4store-support@googlegroups.com.
To unsubscribe from this group, send email to 4store-support+unsubscribe@googlegroups.com.

Steve Harris

unread,
May 17, 2012, 5:42:24 AM5/17/12
to 4store-...@googlegroups.com, 4store-...@googlegroups.com
Yeah, I managed to reproduce the sticky value bug yesterday afternoon, but I'm in the hospital today and can't work on it for a few days. Oddly it seemed to only happen with minus, things like STR() and CONCAT() seemed to work. Possibly other mathematical operators have the same problem I  don't think there's anything special about minus. 

The division case is interesting, that was one of the hard challenges in implementing BIND in 4store, must have slipped through the net somehow. 

Sent on the move.
To view this discussion on the web visit https://groups.google.com/d/msg/4store-support/-/d_KqBLR9rJAJ.
To post to this group, send email to 4store-...@googlegroups.com.
To unsubscribe from this group, send email to 4store-suppor...@googlegroups.com.

Rob Syme

unread,
May 17, 2012, 5:44:32 AM5/17/12
to 4store-...@googlegroups.com
No worries. Get well soon!
-r

Steve Harris

unread,
May 25, 2012, 6:43:42 AM5/25/12
to 4store-...@googlegroups.com
This is now fixed in Git HEAD

- Steve

To view this discussion on the web visit https://groups.google.com/d/msg/4store-support/-/d_KqBLR9rJAJ.
To post to this group, send email to 4store-...@googlegroups.com.
To unsubscribe from this group, send email to 4store-suppor...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/4store-support?hl=en.
-- 
Steve Harris, CTO
Garlik, a part of Experian
1-3 Halford Road, Richmond, TW10 6AW, UK
Registered in England and Wales 653331 VAT # 887 1335 93
Registered office: Landmark House, Experian Way, Nottingham, Notts, NG80 1ZZ

Rob Syme

unread,
May 25, 2012, 9:05:10 AM5/25/12
to 4store-...@googlegroups.com

Thanks Steve!
-r

Reply all
Reply to author
Forward
0 new messages