Skip to content

Commit 8289238

Browse files
authored
Fix init time logic to ensure that time is not initiated‌ when the last cache will not updated during the execution phase (#17094)
1 parent 5802fa2 commit 8289238

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,6 +2498,15 @@ public void lastTest() {
24982498
DATABASE_NAME,
24992499
2);
25002500

2501+
expectedHeader = new String[] {"device_id", "_col1"};
2502+
retArray = new String[] {"d01,0xcafebabe55,", "d02,0xcafebabe50,"};
2503+
repeatTest(
2504+
"select device_id, last(s8) from table1 where device_id = 'd01' or device_id = 'd02' group by device_id order by device_id",
2505+
expectedHeader,
2506+
retArray,
2507+
DATABASE_NAME,
2508+
2);
2509+
25012510
expectedHeader =
25022511
new String[] {
25032512
"_col0", "_col1", "_col2", "_col3", "_col4", "_col5", "_col6", "_col7", "_col8", "_col9",

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,9 +3247,9 @@ private LastQueryAggTableScanOperator constructLastQueryAggTableScanOperator(
32473247
.initOrInvalidateLastCache(
32483248
node.getQualifiedObjectName().getDatabaseName(),
32493249
deviceEntry.getDeviceID(),
3250-
needInitTime && node.getGroupingKeys().isEmpty()
3251-
? Arrays.copyOfRange(targetColumns, 0, targetColumns.length - 1)
3252-
: targetColumns,
3250+
needInitTime || node.getGroupingKeys().isEmpty()
3251+
? targetColumns
3252+
: Arrays.copyOfRange(targetColumns, 0, targetColumns.length - 1),
32533253
false);
32543254
} else {
32553255
hitCachesIndexes.add(i);

0 commit comments

Comments
 (0)