ruby-rdf / sparql

Ruby SPARQL library
http://rubygems.org/gems/sparql
The Unlicense
88 stars 14 forks source link

Exception while parsing a query with path expression #25

Closed lks128 closed 7 years ago

lks128 commented 7 years ago

Hello, I'm having a bad luck parsing a query with path expression. The query works just fine in Protege 5.1.0.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

SELECT ?class (group_concat(DISTINCT ?item;separator=",") as ?keys) WHERE {
  ?class rdf:type owl:Class .
  ?class owl:hasKey ?key .
  ?key rdf:rest*/rdf:first ?item .
}
GROUP BY ?class ?key

STDERR output: https://gist.github.com/b36694c3a1577944acbecad4262deef9 bundle output: https://gist.github.com/anonymous/d83b285d1e77b830f0b0436ef19d400e Ruby version: ruby 2.2.6p396 (2016-11-15 revision 56800) [x86_64-linux]

gkellogg commented 7 years ago

@lks128 I believe I've fixed this in the branch, if you'd like to check it out. The generated SSE is now:

(project
  (?class ?keys)
  (extend ((?keys ?.0))
    (group (?class ?key)
      ((?.0 (group_concat (separator ",") distinct ?item)))
      (join
        (bgp (triple ?class <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class>))
        (join
          (bgp (triple ?class <http://www.w3.org/2002/07/owl#hasKey> ?key))
          (path ?key
            (seq
              (path* <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>)
              <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
            )
            ?item))))))
lks128 commented 7 years ago

@gkellogg It is awesome, thank you very much! I hope I will have time to try it out this week ;-)