Problem with most aggregate operators
Posted: Fri Feb 25, 2011 5:16 pm
In the original version of Tutorial D, the syntax for most aggregate operator invocations was <agg op name> ( <rel exp>, <attribute name> ), but eventually we generalized it to allow any expression (usually an open one) in place of <attribute name>.
The expression SUM(r, a + 1), where a is a numerical attribute of relation r, is accepted by Rel and computes correctly. However, AND(r, a > 1), for example, is not accepted, Rel saying that it expects ")" where it encountered ">". A similar comment applies to most aggregate operators, possibly all of them apart from SUM. I mentioned AND first because with AND one nearly always wants to write an expression using comparison operators and possibly logical connectives as the second operand.
Of course, one can get around the problem by writing an EXTEND invocation as the first operand, but that was always the case and the purpose of generalizing the second operand was to address that slight inconvenience.
Hugh Darwen
The expression SUM(r, a + 1), where a is a numerical attribute of relation r, is accepted by Rel and computes correctly. However, AND(r, a > 1), for example, is not accepted, Rel saying that it expects ")" where it encountered ">". A similar comment applies to most aggregate operators, possibly all of them apart from SUM. I mentioned AND first because with AND one nearly always wants to write an expression using comparison operators and possibly logical connectives as the second operand.
Of course, one can get around the problem by writing an EXTEND invocation as the first operand, but that was always the case and the purpose of generalizing the second operand was to address that slight inconvenience.
Hugh Darwen