Skip to content

Unexpected result when using CONCAT_WS containing NULL #15459

Description

@suyZhong

CrateDB version

CrateDB 5.7.0-SNAPSHOT built 93ee46e

CrateDB setup information

Manual build following the instructions here: https://github.com/crate/crate/blob/master/devs/docs/basics.rst

Problem description

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

Steps to Reproduce

DROP TABLE IF EXISTS t1;
CREATE TABLE t1(c1 BOOLEAN);
INSERT INTO t1 (c1) VALUES (null);
REFRESH TABLE t1;


SELECT * FROM t1; -- NULL
SELECT (NOT (NOT CONCAT_WS(true, CAST(t1.c1 AS BOOLEAN), true))) FROM t1; -- TRUE
SELECT * FROM t1 WHERE (NOT (NOT CONCAT_WS(true, CAST(t1.c1 AS BOOLEAN), true)));
-- Expected: NULL
-- Actual:   empty result

-- For reference:
SELECT CAST(t1.c1 AS BOOLEAN) FROM t1; -- NULL
SELECT (NOT (NOT CONCAT_WS(true, NULL, true))) FROM t1; -- TRUE
SELECT * FROM t1 WHERE (NOT (NOT CONCAT_WS(true, null, true))); -- NULL

Actual Result

Empty

Expected Result

NULL

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugClear identification of incorrect behaviour

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions