Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#2273 closed defect (worksforme)

rasql - error with > operator in switch case

Reported by: Bang Pham Huu Owned by: apercov
Priority: major Milestone: 10.0
Component: server Version: 9.8
Keywords: Cc: Dimitar Misev, Vlad Merticariu
Complexity: Medium

Description

This query below works with 25 = ... on rgb collection

rasql -q 'SELECT ENCODE( ( Scale( ( ( case when 25 = ( extend(shift(project(c0, "6.92725,51.92725,7.838375,52.83837499999999", "EPSG:4326", "6.92725,51.92725,7.838375,52.838375", "EPSG:4326", 0.002, 0.002), [0,0]), [0:455,0:455]) )[53:402,53:402] then {255c, 255c, 255c} when 18 > ( extend(shift(project(c0, "6.92725,51.92725,7.838375,52.83837499999999", "EPSG:4326", "6.92725,51.92725,7.838375,52.838375", "EPSG:4326", 0.002, 0.002), [0,0]), [0:455,0:455]) )[53:402,53:402].1 then {0c, 0c, 255c} when 23 > ( extend(shift(project(c0, "6.92725,51.92725,7.838375,52.83837499999999", "EPSG:4326", "6.92725,51.92725,7.838375,52.838375", "EPSG:4326", 0.002, 0.002), [0,0]), [0:455,0:455]) )[53:402,53:402].2 then {255c, 255c, 0c} when 30 > ( extend(shift(project(c0, "6.92725,51.92725,7.838375,52.83837499999999", "EPSG:4326", "6.92725,51.92725,7.838375,52.838375", "EPSG:4326", 0.002, 0.002), [0,0]), [0:455,0:455]) )[53:402,53:402].0 then {255c, 140c, 0c} else {255c, 0c, 0c} end ) ), [0:255, 0:255] ) ) , "png", "{ \"nodata\" : [ 0 ] }") FROM test_rgb AS c0'

But this one with 25 > ... does not work

asql -q 'SELECT ENCODE( ( Scale( ( ( case when 25 > ( extend(shift(project(c0, "6.92725,51.92725,7.838375,52.83837499999999", "EPSG:4326", "6.92725,51.92725,7.838375,52.838375", "EPSG:4326", 0.002, 0.002), [0,0]), [0:455,0:455]) )[53:402,53:402] then {255c, 255c, 255c} when 18 > ( extend(shift(project(c0, "6.92725,51.92725,7.838375,52.83837499999999", "EPSG:4326", "6.92725,51.92725,7.838375,52.838375", "EPSG:4326", 0.002, 0.002), [0,0]), [0:455,0:455]) )[53:402,53:402].1 then {0c, 0c, 255c} when 23 > ( extend(shift(project(c0, "6.92725,51.92725,7.838375,52.83837499999999", "EPSG:4326", "6.92725,51.92725,7.838375,52.838375", "EPSG:4326", 0.002, 0.002), [0,0]), [0:455,0:455]) )[53:402,53:402].2 then {255c, 255c, 0c} when 30 > ( extend(shift(project(c0, "6.92725,51.92725,7.838375,52.83837499999999", "EPSG:4326", "6.92725,51.92725,7.838375,52.838375", "EPSG:4326", 0.002, 0.002), [0,0]), [0:455,0:455]) )[53:402,53:402].0 then {255c, 140c, 0c} else {255c, 0c, 0c} end ) ), [0:255, 0:255] ) ) , "png", "{ \"nodata\" : [ 0 ] }") FROM test_rgb AS c0'

with error

Executing retrieval query... rasdaman error 455: Execution error 455 in line 1, column 42, 
near token >: Operation not supported on operand of complex type.

Change History (5)

comment:1 by apercov, 4 years ago

Status: assignedaccepted

comment:2 by apercov, 4 years ago

This is the expected behavior. Only OP_EQUAL is defined for operations between struct and non-structs. If it shouldn't be like that, what would be the definition for the comparison?
EQUAL only gives true if the scalar value is equal to every element of the struct.

comment:3 by Dimitar Misev, 4 years ago

Resolution: worksforme
Status: acceptedclosed

Indeed, this is not supported in rasql. According to the documentation https://doc.rasdaman.org/04_ql-guide.html#induction-all-operations

On composite cells, only = and != are supported; both operands must have a compatible cell structure. In this case, the comparison result is the conjunction (“and” connection) of the pairwise comparison of all cell components.

So the implementation currently supports even more than what the documentation says. Comparison of two struct values should work, so you can try for example

{25,25,25} > rgbcoll

comment:4 by Bang Pham Huu, 4 years ago

why " when 18 > MDD" in the description work?

the query is "case 25 = MDD then … when 18 > MDD then…"

comment:5 by Dimitar Misev, 4 years ago

Because in the when clauses you're comparing 18 > c0.1, not 18 > c0.

Note: See TracTickets for help on using tickets.