Skip to content

Unexpected result when using CASE statement #15029

Description

@suyZhong

CrateDB version

5.5.0 docker image

CrateDB setup information

-Cdiscovery.type=single-node

Problem description

The third SELECT returns an empty result, which is surprising, given that the result of the second query is TRUE. The value of the CASE expression should always be true, and thus the third query should return the whole table.

Steps to Reproduce

CREATE TABLE t1 (c0 INT);
INSERT INTO t1 VALUES (NULL);

SELECT * FROM t1; -- NULL
SELECT (CASE WHEN 1 THEN 2 ELSE c0 END )!=1 FROM t1; -- TRUE
SELECT * FROM t1 WHERE (CASE WHEN 1 THEN 2 ELSE c0 END )!=1; 

Actual Result

Empty table

Expected Result

NULL

Metadata

Metadata

Assignees

Labels

bugClear identification of incorrect behaviour

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions