Re: HAVING vs. FILTER

On 13/11/2009 15:53, Steve Harris wrote:
> On 13 Nov 2009, at 11:53, Andy Seaborne wrote:
>> On 13/11/2009 07:18, Axel Polleres wrote:
>>> One concern raised was IIRC why we need both if HAVING is anyway
>>> redundant by:
>>>
>>> SELECT AGG(?X)
>>> WHERE P
>>> GROUP BY G
>>> HAVING R
>>>
>>> being equivalent to
>>>
>>> { SELECT AGG(?X)
>>> WHERE P
>>> GROUP BY G }
>>> FILTER R
>>
>> Can R be (count(*)>0) ?
>
> That's a good point, but the {}s aren't strictly necessary:
>
> SELECT AGG(?X)
> WHERE P
> GROUP BY G
> FILTER R
>
> is still unambiguous, as a scalar FILTER would be illegal there, but it
> makes me much less keen on using one keyword.

It's not ambiguous - the two cases are different though.

In the {} case, it's a scalar FILTER like a BGP block, (unfortunately, 
that's called a "group" in the grammar) so it's

{ {SELECT } FILTER R }
is
  filter(R, join( unit, { SELECT } ))

because the elements between {} are joined currently.

c.f.

{
   { SELECT ...  }
   ?x :p ?v . FILTER ...
}

It would be odd to allow COUNT in that FILTER IMHO.  Then consider an 
empty BGP.

c.f.
{
   { SELECT ...  }
   FILTER ... ?x :p ?v .
}

and in the non-{} case the FILTER is attached as a aggregate-aware 
FILTER (HAVING) to the GROUP.

Because HAVING covers all of FILTER\aggregates, the difference isn't 
very significant in outcome but the algebra formulations are not the same.

>
> Consider that a +0.5 to HAVING, -0.5 to FILTER. I still don't care that
> much :)

Ditto.

	Andy

>
> - Steve
>

Received on Friday, 13 November 2009 17:16:08 UTC