CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 17:44:49 GMT
content-type: text/html
content-encoding: gzip
last-modified: Thu, 13 Jul 2023 17:27:30 GMT
cache-control: max-age=2592000, public
expires: Mon, 10 Nov 2025 17:44:49 GMT
vary: Accept-Encoding
access-control-allow-origin: *
x-request-id: 98d02ae7d9f8f313
strict-transport-security: max-age=15552015; preload
x-frame-options: deny
x-xss-protection: 1; mode=block
cf-cache-status: EXPIRED
set-cookie: __cf_bm=zYT.ZDMnPOphtVnaeAFzuHIsJ7uRtyZyCM7lH3bOSvk-1760204689-1.0.1.1-zYQQRA9rbxYfb93YKN710CdjY1KhziCUT5B.8YrK9umwZ7Eadmh_NWMPill2qWmdlSULZ5ispPXdmI5za_Wb6P.MvVH7DT8C5I5gHtB_850; path=/; expires=Sat, 11-Oct-25 18:14:49 GMT; domain=.w3.org; HttpOnly; Secure; SameSite=None
server: cloudflare
cf-ray: 98d02ae7d9f8f313-BLR
alt-svc: h3=":443"; ma=86400
Undefined results order with Order By/Projection/Distinct from Pavel Klinov on 2022-10-07 (public-sparql-dev@w3.org from October to December 2022)
Undefined results order with Order By/Projection/Distinct
- From: Pavel Klinov <pavel.klinov@gmail.com>
- Date: Fri, 7 Oct 2022 16:38:35 +0200
- To: public-sparql-dev@w3.org
- Message-ID: <CAG5JQxV9b1EO1iDgOA-Jn_LKgqsujhh81S4NvncgXdLUFbtWQw@mail.gmail.com>
Hi all, Sorry if this is known but was a little surprise to me. Even though both Projection and Distinct solution modifiers are required to preserve the order of solutions imposed by Order By (see 18.5), one can construct an example where the final query results would be undefined: SELECT DISTINCT ?a { VALUES (?a ?b) { (1 1) (1 2) (2 3) (1 4) (2 5) } } ORDER BY DESC(?b) Solution modifiers are applied in the order of: Order By -> Projection -> Distinct (15). So after the projection, the solution sequence is: ?a -> 2, ?a -> 1, ?a -> 2, ?a -> 1, ?a -> 1. Now, the Distinct is only required to keep this order but it's free to remove any of the duplicate ?a -> 2 or ?a -> 1 solutions. So the final results could be either ?a -> 2, ?a -> 1 or ?a -> 1, ?a -> 2. Note that both solution sequences preserve the Order By order! It's easy to make an extended example with LIMIT where the results could be completely different based on how Distinct eliminates duplicates. Given the role preservation requirement one can argue that Distinct should always keep the first occurrence of each duplicate in the input, but I don't think it's in the spec. Am I missing something? Pavel
Received on Friday, 7 October 2022 14:40:21 UTC