I am building a daily energy report on Apache IoTDB 2.0.8 table model. The UI sends day boundaries as formatted strings, so I tried to cast those strings to TIMESTAMP directly in the WHERE clause. The rows are present, but the casted timestamp predicate fails with a class cast error.
Table definition and rows:
CREATE TABLE meter_energy (
time TIMESTAMP TIME,
meter_id STRING TAG,
kwh DOUBLE FIELD
);
INSERT INTO meter_energy(time, meter_id, kwh)
VALUES ('2025-07-01 23:30:00', 'main', 10.0);
INSERT INTO meter_energy(time, meter_id, kwh)
VALUES ('2025-07-02 00:30:00', 'main', 12.0);
Query that fails:
SELECT time, meter_id, kwh
FROM meter_energy
WHERE time >= CAST('2025-07-01 00:00:00' AS TIMESTAMP)
AND time < CAST('2025-07-02 00:00:00' AS TIMESTAMP);
Actual result:
Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 301: class org.apache.iotdb.db.queryengine.plan.relational.sql.ast.GenericLiteral cannot be cast to class org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LongLiteral (org.apache.iotdb.db.queryengine.plan.relational.sql.ast.GenericLiteral and org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LongLiteral are in unnamed module of loader 'app')
Control query using epoch millisecond boundaries:
SELECT time, meter_id, kwh
FROM meter_energy
WHERE time >= 1751299200000
AND time < 1751385600000;
Control result:
+-----------------------------+--------+----+
| time|meter_id| kwh|
+-----------------------------+--------+----+
|2025-07-01T23:30:00.000+08:00| main|10.0|
+-----------------------------+--------+----+
The same report works if I convert the boundaries to epoch milliseconds before sending SQL. What surprised me is that CAST(... AS TIMESTAMP) is accepted syntactically but fails with a planner class cast when used against the time column.
My question is: does IoTDB table model currently require time range predicates to be written with numeric timestamp literals, or is CAST(string AS TIMESTAMP) supposed to work here? If it is unsupported in WHERE time ..., is this class-cast exception the expected error surface?