db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Manish Khettry" <manish.khet...@gmail.com>
Subject Re: Functions in GROUP BY expressions? (related to DERBY-883)
Date Wed, 15 Nov 2006 18:47:07 GMT
Actually, when I was implementing this functionality I thought that
comparing java nodes for equivalence was not possible or perhaps hard to do.
I could be wrong on this, so someone who knows this stuff better can comment
on this.

At any rate, I find it strange that one of these query works but not the
other. I think right now as things stand, both should fail. If there is
consensus that we should allow java value nodes in group by expressions,
then we should add isEquivalence methods to all the JavaValueNodes.

m


On 11/15/06, Oystein Grovlen - Sun Norway <Oystein.Grovlen@sun.com> wrote:
>
> Manish Khettry wrote:
> > Hmm strange. I am not sure why this
> >
> >    select avg(i) from t group by sin(i)
> >
> > works but not this,
> >
> >   select avg(i), sin(i) from test group by sin(i);
> >
> > I think its a bug-- both should be disallowed.
>
> Why should they be disallowed?  I agree that in most cases grouping by
> non-deterministic functions do not make sense, but I am not sure that
> is a reason for disallowing it.  Also, a function that is generally
> non-deterministic may be deterministic in a given context.
>
> Theoretically, I do not see why equivalence and non-deterministic
> functions are an issue for GROUP BY.  I do not think an implementation
> need to execute the function twice if it appears both in the group-by
> clause and in the select list.  The value returned when determining
> group could be used for the select list also.
>
> --
> Øystein
>

Mime
View raw message