Confusing Behavior of ALL Subquery in Apache IoTDB
14:13 26 Apr 2026

I'm using the ALL syntax in Apache IoTDB 2.0.6 table model for a query, but the returned result is inconsistent with expectations.

Minimal Reproducible Data

  CREATE TABLE main_data (
  `time` TIMESTAMP `TIME`,
  device_id STRING TAG,
  value INT32 FIELD
  );
  
  CREATE TABLE detail_data (
  device_id STRING TAG,
  ref_value INT32 FIELD
  );
  
  INSERT INTO main_data VALUES
  (2024-01-01T00:00:00, 'D1', 30),
  (2024-01-01T01:00:00, 'D1', 40),
  (2024-01-01T02:00:00, 'D1', 50);
  
  INSERT INTO detail_data VALUES
  (2024-01-01T00:00:00, 'D1', 30),
  (2024-01-01T01:00:00, 'D1', 40),
  (2024-01-02T00:00:00, 'D1', `NULL`);

Query Statement

  SELECT * FROM main_data
  WHERE device_id = 'D1'
  AND value > ALL (SELECT ref_value FROM detail_data WHERE device_id = 'D1');

Returned Result

  +----+---------+-----+
  |`time`|device_id|value|
  +----+---------+-----+
  +----+---------+-----+
  Empty set.

Problem Encountered

When comparing 50 > ALL(30, 40, NULL), no result is returned.

My expected behavior: ignore NULL values and return the following result:

  +-----------------------------+----------+-------+
  | `time`| device_id| value|
  +-----------------------------+----------+-------+
  |2024-01-01T02:00:00.000+08:00| D1| 50|
  +-----------------------------+----------+-------+

Question

How should I adjust the SQL to ignore NULL values when performing the comparison?

time-series apache-iotdb