apache / apache/iotdb

[Bug] In version 1.3.3 of IoTDB, The time series function TIME_DIFFERENCE returns an index out of bounds error.

Open
#14,522 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
6.4k
Forks
1.2k
Avg merge
1d 23h
Merged PRs (30d)
115

Description

### Search before asking

- [X] I searched in the [issues](https://github.com/apache/iotdb/issues) and found nothing similar.

### Version

version 1.3.3 (Build: ad95a7e)

### Describe the bug and provide the minimal reproduce step

```
DROP DATABASE root.db0.t1
CREATE DATABASE root.db0.t1

CREATE TIMESERIES root.db0.t1.c0 WITH datatype=INT32;
INSERT INTO root.db0.t1(timestamp, c0) VALUES (1641024000000, 0), (1641024005000, 1);

# query 1
SELECT TIME_DIFFERENCE(c0) FROM root.db0.t1 WHERE c0 < 0;

# query 2
SELECT TIME_DIFFERENCE(c0) FROM root.db0.t1 WHERE time != time;
```

### What did you expect to see?

The expected result set for Query 1 is: **empty set**

The expected result set for Query 2 is: **empty set**

### What did you see instead?

The actual result set returned by Query 1 is: **empty set**

The actual result set returned by Query 2 is: **Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 301: Index 1 out of bounds for length 1**

### Anything else?

Dear IoTDB team, In the above queries, both Query 1 and Query 2 are unable to retrieve any data, so they both perform the `TIME_DIFFERENCE` operation on empty sets. However, Query 2 triggers an index out of bounds error during execution. This should be considered a crash error.

### Are you willing to submit a PR?

- [ ] I'm willing to submit a PR!

Contributor guide

Open the contributing guide

Research direction

Start by running the minimal reproduction against IoTDB 1.3.3, comparing Query 1 and Query 2. Trace the TIME_DIFFERENCE execution path for the empty result produced by Query 2; done means both queries return an empty set without an index-out-of-bounds exception. No source file or existing test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.