提交 976b3663 编写于 作者: H Haojun Liao

fix(query): keep last key for interp query.

上级 6c6e20ff
...@@ -3329,7 +3329,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl ...@@ -3329,7 +3329,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) { if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) {
// update the SQueryTableDataCond to create inner reader // update the SQueryTableDataCond to create inner reader
int32_t order = pCond->order; int32_t order = pCond->order;
if (order == TSDB_ORDER_ASC) { if (order == TSDB_ORDER_ASC) {
pCond->twindows.ekey = window.skey; pCond->twindows.ekey = window.skey;
pCond->twindows.skey = INT64_MIN; pCond->twindows.skey = INT64_MIN;
...@@ -3353,6 +3353,8 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl ...@@ -3353,6 +3353,8 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
pCond->twindows.skey = INT64_MIN; pCond->twindows.skey = INT64_MIN;
pCond->twindows.ekey = window.ekey; pCond->twindows.ekey = window.ekey;
} }
pCond->order = order;
code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[1], 1, idstr); code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[1], 1, idstr);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
goto _err; goto _err;
...@@ -3373,8 +3375,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl ...@@ -3373,8 +3375,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
} }
} }
STsdbReader* p = pReader->innerReader[0] != NULL? pReader->innerReader[0]:pReader;
int32_t numOfTables = taosArrayGetSize(pTableList); int32_t numOfTables = taosArrayGetSize(pTableList);
pReader->status.pTableMap = createDataBlockScanInfo(pReader, pTableList->pData, numOfTables); pReader->status.pTableMap = createDataBlockScanInfo(p, pTableList->pData, numOfTables);
if (pReader->status.pTableMap == NULL) { if (pReader->status.pTableMap == NULL) {
tsdbReaderClose(pReader); tsdbReaderClose(pReader);
*ppReader = NULL; *ppReader = NULL;
...@@ -3541,8 +3545,9 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { ...@@ -3541,8 +3545,9 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
if (pReader->innerReader[0] != NULL && pReader->step == 0) { if (pReader->innerReader[0] != NULL && pReader->step == 0) {
bool ret = doTsdbNextDataBlock(pReader->innerReader[0]); bool ret = doTsdbNextDataBlock(pReader->innerReader[0]);
resetDataBlockScanInfo(pReader->innerReader[0]->status.pTableMap, pReader->innerReader[0]->window.ekey); resetDataBlockScanInfo(pReader->innerReader[0]->status.pTableMap, pReader->innerReader[0]->window.ekey);
pReader->step = EXTERNAL_ROWS_PREV;
if (ret) { if (ret) {
pReader->step = EXTERNAL_ROWS_PREV;
return ret; return ret;
} }
} }
...@@ -3559,8 +3564,8 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { ...@@ -3559,8 +3564,8 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
if (pReader->innerReader[1] != NULL && pReader->step == EXTERNAL_ROWS_MAIN) { if (pReader->innerReader[1] != NULL && pReader->step == EXTERNAL_ROWS_MAIN) {
resetDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey); resetDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey);
bool ret1 = doTsdbNextDataBlock(pReader->innerReader[1]); bool ret1 = doTsdbNextDataBlock(pReader->innerReader[1]);
pReader->step = EXTERNAL_ROWS_NEXT;
if (ret1) { if (ret1) {
pReader->step = EXTERNAL_ROWS_NEXT;
return ret1; return ret1;
} }
} }
......
...@@ -1994,7 +1994,7 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo ...@@ -1994,7 +1994,7 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
} }
} }
pSliceInfo->fillLastPoint = isLastRow ? true : false; pSliceInfo->fillLastPoint = isLastRow;
} }
static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock) { static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock) {
...@@ -2342,6 +2342,9 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { ...@@ -2342,6 +2342,9 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
break; break;
} }
} }
} else {
// store ts value as start, and calculate interp value when processing next block
doKeepLinearInfo(pSliceInfo, pBlock, i, true);
} }
} else { // non-linear interpolation } else { // non-linear interpolation
if (i < pBlock->info.rows - 1) { if (i < pBlock->info.rows - 1) {
...@@ -2420,6 +2423,9 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { ...@@ -2420,6 +2423,9 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
break; break;
} }
} }
} else { // it is the last row of current block
// store ts value as start, and calculate interp value when processing next block
doKeepLinearInfo(pSliceInfo, pBlock, i, true);
} }
} else { // non-linear interpolation } else { // non-linear interpolation
pSliceInfo->current = pSliceInfo->current =
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册