taosdata / TDengine

High-performance, scalable time-series database designed for Industrial IoT (IIoT) scenarios
https://tdengine.com
GNU Affero General Public License v3.0
23.36k stars 4.85k forks source link

An error occurred during binary arithmetic operations between the time field and the data field. #28339

Open LingweiKuang opened 2 weeks ago

LingweiKuang commented 2 weeks ago

Bug Description

An error occurred during binary arithmetic operations between the time field and the data field.

To Reproduce

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

DROP TABLE t1;

CREATE TABLE t1( time TIMESTAMP, c0 INT);
INSERT INTO t1(time, c0) VALUES (1641024000000, 1);

# query 1 success
SELECT time, c0 FROM t1 WHERE (time - c0) > 0;
SELECT time, c0 FROM t1 WHERE (time + c0) > 0;
SELECT time, c0 FROM t1 WHERE (-(-c0)) > 0;

# query 2 error
SELECT time, c0 FROM t1 WHERE (time - (-c0)) > 0;

Expected Behavior

The query statement 1 and query statement 2 can both retrieve all the data.

Actual behaviour

Query 1 can retrieve all the data, but Query 2 returns an error: DB error: Invalid operation.

Environment

Additional Context

Hello, TDengine team. I'd like to confirm with you whether this is a bug? Because Query 1 and Query 2 are equivalent.

yu285 commented 2 days ago

let me check on this