[Bug] 多设备查询最新值报错
- 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
1.0.1
### Describe the bug and provide the minimal reproduce step
查询多设备最新值
select last 进水COD, `11`, CO2, 水管流速, 膜产水状态, 功能码, TJCTSB1_Manual_start, TJCTSB1_Manual_stop, JCS_In_TN from root.ln_1.tb_6340, root.ln_1.tb_0014, root.ln_1.tb_6141
### What did you expect to see?
正确结果
### What did you see instead?
Msg: 301: null
2023-03-17 16:05:46,526 [Query-Worker-Thread-11$20230317_080546_52613_1.1.0] WARN o.a.i.d.m.e.s.AbstractDriverThread:80 - [ExecuteFailed]
java.lang.NullPointerException: null
at org.apache.iotdb.db.mpp.execution.operator.process.last.LastQueryUtil.appendLastValue(LastQueryUtil.java:108)
at org.apache.iotdb.db.mpp.execution.operator.process.last.LastQueryMergeOperator.next(LastQueryMergeOperator.java:171)
at org.apache.iotdb.db.mpp.execution.driver.Driver.processInternal(Driver.java:193)
at org.apache.iotdb.db.mpp.execution.driver.Driver.lambda$processFor$1(Driver.java:131)
at org.apache.iotdb.db.mpp.execution.driver.Driver.tryWithLock(Driver.java:277)
at org.apache.iotdb.db.mpp.execution.driver.Driver.processFor(Driver.java:112)
at org.apache.iotdb.db.mpp.execution.schedule.DriverTaskThread.execute(DriverTaskThread.java:64)
at org.apache.iotdb.db.mpp.execution.schedule.AbstractDriverThread.run(AbstractDriverThread.java:74)
2023-03-17 16:05:46,527 [pool-30-IoTDB-ClientRPC-Processor-6] WARN o.a.i.d.u.ErrorHandlingUtils:90 - Status code: 301, Query Statement: "select last 进水COD, CO2, 水管流速, 膜产水状态, 功能码, TJCTSB1_Manual_start, TJCTSB1_Manual_stop, JCS_In_TN from root.ln_1.tb_6340, root.ln_1.tb_0014, root.ln_1.tb_6141". executeStatement failed
org.apache.iotdb.commons.exception.IoTDBException: java.lang.NullPointerException
at org.apache.iotdb.db.mpp.plan.execution.QueryExecution.dealWithException(QueryExecution.java:428)
at org.apache.iotdb.db.mpp.plan.execution.QueryExecution.getResult(QueryExecution.java:411)
at org.apache.iotdb.db.mpp.plan.execution.QueryExecution.getByteBufferBatchResult(QueryExecution.java:446)
at org.apache.iotdb.db.utils.QueryDataSetUtils.convertQueryResultByFetchSize(QueryDataSetUtils.java:387)
at org.apache.iotdb.db.service.thrift.impl.ClientRPCServiceImpl.lambda$static$0(ClientRPCServiceImpl.java:162)
at org.apache.iotdb.db.service.thrift.impl.ClientRPCServiceImpl.executeStatementInternal(ClientRPCServiceImpl.java:240)
at org.apache.iotdb.db.service.thrift.impl.ClientRPCServiceImpl.executeStatementV2(ClientRPCServiceImpl.java:398)
at org.apache.iotdb.service.rpc.thrift.IClientRPCService$Processor$executeStatementV2.getResult(IClientRPCService.java:3509)
at org.apache.iotdb.service.rpc.thrift.IClientRPCService$Processor$executeStatementV2.getResult(IClientRPCService.java:3489)
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:38)
at org.apache.iotdb.db.service.thrift.ProcessorWithMetrics.process(ProcessorWithMetrics.java:64)
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:248)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException: null
at org.apache.iotdb.db.mpp.execution.operator.process.last.LastQueryUtil.appendLastValue(LastQueryUtil.java:108)
at org.apache.iotdb.db.mpp.execution.operator.process.last.LastQueryMergeOperator.next(LastQueryMergeOperator.java:171)
at org.apache.iotdb.db.mpp.execution.driver.Driver.processInternal(Driver.java:193)
at org.apache.iotdb.db.mpp.execution.driver.Driver.lambda$processFor$1(Driver.java:131)
at org.apache.iotdb.db.mpp.execution.driver.Driver.tryWithLock(Driver.java:277)
at org.apache.iotdb.db.mpp.execution.driver.Driver.processFor(Driver.java:112)
at org.apache.iotdb.db.mpp.execution.schedule.DriverTaskThread.execute(DriverTaskThread.java:64)
at org.apache.iotdb.db.mpp.execution.schedule.AbstractDriverThread.run(AbstractDriverThread.java:74)
### Anything else?
_No response_
### Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
Contributor guide
Research direction
Start with LastQueryUtil.java at line 108 and trace how LastQueryMergeOperator.java at line 171 handles the multi-device LAST query. Reproduce the reported SQL against IoTDB 1.0.1 or an equivalent setup, then verify that the query returns the correct latest values without a NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100