• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #4829

30 Oct 2025 09:25AM UTC coverage: 49.734% (-11.3%) from 61.071%
#4829

push

travis-ci

web-flow
Merge pull request #33435 from taosdata/3.0

merge 3.0

123072 of 323930 branches covered (37.99%)

Branch coverage included in aggregate %.

7 of 25 new or added lines in 3 files covered. (28.0%)

35232 existing lines in 327 files now uncovered.

172062 of 269495 relevant lines covered (63.85%)

70709785.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.43
/source/libs/executor/src/eventwindowoperator.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#include "executorInt.h"
17
#include "filter.h"
18
#include "function.h"
19
#include "functionMgt.h"
20
#include "operator.h"
21
#include "querytask.h"
22
#include "tcommon.h"
23
#include "tcompare.h"
24
#include "tdatablock.h"
25
#include "ttime.h"
26

27
static int32_t eventWindowAggregateNext(SOperatorInfo* pOperator, SSDataBlock** pRes);
28
static void    destroyEWindowOperatorInfo(void* param);
29
static int32_t eventWindowAggImpl(SOperatorInfo* pOperator, SEventWindowOperatorInfo* pInfo, SSDataBlock* pBlock);
30
void cleanupResultInfoInEventWindow(SOperatorInfo* pOperator, SEventWindowOperatorInfo* pInfo);
31

32
static int32_t resetEventWindowOperState(SOperatorInfo* pOper) {
×
33
  SEventWindowOperatorInfo* pEvent = pOper->info;
×
34
  SExecTaskInfo*           pTaskInfo = pOper->pTaskInfo;
×
35
  SEventWinodwPhysiNode* pPhynode = (SEventWinodwPhysiNode*)pOper->pPhyNode;
×
36
  pOper->status = OP_NOT_OPENED;
×
37

38
  resetBasicOperatorState(&pEvent->binfo);
×
39
  taosMemoryFreeClear(pEvent->pRow);
×
40

41
  pEvent->groupId = 0;
×
42
  pEvent->pPreDataBlock = NULL;
×
43
  pEvent->inWindow = false;
×
44

45
  colDataDestroy(&pEvent->twAggSup.timeWindowData);
×
46
  int32_t code = initExecTimeWindowInfo(&pEvent->twAggSup.timeWindowData, &pTaskInfo->window);
×
47
  cleanupResultInfoInEventWindow(pOper, pEvent);
×
48

49
  if (code == 0) {
×
50
    code = resetAggSup(&pOper->exprSupp, &pEvent->aggSup, pTaskInfo, pPhynode->window.pFuncs, NULL,
×
51
                       sizeof(int64_t) * 2 + POINTER_BYTES, pTaskInfo->id.str, pTaskInfo->streamInfo.pState,
×
52
                       &pTaskInfo->storageAPI.functionStore);
53
  }
54
  if (code == 0) {
×
55
    code = resetExprSupp(&pEvent->scalarSup, pTaskInfo, pPhynode->window.pExprs, NULL,
×
56
                         &pTaskInfo->storageAPI.functionStore);
57
  }
58
  return code;
×
59
}
60

61
int32_t createEventwindowOperatorInfo(SOperatorInfo* downstream, SPhysiNode* physiNode,
59,728✔
62
                                             SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
63
  QRY_PARAM_CHECK(pOptrInfo);
59,728!
64

65
  int32_t                   code = TSDB_CODE_SUCCESS;
59,728✔
66
  int32_t                   lino = 0;
59,728✔
67
  SEventWindowOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SEventWindowOperatorInfo));
59,728!
68
  SOperatorInfo*            pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
59,728!
69
  if (pInfo == NULL || pOperator == NULL) {
59,728!
70
    code = terrno;
×
71
    goto _error;
×
72
  }
73

74
  pOperator->pPhyNode = physiNode;
59,728✔
75
  pOperator->exprSupp.hasWindowOrGroup = true;
59,728✔
76

77
  SEventWinodwPhysiNode* pEventWindowNode = (SEventWinodwPhysiNode*)physiNode;
59,728✔
78

79
  int32_t tsSlotId = ((SColumnNode*)pEventWindowNode->window.pTspk)->slotId;
59,728✔
80
  code = filterInitFromNode((SNode*)pEventWindowNode->pStartCond, &pInfo->pStartCondInfo, 0,
59,728✔
81
                            pTaskInfo->pStreamRuntimeInfo);
59,728✔
82
  QUERY_CHECK_CODE(code, lino, _error);
59,728!
83

84
  code = filterInitFromNode((SNode*)pEventWindowNode->pEndCond, &pInfo->pEndCondInfo, 0,
59,728✔
85
                            pTaskInfo->pStreamRuntimeInfo);
59,728✔
86
  QUERY_CHECK_CODE(code, lino, _error);
59,728!
87

88
  if (pEventWindowNode->window.pExprs != NULL) {
59,728!
UNCOV
89
    int32_t    numOfScalarExpr = 0;
×
UNCOV
90
    SExprInfo* pScalarExprInfo = NULL;
×
91

UNCOV
92
    code = createExprInfo(pEventWindowNode->window.pExprs, NULL, &pScalarExprInfo, &numOfScalarExpr);
×
UNCOV
93
    QUERY_CHECK_CODE(code, lino, _error);
×
UNCOV
94
    code = initExprSupp(&pInfo->scalarSup, pScalarExprInfo, numOfScalarExpr, &pTaskInfo->storageAPI.functionStore);
×
UNCOV
95
    QUERY_CHECK_CODE(code, lino, _error);
×
96
  }
97

98
  code = filterInitFromNode((SNode*)pEventWindowNode->window.node.pConditions, &pOperator->exprSupp.pFilterInfo, 0,
59,728✔
99
                            pTaskInfo->pStreamRuntimeInfo);
59,728✔
100
  QUERY_CHECK_CODE(code, lino, _error);
59,728!
101

102
  size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
59,728✔
103

104
  int32_t    num = 0;
59,728✔
105
  SExprInfo* pExprInfo = NULL;
59,728✔
106
  code = createExprInfo(pEventWindowNode->window.pFuncs, NULL, &pExprInfo, &num);
59,728✔
107
  QUERY_CHECK_CODE(code, lino, _error);
59,728!
108

109
  initResultSizeInfo(&pOperator->resultInfo, 4096);
59,728✔
110

111
  code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str,
119,456✔
112
                    pTaskInfo->streamInfo.pState, &pTaskInfo->storageAPI.functionStore);
59,728✔
113
  QUERY_CHECK_CODE(code, lino, _error);
59,728!
114

115
  SSDataBlock* pResBlock = createDataBlockFromDescNode(pEventWindowNode->window.node.pOutputDataBlockDesc);
59,728✔
116
  QUERY_CHECK_NULL(pResBlock, code, lino, _error, terrno);
59,728!
117
  initBasicInfo(&pInfo->binfo, pResBlock);
59,728✔
118

119
  code = blockDataEnsureCapacity(pResBlock, pOperator->resultInfo.capacity);
59,728✔
120
  QUERY_CHECK_CODE(code, lino, _error);
59,728!
121

122
  initResultRowInfo(&pInfo->binfo.resultRowInfo);
59,728✔
123
  pInfo->binfo.inputTsOrder = physiNode->inputTsOrder;
59,728✔
124
  pInfo->binfo.outputTsOrder = physiNode->outputTsOrder;
59,728✔
125

126
  pInfo->twAggSup = (STimeWindowAggSupp){.waterMark = pEventWindowNode->window.watermark,
59,728✔
127
                                         .calTrigger = pEventWindowNode->window.triggerType};
59,728✔
128

129
  code = initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
59,728✔
130
  QUERY_CHECK_CODE(code, lino, _error);
59,728!
131

132
  pInfo->tsSlotId = tsSlotId;
59,728✔
133
  pInfo->pPreDataBlock = NULL;
59,728✔
134
  pInfo->pOperator = pOperator;
59,728✔
135
  pInfo->trueForLimit = pEventWindowNode->trueForLimit;
59,728✔
136

137
  setOperatorInfo(pOperator, "EventWindowOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT, true, OP_NOT_OPENED, pInfo,
59,728✔
138
                  pTaskInfo);
139
  pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, eventWindowAggregateNext, NULL, destroyEWindowOperatorInfo,
59,728✔
140
                                         optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
141

142
  setOperatorResetStateFn(pOperator, resetEventWindowOperState);
59,728✔
143
  code = appendDownstream(pOperator, &downstream, 1);
59,728✔
144
  if (code != TSDB_CODE_SUCCESS) {
59,728!
145
    goto _error;
×
146
  }
147

148
  *pOptrInfo = pOperator;
59,728✔
149
  return TSDB_CODE_SUCCESS;
59,728✔
150

151
_error:
×
152
  if (pInfo != NULL) {
×
153
    destroyEWindowOperatorInfo(pInfo);
×
154
  }
155

156
  destroyOperatorAndDownstreams(pOperator, &downstream, 1);
×
157
  pTaskInfo->code = code;
×
158
  return code;
×
159
}
160

161
void cleanupResultInfoInEventWindow(SOperatorInfo* pOperator, SEventWindowOperatorInfo* pInfo) {
59,728✔
162
  if (pInfo == NULL || pInfo->pRow == NULL || pOperator == NULL) {
59,728!
163
    return;
8,316✔
164
  }
165
  SExprSupp*       pSup = &pOperator->exprSupp;
51,412✔
166
  for (int32_t j = 0; j < pSup->numOfExprs; ++j) {
692,296✔
167
    pSup->pCtx[j].resultInfo = getResultEntryInfo(pInfo->pRow, j, pSup->rowEntryInfoOffset);
640,884✔
168
    if (pSup->pCtx[j].fpSet.cleanup) {
640,884!
169
      pSup->pCtx[j].fpSet.cleanup(&pSup->pCtx[j]);
×
170
    }
171
  }
172
}
173

174
void destroyEWindowOperatorInfo(void* param) {
59,728✔
175
  SEventWindowOperatorInfo* pInfo = (SEventWindowOperatorInfo*)param;
59,728✔
176
  if (pInfo == NULL) {
59,728!
177
    return;
×
178
  }
179

180
  if (pInfo->pRow != NULL) {
59,728✔
181
    taosMemoryFree(pInfo->pRow);
51,412!
182
  }
183

184
  if (pInfo->pStartCondInfo != NULL) {
59,728!
185
    filterFreeInfo(pInfo->pStartCondInfo);
59,728✔
186
    pInfo->pStartCondInfo = NULL;
59,728✔
187
  }
188

189
  if (pInfo->pEndCondInfo != NULL) {
59,728!
190
    filterFreeInfo(pInfo->pEndCondInfo);
59,728✔
191
    pInfo->pEndCondInfo = NULL;
59,728✔
192
  }
193

194
  cleanupBasicInfo(&pInfo->binfo);
59,728✔
195
  colDataDestroy(&pInfo->twAggSup.timeWindowData);
59,728✔
196

197
  cleanupResultInfoInEventWindow(pInfo->pOperator, pInfo);
59,728✔
198
  pInfo->pOperator = NULL;
59,728✔
199
  cleanupAggSup(&pInfo->aggSup);
59,728✔
200
  cleanupExprSupp(&pInfo->scalarSup);
59,728✔
201
  taosMemoryFreeClear(param);
59,728!
202
}
203

204
static int32_t eventWindowAggregateNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
704,348✔
205
  int32_t                   code = TSDB_CODE_SUCCESS;
704,348✔
206
  int32_t                   lino = 0;
704,348✔
207
  SEventWindowOperatorInfo* pInfo = pOperator->info;
704,348✔
208
  SExecTaskInfo*            pTaskInfo = pOperator->pTaskInfo;
704,348✔
209

210
  SExprSupp* pSup = &pOperator->exprSupp;
704,348✔
211
  int32_t    order = pInfo->binfo.inputTsOrder;
704,348✔
212

213
  SSDataBlock* pRes = pInfo->binfo.pRes;
704,348✔
214

215
  blockDataCleanup(pRes);
704,348✔
216

217
  SOperatorInfo* downstream = pOperator->pDownstream[0];
704,348✔
218
  while (1) {
1,403,838✔
219
    SSDataBlock* pBlock = NULL;
2,108,186✔
220
    if (pInfo->pPreDataBlock == NULL) {
2,108,186✔
221
      pBlock = getNextBlockFromDownstream(pOperator, 0);
1,334,642✔
222
    } else {
223
      pBlock = pInfo->pPreDataBlock;
773,544✔
224
      pInfo->pPreDataBlock = NULL;
773,544✔
225
    }
226

227
    if (pBlock == NULL) {
2,108,186✔
228
      break;
38,376✔
229
    }
230

231
    pRes->info.scanFlag = pBlock->info.scanFlag;
2,069,810✔
232
    code = setInputDataBlock(pSup, pBlock, order, pBlock->info.scanFlag, true);
2,069,810✔
233
    QUERY_CHECK_CODE(code, lino, _end);
2,069,810!
234

235
    code = blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
2,069,810✔
236
    QUERY_CHECK_CODE(code, lino, _end);
2,069,810!
237

238
    // there is an scalar expression that needs to be calculated right before apply the group aggregation.
239
    if (pInfo->scalarSup.pExprInfo != NULL) {
2,069,810!
UNCOV
240
      code = projectApplyFunctions(pInfo->scalarSup.pExprInfo, pBlock, pBlock, pInfo->scalarSup.pCtx,
×
UNCOV
241
                                   pInfo->scalarSup.numOfExprs, NULL, GET_STM_RTINFO(pOperator->pTaskInfo));
×
UNCOV
242
      QUERY_CHECK_CODE(code, lino, _end);
×
243
    }
244

245
    code = eventWindowAggImpl(pOperator, pInfo, pBlock);
2,069,810✔
246
    QUERY_CHECK_CODE(code, lino, _end);
2,069,810!
247

248
    code = doFilter(pRes, pSup->pFilterInfo, NULL, NULL);
2,069,810✔
249
    QUERY_CHECK_CODE(code, lino, _end);
2,069,810!
250

251
    if (pRes->info.rows >= pOperator->resultInfo.threshold ||
2,069,810✔
252
        (pRes->info.id.groupId != pInfo->groupId && pRes->info.rows > 0)) {
2,056,718✔
253
      (*ppRes) = pRes;
665,972✔
254
      return code;
665,972✔
255
    }
256
  }
257

258
_end:
38,376✔
259
  if (code != TSDB_CODE_SUCCESS) {
38,376!
260
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
261
    pTaskInfo->code = code;
×
262
    T_LONG_JMP(pTaskInfo->env, code);
×
263
  }
264
  (*ppRes) =  pRes->info.rows == 0 ? NULL : pRes;
38,376✔
265
  return code;
38,376✔
266
}
267

268
static int32_t setSingleOutputTupleBufv1(SResultRowInfo* pResultRowInfo, STimeWindow* win, SResultRow** pResult,
99,729,430✔
269
                                         SExprSupp* pExprSup, SAggSupporter* pAggSup) {
270
  if (*pResult == NULL) {
99,729,430✔
271
    SResultRow* p = taosMemoryCalloc(1, pAggSup->resultRowSize);
51,412!
272
    if (!p) {
51,412!
273
      return terrno;
×
274
    }
275
    pResultRowInfo->cur = (SResultRowPosition){.pageId = p->pageId, .offset = p->offset};
51,412✔
276
    *pResult = p;
51,412✔
277
  }
278

279
  (*pResult)->win = *win;
99,729,430✔
280

281
  return setResultRowInitCtx(*pResult, pExprSup->pCtx, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset);
99,729,430✔
282
}
283

284
static int32_t doEventWindowAggImpl(SEventWindowOperatorInfo* pInfo, SExprSupp* pSup, int32_t startIndex,
99,729,430✔
285
                                    int32_t endIndex, const SSDataBlock* pBlock, int64_t* tsList,
286
                                    SExecTaskInfo* pTaskInfo) {
287
  int32_t code = TSDB_CODE_SUCCESS;
99,729,430✔
288
  SWindowRowsSup* pRowSup = &pInfo->winSup;
99,729,430✔
289

290
  int32_t numOfOutput = pSup->numOfExprs;
99,729,430✔
291
  int32_t numOfRows = endIndex - startIndex + 1;
99,729,430✔
292

293
  doKeepTuple(pRowSup, tsList[endIndex], endIndex, pBlock->info.id.groupId);
99,729,430✔
294

295
  code = setSingleOutputTupleBufv1(&pInfo->binfo.resultRowInfo, &pRowSup->win, &pInfo->pRow, pSup, &pInfo->aggSup);
99,729,430✔
296
  if (code != TSDB_CODE_SUCCESS) {  // null data, too many state code
99,729,430!
297
    qError("failed to set single output tuple buffer, code:%d", code);
×
298
    return code;
×
299
  }
300

301
  updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, 0);
99,729,430✔
302
  code = applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startIndex, numOfRows,
99,729,430✔
303
                                         pBlock->info.rows, numOfOutput);
99,729,430✔
304
  return code;
99,729,430✔
305
}
306

307
int32_t eventWindowAggImpl(SOperatorInfo* pOperator, SEventWindowOperatorInfo* pInfo, SSDataBlock* pBlock) {
2,069,810✔
308
  int32_t          code = TSDB_CODE_SUCCESS;
2,069,810✔
309
  int32_t          lino = 0;
2,069,810✔
310
  SExecTaskInfo*   pTaskInfo = pOperator->pTaskInfo;
2,069,810✔
311
  SExprSupp*       pSup = &pOperator->exprSupp;
2,069,810✔
312
  SSDataBlock*     pRes = pInfo->binfo.pRes;
2,069,810✔
313
  int64_t          gid = pBlock->info.id.groupId;
2,069,810✔
314
  SColumnInfoData *ps = NULL, *pe = NULL;
2,069,810✔
315
  SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pInfo->tsSlotId);
2,069,810✔
316
  QUERY_CHECK_NULL(pColInfoData, code, lino, _return, terrno);
2,069,810!
317
  TSKEY*           tsList = (TSKEY*)pColInfoData->pData;
2,069,810✔
318
  SWindowRowsSup*  pRowSup = &pInfo->winSup;
2,069,810✔
319
  int32_t          rowIndex = 0;
2,069,810✔
320
  int64_t          minWindowSize = getMinWindowSize(pOperator);
2,069,810✔
321

322
  pRowSup->numOfRows = 0;
2,069,810✔
323
  if (pInfo->groupId == 0) {
2,069,810✔
324
    pInfo->groupId = gid;
188,878✔
325
  } else if (pInfo->groupId != gid) {
1,880,932✔
326
    // this is a new group, reset the info
327
    pInfo->inWindow = false;
783,096✔
328
    pInfo->groupId = gid;
783,096✔
329
    pInfo->pPreDataBlock = pBlock;
783,096✔
330
    goto _return;
783,096✔
331
  }
332
  pRes->info.id.groupId = pInfo->groupId;
1,286,714✔
333

334
  SFilterColumnParam param1 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock};
1,286,714✔
335

336
  code = filterSetDataFromSlotId(pInfo->pStartCondInfo, &param1);
1,286,714✔
337
  QUERY_CHECK_CODE(code, lino, _return);
1,286,714!
338

339
  int32_t status1 = 0;
1,286,714✔
340
  code = filterExecute(pInfo->pStartCondInfo, pBlock, &ps, NULL, param1.numOfCols, &status1);
1,286,714✔
341
  QUERY_CHECK_CODE(code, lino, _return);
1,286,714!
342

343
  SFilterColumnParam param2 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock};
1,286,714✔
344
  code = filterSetDataFromSlotId(pInfo->pEndCondInfo, &param2);
1,286,714✔
345
  QUERY_CHECK_CODE(code, lino, _return);
1,286,714!
346

347
  int32_t status2 = 0;
1,286,714✔
348
  code = filterExecute(pInfo->pEndCondInfo, pBlock, &pe, NULL, param2.numOfCols, &status2);
1,286,714✔
349
  QUERY_CHECK_CODE(code, lino, _return);
1,286,714!
350

351
  int32_t startIndex = pInfo->inWindow ? 0 : -1;
1,286,714!
352
  while (rowIndex < pBlock->info.rows) {
200,532,482✔
353
    if (pInfo->inWindow) {  // let's find the first end value
199,782,304!
354
      for (rowIndex = startIndex; rowIndex < pBlock->info.rows; ++rowIndex) {
594,605,046✔
355
        if (((bool*)pe->pData)[rowIndex]) {
593,919,028!
356
          break;
99,043,412✔
357
        }
358
      }
359

360
      if (rowIndex < pBlock->info.rows) {
99,729,430✔
361
        code = doEventWindowAggImpl(pInfo, pSup, startIndex, rowIndex, pBlock, tsList, pTaskInfo);
99,043,412✔
362
        QUERY_CHECK_CODE(code, lino, _return);
99,043,412!
363
        doUpdateNumOfRows(pSup->pCtx, pInfo->pRow, pSup->numOfExprs, pSup->rowEntryInfoOffset);
99,043,412✔
364

365
        if (pRowSup->win.ekey - pRowSup->win.skey < minWindowSize) {
99,043,412✔
366
          qDebug("skip small window, groupId: %" PRId64 ", windowSize: %" PRId64 ", minWindowSize: %" PRId64,
280,364!
367
                 pInfo->groupId, pRowSup->win.ekey - pRowSup->win.skey, minWindowSize);
368
        } else {
369
          // check buffer size
370
          if (pRes->info.rows + pInfo->pRow->numOfRows >= pRes->info.capacity) {
98,763,048✔
371
            int32_t newSize = pRes->info.rows + pInfo->pRow->numOfRows;
942,624✔
372
            code = blockDataEnsureCapacity(pRes, newSize);
942,624✔
373
            QUERY_CHECK_CODE(code, lino, _return);
942,624!
374
          }
375

376
          code = copyResultrowToDataBlock(pSup->pExprInfo, pSup->numOfExprs, pInfo->pRow, pSup->pCtx, pRes,
98,763,048✔
377
                                          pSup->rowEntryInfoOffset, pTaskInfo);
98,763,048✔
378
          QUERY_CHECK_CODE(code, lino, _return);
98,763,048!
379

380
          pRes->info.rows += pInfo->pRow->numOfRows;
98,763,048✔
381
        }
382
        pInfo->pRow->numOfRows = 0;
99,043,412✔
383

384
        pInfo->inWindow = false;
99,043,412✔
385
        rowIndex += 1;
99,043,412✔
386
      } else {
387
        code = doEventWindowAggImpl(pInfo, pSup, startIndex, pBlock->info.rows - 1, pBlock, tsList, pTaskInfo);
686,018✔
388
        QUERY_CHECK_CODE(code, lino, _return);
686,018!
389
      }
390
    } else {  // find the first start value that is fulfill for the start condition
391
      for (; rowIndex < pBlock->info.rows; ++rowIndex) {
351,430,082✔
392
        if (((bool*)ps->pData)[rowIndex]) {
350,893,546!
393
          doKeepNewWindowStartInfo(pRowSup, tsList, rowIndex, gid);
99,516,338✔
394
          pInfo->inWindow = true;
99,516,338✔
395
          startIndex = rowIndex;
99,516,338✔
396
          if (pInfo->pRow != NULL) {
99,516,338✔
397
            clearResultRowInitFlag(pSup->pCtx, pSup->numOfExprs);
99,464,926✔
398
          }
399
          break;
99,516,338✔
400
        }
401
      }
402

403
      if (pInfo->inWindow) {
100,052,874!
404
        continue;  // try to find the end position
99,516,338✔
405
      } else {
406
        break;  // no valid start position, quit
536,536✔
407
      }
408
    }
409
  }
410

411
_return:
2,069,810✔
412

413
  if (code != TSDB_CODE_SUCCESS) {
2,069,810!
414
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
415
  }
416
  colDataDestroy(ps);
2,069,810✔
417
  taosMemoryFree(ps);
2,069,810!
418
  colDataDestroy(pe);
2,069,810✔
419
  taosMemoryFree(pe);
2,069,810!
420

421
  return code;
2,069,810✔
422
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc