Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Faulty response to certain queries combining DISTINCT and VALUES keywords #250

Description

@simonrihm

There seems to be a bug when parsing queries of the form

SELECT DISTINCT ?object WHERE { VALUES ?subject { <s1> <s2> } ?subject <predicate> ?object .

Instead of returning all distinct objects related to the two given subject instances by the predicate, it returns all instances of the subjects type. This only happens when the following conditions are met:
a) Only the object is selected with DISTINCT keyword.
b) More than one instances are bound to the subject variable via VALUES keyword.
c) Only one s-p-o statement is given as context.

Workarounds I have found so far:

  1. Do not use DISTINCT keyword, instead add GROUP BY ?object at the end of the query
  2. Add a random second statement to the query that does not affect the results, e.g. ?x ?y ?z .

You can reproduce this bug for example in Wikidata:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions