An inspection screen filters rows by a short list of priority values. In Apache IoTDB 2.0.10, adding an untyped NULL to that list turns a valid-looking filter into an internal type cast error.
Reproduction:
CREATE DATABASE inspection_selection;
USE inspection_selection;
CREATE TABLE inspection_items(station STRING TAG, priority INT32 FIELD);
INSERT INTO inspection_items(time,station,priority) VALUES
(1000,'west',1),(2000,'west',2),(3000,'west',3);
This query fails:
SELECT time,priority
FROM inspection_items
WHERE priority IN (1,NULL)
ORDER BY time;
Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 301: class org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.NullLiteral cannot be cast to class org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.LongLiteral (org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.NullLiteral and org.apache.iotdb.commons.queryengine.plan.relational.sql.ast.LongLiteral are in unnamed module of loader 'app')
Typing the null to the column type makes the same membership test return the matching row:
SELECT time,priority
FROM inspection_items
WHERE priority IN (1,CAST(NULL AS INT32))
ORDER BY time;
+-----------------------------+--------+
| time|priority|
+-----------------------------+--------+
|1970-01-01T08:00:01.000+08:00| 1|
+-----------------------------+--------+
The non-NULL list also succeeds and returns both requested priorities:
SELECT time,priority
FROM inspection_items
WHERE priority IN (1,2)
ORDER BY time;
+-----------------------------+--------+
| time|priority|
+-----------------------------+--------+
|1970-01-01T08:00:01.000+08:00| 1|
|1970-01-01T08:00:02.000+08:00| 2|
+-----------------------------+--------+
The table-model IN operator accepts a list of values or scalar expressions, but the untyped null escapes as an AST class cast instead of a SQL result or a type-analysis error. Should this be handled as SQL NULL membership, or rejected with a user-facing type diagnostic?