Can I generated a uuid for each group in group by query

17 views
Skip to first unread message

Peter Neorr

unread,
Jul 27, 2016, 12:58:09 AM7/27/16
to Stardog
Hi All,

I could have sworn that I've done this before, but today I'm getting the following error:
"Non-group key variable in SELECT expression: Var(4)"

I'm trying to create a query that will give me count of employees on each team on any given day and also create a uuid for each day/team/count group.  Here's my query:

select ?date ?team (count(?team) as ?count) (uuid() as ?uid)
    where      
      {       
        graph ?r{
          ?r <tag:cert#recordDate> ?date .
          ?r <tag:cert#team> ?team .
          #?r <tag:cert#team> "24 - SystemsEngineering" .
         ?r a <tag:cert#LDAPRecord>          
        }
      }
    group by ?date ?team 
order by ?date ?team

Any tips?  (sample data attached)

Thanks!

-Peter Neorr
 
sampledata.zip

Pavel Klinov

unread,
Jul 27, 2016, 3:28:57 AM7/27/16
to sta...@clarkparsia.com
Hi Peter,

You're right, as per 11.4 of the spec variable-free expressions are allowed in projections with GROUP BY. This is a limitation of our new SPARQL parser and we will fix it.

Meanwhile you can do something like this:

select ?date ?team (uuid() as ?uid) ?count where {
{
select ?date ?team (count(?team) as ?count)
    where      
      {       
        graph ?r{
          ?r <tag:cert#recordDate> ?date .
          ?r <tag:cert#team> ?team .
          #?r <tag:cert#team> "24 - SystemsEngineering" .
         ?r a <tag:cert#LDAPRecord>          
        }
      }
    group by ?date ?team 
}
}
order by ?date ?team

Cheers,
Pavel

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Peter Neorr

unread,
Jul 28, 2016, 11:02:37 AM7/28/16
to sta...@clarkparsia.com
Thank you the reply Pavel.

I must be getting better at SPARQL because that's the exact same solution that I eventually arrived at.  :)

-Peter 

---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.
Reply all
Reply to author
Forward
0 new messages