Question Details

No question body available.

Tags

sql time-series apache-iotdb

Answers (1)

June 30, 2026 Score: 3 Rep: 526,863 Quality: Medium Completeness: 50%

I don't know why Apache IOTDB behaves this way, as in most other SQL databases, using plain NULL as the else condition would have compiled.

However, I can suggest the following version instead:

SELECT
    time,
    txt,
    CAST(CASE WHEN txt != 'bad' THEN txt END AS DOUBLE) AS n
FROM replacementcasenull
ORDER BY time;

We can take advantage of that the default else value in a CASE expression is already NULL, so we don't have to explicitly even add an else condition. And since both if/else are being cast to double, we can just wrap the entire CASE expression in one single cast.