Skip to content

Unexpected result when using empty OBJECT literal #16476

Description

@suyZhong

CrateDB version

CrateDB 5.9.0-SNAPSHOT built 5940044

CrateDB setup information

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

Problem description

Consider the following test case. As the second query returns NULL, the expression of the WHERE filter should be evaluated to NULL, and thus the third query should return an empty table. However, a row is fetched. Either the result of the second query or the third query should be wrong.

Steps to Reproduce

DROP TABLE IF EXISTS t0;

CREATE  TABLE  t0(c0 OBJECT);
INSERT INTO t0(c0) VALUES (NULL);
REFRESH TABLE t0;

SELECT * FROM t0; -- NULL
SELECT (c0 != {}) FROM t0; -- NULL
SELECT * FROM t0 WHERE (c0 != {});
-- Expected: empty result set
-- Actual: NULL

-- I orignally found by this query:
SELECT * FROM t0 WHERE (c0 != CAST('1' AS OBJECT));

Actual Result

NULL

Expected Result

An empty table

Metadata

Metadata

Assignees

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