EXTREME misses the largest-magnitude INT32 value in Apache IoTDB 2.0.8
13:14 30 Aug 2026

An electrical protection report uses EXTREME to retain the current delta with the largest absolute magnitude. With an INT32 series in Apache IoTDB 2.0.8 tree model, the result changes incorrectly at the minimum representable value.

I reproduced it with one panel:

CREATE TIMESERIES root.electrical_protection.relay_panel.current_delta
WITH DATATYPE=INT32, ENCODING=PLAIN;

INSERT INTO root.electrical_protection.relay_panel(timestamp,current_delta)
VALUES (1000,-2147483647);
INSERT INTO root.electrical_protection.relay_panel(timestamp,current_delta)
VALUES (2000,2147483647);
INSERT INTO root.electrical_protection.relay_panel(timestamp,current_delta)
VALUES (3000,-2147483648);

For the first two points, the absolute magnitudes are tied and the positive value is returned:

SELECT min_value(current_delta), max_value(current_delta), extreme(current_delta)
FROM root.electrical_protection.relay_panel
WHERE time <= 2000;
min_value max_value extreme
-2147483647 2147483647 2147483647

After including -2147483648, its magnitude is one larger than that of 2147483647, but EXTREME still selects the positive value:

SELECT min_value(current_delta), max_value(current_delta), extreme(current_delta)
FROM root.electrical_protection.relay_panel;
min_value max_value extreme
-2147483648 2147483647 2147483647

I expected -2147483648, because its mathematical absolute value is 2147483648. Is the INT32 implementation taking the absolute value before widening, so the minimum value overflows and loses the comparison?

time-series aggregate-functions apache-iotdb