kasei / perlrdf

Deprecated in favor of the Attean package
26 stars 25 forks source link

Potential problem with GROUP BY in RDF::Query when using RDF::Trine::Store::Memory #151

Open minusdavid opened 7 years ago

minusdavid commented 7 years ago

Using RDF::Query, I have a SPARQL query that has a GROUP BY, but it doesn't seem to be working with RDF::Trine::Store::Memory.

Still need to investigate more...

minusdavid commented 7 years ago

In my logs I see:

SELECT ?subject WHERE { ?subject ?predicate ?object . FILTER NOT EXISTS { ?os ?op ?subject } } GROUP BY ?subject

Become:

using query plan: (project (subject) (filter (! ( (BGP (triple ?os ?op ?subject)

kasei commented 7 years ago

You're on a roll finding issues. Really sorry about that! This does seem like a big, but I'll mention that this is a strange query that might be more naturally expressed as "select distinct ?subject" without any grouping. That said, using grouping without any aggregate functions like SUM should still work and I'll try to get a fix for that.

minusdavid commented 7 years ago

I'm nearly finished with my RDF code, so I probably won't be finding many more soon!

Great suggestion. I changed it to use 'select distinct' instead and that works a treat. Sounds good about getting a fix out though. I always use 'GROUP BY' with SQL rather than 'DISTINCT', so I hadn't even thought to use it here with SPARQL.