taosdata / taosdata/TDengine

The combination of the IN operator and the BETWEEN operator contains a logical error.

Open
#28,989 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C
Stars
25.1k
Forks
5k
Avg merge
4d 59m
Merged PRs (30d)
7

Description

Bug Description

The abstract expression sequence is: time IN (constant) AND time BETWEEEN (constant) AND (constant)

To Reproduce

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

DROP TABLE IF EXISTS t1;
CREATE TABLE t1(time TIMESTAMP, c1 BIGINT);
INSERT INTO t1(time, c1) VALUES (1641024000000, 1);

# query 1
SELECT c1 FROM t1 WHERE time IN (1) AND time BETWEEN (1741024000000) AND (1741024000000);
Expected Behavior

Query 1 returned result set: empty set

Actual behaviour

Query 1 returned result set: 1

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

Hello, TDengine team. When the IN operator and the BETWEEN operator are used on the time field and connected by the AND logical operator, the expressions involving the IN and BETWEEN operators evaluate to FALSE, but the final result still filters out all the data.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by running the provided CREATE, INSERT, and SELECT statements against TDengine, then trace the expression evaluation for the time-field IN and BETWEEN predicates joined by AND. Done means the query returns an empty result set, with a regression test covering this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.