Opened 10 years ago

Closed 7 years ago

#601 closed defect (invalid)

Escaping logical ANDs chains when collections are involved

Reported by: Piero Campalani Owned by: Dimitar Misev
Priority: minor Milestone: Future
Component: qlparser Version: development
Keywords: and chain collection escape Cc:
Complexity: Hard

Description

When creating a logical chain and ANDs, RasQL evaluates 2nd (and further) logical conditions also if the first is false.

While with scalars it properly escapes the chain at the first false condition:

# [0 == 9999] && [ln(-1) == 0] :
$ rasql -q "select (((0)=(9999))and(((ln(-1))=(0)))) from eobstest AS c"  --out hex
  Result element 1: f

… it does not with marrays:

# WCPS
for c in (eobscov)
return encode (
  count(       c[t("1950-01-04")]  = -9999 and
     ln(3932 + c[t("1950-01-04")]) = 1 )
, "csv")

# -> RASQL
$ rasql -q "select csv(count_cells((((((c) [3,*:*,*:*])=(-9999)))and(((ln(((3932)+((c) [3,*:*,*:*]))))=(1)))))) from eobstest AS c" --out hex 
Executing retrieval query...rasdaman error 510: Execution error 510 in line 1, column 60, near token ln: The argument is outside the function domain.

Over cells which do satisfy the first condition, the argument of the logarithm in the second logical condition becomes >0, whereas the reported RasQL error is thrown because the condition is evaluated also for cells which do not satisfy the first condition (i.e. == -9999), and hence push down the argument of the logarithm below zero, so "outside the function domain".

Change History (4)

comment:1 by Dimitar Misev, 10 years ago

Owner: changed from Dimitar Misev to George Merticariu
Status: newassigned

comment:2 by Dimitar Misev, 10 years ago

Owner: changed from George Merticariu to Dimitar Misev

comment:3 by Dimitar Misev, 10 years ago

Component: undecidedqlparser
Priority: majorminor

So let's consider this query:

rasql -q 'select mr > 300 and ln(mr - 100) < 2 from mr'

mr > 300 produces a boolean array, where all cells greater than 300 are 1, and the rest are 0. In this case all cells are 0 in the result array.

The order of evaluation is

  1. mr > 300
  2. ln(mr - 100) < 2
  3. a and b

Piero is suggesting that c. should be embeded into the evaluation of b. This is an optimization issue which will be non-trivial to implement, and since it can be fixed with the switch statement I'll put it on low priority.

comment:4 by Dimitar Misev, 7 years ago

Resolution: invalid
Status: assignedclosed

Closing as invalid, as the request doesn't fit with how rasql works. AND, OR, etc. are induced on arrays, and we cannot make them in certain contexts to act as non-induced.

Note: See TracTickets for help on using tickets.