Opened 9 years ago

Closed 5 years ago

#928 closed defect (duplicate)

Incorrect result of CASE statement with MDDs in "then" clauses

Reported by: Veranika Liaukevich Owned by: dkamov
Priority: major Milestone: 10.0
Component: qlparser Version: development
Keywords: Cc:
Complexity: Medium

Description

Case statement returns wrong results if one of result expressions (then clause) is a database MDD.

Example: array test has 4 cells:

$ rasql -q 'select csv(x) from test as x' --out string
{1,2},{3,4}

Wrong case statement result:

$ rasql-q 'select csv(case when mod(x, 2) = 1 then x else 0 end) from test as x' --out string
{67305985,0},{1027,0}

However, the statement produces correct results if an argument is a general expression:

$ rasql -q 'select csv(case when mod(x, 2) = 1 then 1*x else 0 end) from test as x' --out string
{1,0},{3,0}

Change History (9)

comment:1 by Dimitar Misev, 9 years ago

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

comment:2 by Dimitar Misev, 9 years ago

Milestone: 9.2

comment:3 by Dimitar Misev, 8 years ago

Milestone: 9.29.4

comment:4 by Dimitar Misev, 7 years ago

Milestone: 9.49.5

comment:5 by Vlad Merticariu, 7 years ago

Milestone: 9.59.6

comment:6 by Dimitar Misev, 7 years ago

Milestone: 9.69.7
Owner: changed from Vlad Merticariu to bbell

Still the case:

rasql -q 'select csv(case when mod(x, 2) = 1 then x else 0 end) from nulltest as x' --out stringrasql: rasdaman query tool v1.0, rasdaman 9.6.0.
Opening database RASBASE at localhost:7001... ok.
Executing retrieval query... ok.
Query result collection has 1 element(s):
  Result object 1: {67305985,0,50463747,0},{0,50660355,0,0},{100992003,0,0,0},{0,0,0,0}
rasql done.

It looks like some uninitialized data, but the output is pretty consistent and valgrind doesn't report any issue. So not sure what exactly is wrong.

comment:7 by Dimitar Misev, 5 years ago

Milestone: 9.710.0
Owner: changed from bbell to dkamov

comment:8 by dkamov, 5 years ago

Currently running the query given gives out this error:

[ERROR] - 2019-08-13 16:02:10,180, qlparser/qtcaseop.cc:592: THEN / ELSE results in CASE statement have different base types (at operand 3). Please add casts as necessary to make sure all result expressions are of the same base type.
rasdaman error 430: Execution error 430 in line 1, column 12, near token case: The results have incompatible types.

which is reasonable x is recognized as a char and 0 as long.

I could produce a result instead of an error if I add in compatibleWith the case of char and long, and in getResultType the return of a char. Should I do that?

comment:9 by Dimitar Misev, 5 years ago

Resolution: duplicate
Status: assignedclosed

No, your proposed fix works only for this specific query in the ticket. What if x was short? :)

The error is good now, so closing as duplicate (clearly this ticket was already fixed before).

Note: See TracTickets for help on using tickets.