W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > October to December 2009

Re: HAVING vs. FILTER

From: Andy Seaborne <andy.seaborne@talis.com>
Date: Fri, 13 Nov 2009 17:15:58 +0000
Message-ID: <4AFD944E.1070708@talis.com>
To: Steve Harris <steve.harris@garlik.com>
CC: Axel Polleres <axel.polleres@deri.org>, Lee Feigenbaum <lee@thefigtrees.net>, RDF Data Access Working Group <public-rdf-dawg@w3.org>


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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:40 GMT