TDengine icon indicating copy to clipboard operation
TDengine copied to clipboard

Abnormality in binary arithmetic operations involving the time field.

Open LingweiKuang opened this issue 1 year ago • 2 comments

Bug Description

An error occurred when performing a modulo operation between the time field and a floating-point number.

To Reproduce

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

DROP TABLE IF EXISTS t1;

CREATE TABLE IF NOT EXISTS t1(time TIMESTAMP, c0 BIGINT);
INSERT INTO t1(time, c0) VALUES (1641024000000, 0);
INSERT INTO t1(time, c0) VALUES (1641024000001, 1);
INSERT INTO t1(time, c0) VALUES (1641024000002, 1);
INSERT INTO t1(time, c0) VALUES (1641024007000, 2);

# query 1
select cast(time % 10 as bigint), c0 from t1;

# query 2 error
SELECT time % 2.0001, c0 FROM t1;

Expected Behavior

Query 1 and Query 2 can be executed successfully and return the corresponding results.

Actual behaviour

Query 1 can be executed successfully, while Query 2 returns an error: "DB error: Invalid operation".

Environment

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

Additional Context

Hello, TDengine team. I'd like to confirm with you whether this is a bug? In addition, in the above queries, ① Query 1 returns results with numerical overflow, and ② binary arithmetic operations between time and time are not supported. For example, the query select * from t2 WHERE time * 2 > 1; can be executed, while the query select * from t2 WHERE time + time > 1; fails to execute.

LingweiKuang avatar Oct 12 '24 06:10 LingweiKuang

I will confirm this, thanks for your feedback

yu285 avatar Oct 14 '24 01:10 yu285

Thank you for your reply. 😊😊😊

LingweiKuang avatar Oct 15 '24 01:10 LingweiKuang

image

yu285 avatar Dec 11 '24 07:12 yu285