Issues with tutorials in Stardog Studio

Hi,
recently I started experimenting with Stardog Studio.
I really liked how the tutorial creates new databases, so one can get started right away.
Yet, in my setup the default namespaces used in the tutorial and the default namespaces of the newly created DBs did not match.
Which is easy to fix, but I just wanted to point it out to you.

Also I ran in another issue. I cannot pin point if it is my mistake or a bug, but when doing the exercises (SPARQL 103: Additional Operations), I ran into a Nullpointer Exception.

com.complexible.stardog.plan.eval.operator.OperatorException: Uncaught error during query evaluation: NullPointerException:

This was caused by running this query:

SELECT ?year ?count 
{
    {
        SELECT ?year (COUNT(?album) AS ?count)
        { 
            ?album a :Album ;
                :date ?date .
            BIND(YEAR(?date) as ?year)
        }
        GROUP BY ?year
    }
    FILTER(avg(?count) < ?count)
}
ORDER BY ?count

However, if the calculated average is replaced with a previously calculated value (18.55) it works just fine. Is it not possible to calculate the average on the fly? Or did I really ran into some kind of bug?

Cheers
Chris

Hi Chris,

It's not that the average can't be calculated on the fly, it's that the variable ?count hasn't been assigned a value yet. Even though it was assigned a value in the subquery, the FILTER statement doesn't have access to that variable.

You can achieve what you want with this (admittedly unwieldy) rewrite:

SELECT ?year ?count 
{
  {
    SELECT (AVG(?count) as ?avgCount)
    {
      SELECT ?year (COUNT(?album) AS ?count)
      { 
        ?album a :Album ;
          :date ?date .
        BIND(YEAR(?date) as ?year)
      }
      GROUP BY ?year
    }
  }

  {
    SELECT ?year (COUNT(?album) AS ?count)
    { 
      ?album a :Album ;
        :date ?date .
      BIND(YEAR(?date) as ?year)
    }
    GROUP BY ?year
  }
  FILTER(?count > ?avgCount)
}
ORDER BY ?count

The first subquery gets the average count of albums, the second subquery gets the count of albums, and the FILTER statement compares the two to only return years with an above-average number of albums.

Let me know if you have any other questions.

Best,
Steve