Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a logical error when combining the IN operator and the IS NULL operator for multiple columns. #29059

Open
LingweiKuang opened this issue Dec 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@LingweiKuang
Copy link

LingweiKuang commented Dec 6, 2024

Bug Description

The abstract expression sequence is: column0 IN (constant) AND column1 IS [NOT] NULL

To Reproduce

Assume that we execute the following statement under a database named testdb.

DROP TABLE IF EXISTS t1;
CREATE TABLE t1(time TIMESTAMP, c0 BIGINT UNSIGNED, c1 BIGINT);
INSERT INTO t1(time, c0, c1) VALUES (1641024000000, 1, 1);
INSERT INTO t1(time, c0, c1) VALUES (1641024005000, 2, 2);
INSERT INTO t1(time, c0, c1) VALUES (1641024010000, null, null);

# query 1
SELECT c0, c1 FROM t1 WHERE (c0 IN (-100)) AND (c1 IS NOT NULL);

Expected Behavior

Query 1 returned result set: empty set

Actual behaviour

Query 1 returned result set: 1 and 2

Environment

  • OS:Ubuntu Server 22.04 LTS 64bit
  • TDengine Version:3.3.4.8

Additional Context

Hello, TDengine team. In Query 1, we restrict column c0 to only take the value -100, which does not exist in our table. Using the AND operator, we combine this restriction on c0 with a restriction on c1 (c1 IS NOT NULL). Theoretically, this should result in no data being retrieved. However, the latest version of TDengine returns all non-null data, indicating a logical error. This error also occurs in window queries, for example: SELECT COUNT(c0), COUNT(c1), _wstart FROM t1 WHERE (c0 IN (-100)) AND (c1 IS NOT NULL) INTERVAL (100s); This query returns the value 2.

@LingweiKuang LingweiKuang added the bug Something isn't working label Dec 6, 2024
@LingweiKuang
Copy link
Author

LingweiKuang commented Dec 6, 2024

There is a logical error when combining the IN operator and the IS NULL operator for multiple columns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant