What happens?
Consider the following test case. The third query should return an empty result, as CAST(CAST(t1.c1 AS BIT) AS INTEGER) is evaluated to -1 and the expression should be false. However, the query returns -1, which is unexpected.
I found in PostgreSQL, the second query would be evaluated as true. Either the second or the third query is unexpected.
To Reproduce
CREATE TABLE t1( c1 INTEGER);
INSERT INTO t1(c1) VALUES (-1);
SELECT t1.c1 FROM t1; -- -1
SELECT (1 BETWEEN -1 AND CAST(CAST(t1.c1 AS BIT) AS INTEGER)) FROM t1; -- false
SELECT t1.c1 FROM t1 WHERE (1 BETWEEN -1 AND CAST(CAST(t1.c1 AS BIT) AS INTEGER));
-- Expected: empty
-- Actual: -1
OS:
ubuntu 22.04
DuckDB Version:
v0.0.1 367aa8d
DuckDB Client:
CLI
Full Name:
Suyang Zhong
Affiliation:
NUS
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a nightly build
Did you include all relevant data sets for reproducing the issue?
Yes
Did you include all code required to reproduce the issue?
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
What happens?
Consider the following test case. The third query should return an empty result, as
CAST(CAST(t1.c1 AS BIT) AS INTEGER)is evaluated to-1and the expression should be false. However, the query returns-1, which is unexpected.I found in PostgreSQL, the second query would be evaluated as
true. Either the second or the third query is unexpected.To Reproduce
OS:
ubuntu 22.04
DuckDB Version:
v0.0.1 367aa8d
DuckDB Client:
CLI
Full Name:
Suyang Zhong
Affiliation:
NUS
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a nightly build
Did you include all relevant data sets for reproducing the issue?
Yes
Did you include all code required to reproduce the issue?
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?