UNION ALL trigger engine Error
Bug Description A valid UNION ALL query that combines an empty result (WHERE 1=0) with a non-empty one causes the TDengine server to throw an internal error. Both branches are syntactically valid and return data individually.
To Reproduce Steps to reproduce the behavior:
-- 1. Create minimal environment
CREATE DATABASE IF NOT EXISTS utest;
USE utest;
CREATE STABLE IF NOT EXISTS s1 (
ts TIMESTAMP,
deviceid BINARY(16),
c0 INT,
c1 INT
) TAGS (tg BINARY(8));
CREATE TABLE IF NOT EXISTS t1 USING s1 TAGS ('X');
INSERT INTO t1 VALUES
('2022-01-01 00:00:00.000', 'devA', 119, 7),
('2022-01-01 00:02:00.000', 'devA', 119, 8),
('2022-01-01 00:05:00.000', 'devA', 120, 9);
-- Query 1
SELECT ts, deviceid, c0, c1 FROM t1 WHERE 1=0; -- returns 0 rows
--Query 2
SELECT ts, deviceid, c0, c1 FROM t1 WHERE c0=119; -- returns 2 rows
--Query 3
(SELECT ts, deviceid, c0, c1 FROM t1 WHERE 1=0)
UNION ALL
(SELECT ts, deviceid, c0, c1 FROM t1 WHERE c0=119);
Expected Behavior Query 3 should return 2 rows as Query 2
Actual Result Query 3 : DB error: Unexpected generic error [0x80000110] (0.002163s)
Screenshots
Environment (please complete the following information):
- OS: Ubuntu 24.04 LTS (GNU/Linux 6.6.87.2-microsoft-standard-WSL2 x86_64
- TDengine Version: 3.3.8.4-linux
Additional Context The error occurs immediately after parsing, not during data fetch. If both branches are empty (WHERE 1=0 UNION ALL WHERE 1=0) the query succeeds Therefore the failure appears when one branch is empty and the other non-empty.
It's a bug. Thank you for your feedback.