Rdrg109 created this task.
Rdrg109 added a project: Wikidata-Query-Service.
Restricted Application added a subscriber: Aklapper.

TASK DESCRIPTION
  **The context**
  
  Before describing the issue, please let me present some context.
  
  Query 1: This query returns the highest point of Earth and Mars. I executed 
it and it returned 4 results in 110ms, also, all the returned values were 
unique. To me, this is expected behavior.
  
    SELECT ?value {
      VALUES ?item {wd:Q2 wd:Q111}.
      ?item wdt:P610 ?value.
    }
  
  Query 2: This query returns the distinct values of highest point of the item 
Earth. I executed it and it returned 3 results in 123ms. To me, this is 
expected behavior.
  
    SELECT DISTINCT ?value {
      VALUES ?item {wd:Q2}.
      ?item wdt:P610 ?value.
    }
  
  Query: 3: This query returns the distinct values of highest point of Earth 
and Mars. I executed it and it returned 11158 results in 197ms. To me, this is 
**NOT** expected behavior.
  
    SELECT DISTINCT ?value {
      VALUES ?item {wd:Q2 wd:Q111}.
      ?item wdt:P610 ?value.
    }
  
  Query 4: This query does the same of Query 3, but it is enclosed in a named 
subquery. I executed it and it returned 4 results in 133ms. To me, this is 
expected behavior.
  
    SELECT *
    WITH {
      SELECT DISTINCT ?value {
        VALUES ?item {wd:Q2 wd:Q111}.
        ?item wdt:P610 ?value.
      }
    } AS %0
    {
      INCLUDE %0.
    }
  
  I think Query 3 has a problem. I've described my reasoning below.
  
  **Steps to replicate the issue**
  
  1. Execute the following query (previously called Query 3) in WDQS.
  
    SELECT DISTINCT ?value {
      VALUES ?item {wd:Q2 wd:Q111}.
      ?item wdt:P610 ?value.
    }
  
  The query query returned 11158 (as of the time of this writing), even though 
the distinct values for highest point (P610 
<https://www.wikidata.org/wiki/Property:P610>) of Earth (Q2) and Mars (Q111) 
are only 4, as shown by Query 1 and Query 4.
  
  **What should have happened instead?**:
  
  The query should have returned 4 items, since the `DISTINCT` values for 
"Earth" (Q2) and "Mars" (Q111) are only 4 (this can be proved by executing 
Query 1 or Query 4).
  
  **Additional information**
  
  I think the bug is when using `DISTINCT` with `VALUES`.
  
  The following query gets the value of parent taxon (P171 
<https://www.wikidata.org/wiki/Property:P171>) of hippopotamus (Q34505) and 
tiger (Q19939). I executed it and it returned 2 results in 296ms.
  
    SELECT ?value {
      VALUES ?item {wd:Q34505 wd:Q19939}
      ?item wdt:P171 ?value.
    }
  
  I executed the query with `DISTINCT` (see below) and it timed out.
  
    SELECT DISTINCT ?value {
      VALUES ?item {wd:Q34505 wd:Q19939}
      ?item wdt:P171 ?value.
    }
  
  **Software version**
  
  WDQS as of the time of this writing.
  
  **Other information**
  
  Browser: Mozilla Firefox 106.0.1

TASK DETAIL
  https://phabricator.wikimedia.org/T321855

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Rdrg109
Cc: Aklapper, Rdrg109, AWesterinen, MPhamWMF, CBogen, Namenlos314, Gq86, 
Lucas_Werkmeister_WMDE, EBjune, merbst, Jonas, Xmlizer, jkroll, Wikidata-bugs, 
Jdouglas, aude, Tobias1984, Manybubbles
_______________________________________________
Wikidata-bugs mailing list -- wikidata-bugs@lists.wikimedia.org
To unsubscribe send an email to wikidata-bugs-le...@lists.wikimedia.org

Reply via email to