Closed mwkuster closed 11 years ago
Version of the libraries used: sparql (1.0.7) sparql-client (1.0.1) (the latest one available via Ruby-Gem).
Congratulations for finding a corner case not present in the test cases. Complex as it is, everything in here should be supported. I'll try to simplify this to get at the root problem.
Promise, didn't do it on purpose :-)
Please le me know if I can be of any assistance
It ended up being fairly straightforward (presuming that the query actually does what you want). CONCAT was defined to take just two arguments, not a variable number of arguments. Simple update to use Enumerable#inject to get results.
Thanks a lot! Technically it works now (I've just locally replaced in the Gem concat.rb) with the new version
However, the end result is very different from the one using ARQ (Jena version 2.10.0) on the same query, and I would like to think that ARQ's results are the good ones:
Source: https://github.com/mwkuster/eli-budabe/blob/master/sparql/source.ttl
ARQ's results: https://github.com/mwkuster/eli-budabe/blob/master/sparql/sparql_arq.ttl
The library's results: https://github.com/mwkuster/eli-budabe/blob/master/sparql/sparql_ruby.ttl
Query is unchanged: https://github.com/mwkuster/eli-budabe/blob/master/sparql/eli_md.rq
I new it wouldn't be that easy :(. I'll need to be sure I'm generating the same algebra; if so, I should also get the same results.
Just to alert you that I've committed a slightly modified version of the original query (strictly no impact on the results with ARQ and the library, though)
Sorry to slightly highjack this ticket for a related question, but is there a defined interface to register specific new custom extension functions? If so, must they also be derived from Operator with the Evaluatable mixin?
There isn't yet a way to define custom functions; if there were, it would be by extending evaluatable, as with others such functions. It would also need a way to register the classes, so they could be dispatched. I'd certainly consider submissions to handle this.
The current issue seems to relate to a difference in generating the algebra for the query; I'm tied up at the moment, but will get to it. It's also possible to directly execute an SSE query, which could be an alternative for you in the mean time.
OK, can have a go at the custom functions, probably not before the weekend though
@mwkuster, I found an error in how the algebra was being generated, which could have accounted for the differences in output you were seeing. Could you check your results again with the top of the master branch?
thanks, but unfortunately no luck yet (Gem updated based on git clone https://github.com/ruby-rdf/sparql.git, then gem1.9 build sparql.gemspec ):
irb(main):003:0> g = SPARQL.execute(e.legal_resource_query, e.repo)
NoMethodError: undefined method join' for nil:NilClass from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/iri.rb:34:in
apply'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/evaluatable.rb:16:in evaluate' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:40:in
block (2 levels) in execute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:38:in each' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:38:in
block in execute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:36:in each' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:36:in
execute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/join.rb:39:in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/left_join.rb:38:in
execute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:35:in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/construct.rb:41:in
execute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/prefix.rb:30:in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql.rb:85:in
execute'
from (irb):3
from /opt/local/bin/irb1.9:12:in `
That problem was due to running the query without a base URI; I corrected this in fc13d9e2cc444ae18c6460adb6f066d78b5c851c. Can you verify that you have that version, with the updated iri.rb?
I verified running your example with https://github.com/ruby-rdf/sparql/blob/master/examples/issue9.rb, but didn't exhaustively check the actual results; the algebra which is created now should be identical to that from ARQ.
Did another git pull and rebuilt the gem. However, get now another error (same query as before):
e.legal_resource_query: as before e.repo: Repository based on https://github.com/mwkuster/eli-budabe/blob/master/sparql/source.ttl
irb(main):003:0> g = SPARQL.execute(e.legal_resource_query, e.repo)
NoMethodError: undefined method execute' for #<Array:0x007fb2ce6df758> from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/extend.rb:35:in
execute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/project.rb:30:in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/distinct.rb:32:in
execute'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql/algebra/operator/prefix.rb:30:in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql.rb:85:in
execute'
from /Users/marcwilhelmkuster/sandbox/OP/eli-budabe/eli.rb:60:in eli' from /Users/marcwilhelmkuster/sandbox/OP/eli-budabe/eli.rb:76:in
legal_resource_query'
from (irb):3
from /opt/local/bin/irb1.9:12:in `
Sorry, wrong alarm. This is an entirely unrelated issue. Having tested the result with the new version I can confirm that everything looks great now. Thanks a lot!
However, the library does fail on a different query with said error message. Since it seems a different problem, I've opened a new ticket for it
Cool.
Executing a SPARQL 1.1 construct query gives a SPARQL::MalformedQuery: ArgumentError: wrong number of arguments exception
Query: https://github.com/mwkuster/eli-budabe/blob/master/sparql/eli_md.rq Sample data for the query: https://github.com/mwkuster/eli-budabe/tree/master/samples
The query executes correctly against ARQ and validates using http://www.sparql.org/query-validator.html
irb(main):011:0> g2 = SPARQL.execute(query, e.repo) SPARQL::MalformedQuery: ArgumentError: wrong number of arguments (5 for 3) at line 53, production = :BuiltInCall ArgumentError: wrong number of arguments (2 for 3) at line 53, production = :BuiltInCall ArgumentError: wrong number of arguments (0 for 1) at line 53, production = :BuiltInCall ArgumentError: wrong number of arguments (0 for 1) at line 53, production = :BuiltInCall NoMethodError: undefined method'
unshift' for nil:NilClass at line 53, production = :Bind from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql.rb:87:in
rescue in execute' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/sparql-1.0.7/lib/sparql.rb:66:inexecute' from (irb):11 from /opt/local/bin/irb1.9:12:in