Re: [ACTION-18] use case on !ASK in FILTERS to emulate negation

On Tue, 2009-05-26 at 21:18 +0100, Axel Polleres wrote:
> Ivan Mikhailov wrote:
> > Hello Axel,
> > 
> >> aehm... you won. :-)
> >> It starts to look to me like that nesting in FILTERs doesn't really have 
> >> any advantages. Anybody arguments in favor of the FILTERed version?
> > 
> > I'd prefer to not rewrite at all a BI query like
> > 
> > select ?book ?p1 ?dp1 ?end1 where
> >   { ?offer1 :itm ?book ;
> >      :price ?p1 .
> >      OPTIONAL {
> >        ?offer1 :discountPrice ?dp1 ;
> >          :endDate ?end1 .
> >        filter ((?dp1/?p1 < 0.3) ||
> >          ASK { 
> >            ?offer2 :itm ?book ;
> >            :price ?p2 .
> >            OPTIONAL {
> >              ?offer2 :discountPrice ?dp2 ;
> >                :endDate ?end2 .
> >              filter (?end2 >= ?end1) }
> >            filter (?dp1/?p1 < ?dp2/?p2) } } ) } }
> 
> Let me try to phrase this query into "English"
> 
> Give me books and their list prices and optionally their disount prices 
> and the date the discount ends if either
>   - the discount price is less than a third of the list price, or
>   - there is a second offer for that book with a discount that ends
>     later, but with a worse ratio of price to discount price?
> 
> ... aehm, I assume there is a not missing in front of the ASK?
> (assuming because otherwise, it is not about Negation anyways, which we 
> started)

Hm, "!" is skipped, but the result is just another sample query, almost
as bad for debugging as the original :)

The key thing is that simplifying left outer join conditions is painful,
making language more expressive is better choice.

Other issue is that BI queries are frequently made in few iteration,
from simple versions to more detailed. It should be possible to extend
queries with arbitrary new conditions or data extractions without
rephrasing the whole query. So if developer begins with

select ?book ?p1 ?dp1 ?end1 where
  { ?offer1 :itm ?book ;
      :price ?p1 .
      OPTIONAL {
        ?offer1 :discountPrice ?dp1 ;
         :endDate ?end1 .
        filter (?dp1/?p1 < 0.3) } }

then it should be possible to add an OR operator with an argument instead of touching the existing code.


> So, do you mean:
> 
> Give me books and their list prices and optionally their disount prices 
> and the date the discount ends if either
>   - the discount price is less than a third of the list price, or
>   - there is no offer which ends later with a better price to
>     discount price ratio

Yes, sort of that. (Ratios in filters were specially for optimizers that
know Presburger arithmetic a little but panic when expression contains
any '/', to test how complicated queries run with warranty that the test
is not simplified before run.)

Received on Wednesday, 27 May 2009 06:11:28 UTC