- From: <bugzilla@wiggum.w3.org>
- Date: Mon, 09 May 2005 22:01:55 +0000
- To: public-qt-comments@w3.org
- Cc:
http://www.w3.org/Bugs/Public/show_bug.cgi?id=1314 Summary: fn:distinct-values should not accept incomparable types Product: XPath / XQuery / XSLT Version: Last Call drafts Platform: PC OS/Version: Windows XP Status: NEW Severity: normal Priority: P2 Component: Functions and Operators AssignedTo: ashok.malhotra@oracle.com ReportedBy: chamberl@almaden.ibm.com QAContact: public-qt-comments@w3.org The fn:distinct-values function (Section 15.1.6) eliminates duplicates from an atomized sequence, based on comparing values by the "eq" operator. However, it says "Values that cannot be compared, i.e. the eq operator is not defined for their types, are considered to be distinct." This is problematic for the following reasons: (1) If incomparable values were actually compared by the "eq" operator, an error would result (for example, 7 eq "7" raises error XPTY0004.) (2) An "order by" clause also raises an error (XPTY0004) if it encounters incomparable sort keys. (3) The aggregation functions fn:avg, fn:min, fn:max, and fn:sum also raise an error (FORG0006) if they encounter incomparable sort keys. (4) Implementations of fn:distinct-values based on sorting or hashing are not possible under the current definition because they do not accept heterogeneous input sequences. In summary, the current specification of fn:distinct-values is inconsistent with the rest of the language and difficult to implement efficiently. The definition of fn:distinct-values should be made consistent with other functions and operators by raising an error if incomparable values are encountered. This will allow "order by" and fn:distinct-values to share a common efficient implementation. Proposal: In the definition of fn:distinct-values, replace the second sentence with the following: "If the input sequence contains any two values for which the eq operator is not defined, a type error is raised [err:FORG0006]." Also add an example: fn:distinct-values(1, 2.3, "Hello") raises err:FORG0006.
Received on Monday, 9 May 2005 22:02:09 UTC