SAG-FO-05: aggregate functions

This point has been made elsewhere, but we wish to emphasize it, as it seems
to be a serious design flaw.

The polymorphic nature of the aggregation functions, such as min/max/avg,
has not been thought through carefully enough.

It is important that these functions should be capable of a streamed
implementation. This means that if the first 999 values in a sequence are
untyped atomic, the choice of comparison or addition operator should not
depend on the type of the 1000th item. (Note that "order by" in XQuery has
this right: untyped atomic values are treated as strings, irrespective of
the types of the other items in the sequence). 

These functions (in particular sum) also have a problem in how they handle
the empty sequence. Because an empty set of doubles is not dynamically
distinguishable from an empty set of durations, sum() applied to the latter
returns the double value 0.0e0, which is in conflict with static typing
expectations. The only solution to this problem seems to be to stop
overloading the sum() function to handle durations (as proposed in
SAG-FO-02).

Michael Kay
Software AG

Received on Tuesday, 10 June 2003 11:49:47 UTC