Sparql: COUNT(DISTINCT *) returns wrong result

Hi there,
I encountered an issue were COUNT(DISTINCT *) returns always '1' when there is only one variable in scope. Feels like a bug to me.

Stardog Version: 8.0.0

To reproduce:

  1. Load Dataset [1]
  2. Execute Query: select (count (distinct *) as ?cnt) { ?x a :A }

OUTCOME: The query returns 1
EXPECTED: The query should return 2

Sidenotes:

  1. When I explicitly count the variable '?x' I get the desired result. Query: select (count (distinct ?x) as ?cnt) { ?x a :A } -> returns 2
  2. I tested the queries with another system and it returned my expected result.

[1]: Example Dataset

PREFIX    : <http://www.test.de/count#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

:A a owl:Class .

:i a :A .
:j a :A .

Thanks for the perfect bug report. I have created PLAT-4593. We will attempt to get a fix for this in the upcoming 8.0.1 release.

The only workaround I can think of in the meantime (except of using ?x, as you found) is to add memory.management=jvm to stardog.properties). Note that it will make Stardog manage intermediate query results on Java heap so one should be aware of possible OOMs on complex queries.

Thanks again,
Pavel

That's great to hear.

Thank you.