Page 1 of 1

Problem with most aggregate operators

Posted: Fri Feb 25, 2011 5:16 pm
by HughDarwen
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

Re: Problem with most aggregate operators

Posted: Fri Feb 25, 2011 9:52 pm
by Dave
Oddly, the bug may be that SUM(r, a + 1) works! :shock:

I just tried it with SUM(sys.Catalog, CreationSequence + 1) and it threw an error message, which is what I'd expect.

The current (as of this writing) release of Rel is version 1.0.5. That version is based on the Tutorial D specification in "Databases, Types and the Relational Model", in particular the <agg op inv> term described in Chapter 5 under "SCALAR OPERATIONS" (page 103 in my copy). Version 1.0.5 does not yet support the generalized syntax for <agg op inv> as described in "Database Explorations - Essays on The Third Manifesto and Related Topics" in Chapter 11 under "SCALAR OPERATIONS" (page 139 in my copy).

Similarly, the use of colons and braces in UPDATE, EXTEND and SUMMARIZE are not yet supported, D_INSERT and I_DELETE do not yet exist, INT/RAT/BOOL do not exist, etc.

The Tutorial D described in "Database Explorations ..." is currently slated for implementation in a summer 2011 Rel update.

However, given that the new <agg op inv> should support all expressions written for the old <agg op inv>, there's no reason not to support the new <agg op inv>, even without the rest of the "Database Explorations ..." syntax being implemented. I'll see what I can do to produce an update with this one change well before summer, i.e., in a week or two. :)

Re: Problem with most aggregate operators

Posted: Sat Feb 26, 2011 1:32 am
by Dave
I've implemented the "Database Explorations ..." version of <agg op inv>, and it's available in version 1.0.6.

Re: Problem with most aggregate operators

Posted: Sat Feb 26, 2011 12:43 pm
by HughDarwen
Many thanks, Dave, and sorry for my mistake. I don't know, now, how I managed to convince myself that SUM supported expressions rather than just attribute names, but I tried exactly the same test today and it failed.

Hugh