fix interp stable query issue
This commit is contained in:
parent
356018a990
commit
d8622364aa
|
@ -2812,7 +2812,6 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
|
|||
pParentSql->self, pState->numOfSub, pState->numOfRetrievedRows);
|
||||
|
||||
SQueryInfo *pPQueryInfo = tscGetQueryInfo(&pParentSql->cmd);
|
||||
tscClearInterpInfo(pPQueryInfo);
|
||||
|
||||
code = tscCreateGlobalMerger(trsupport->pExtMemBuffer, pState->numOfSub, pDesc, pPQueryInfo, &pParentSql->res.pMerger, pParentSql->self);
|
||||
pParentSql->res.code = code;
|
||||
|
|
|
@ -3670,6 +3670,8 @@ static void interp_function_impl(SQLFunctionCtx *pCtx) {
|
|||
return;
|
||||
}
|
||||
|
||||
bool ascQuery = (pCtx->order == TSDB_ORDER_ASC);
|
||||
|
||||
if (pCtx->inputType == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
*(TSKEY *)pCtx->pOutput = pCtx->startTs;
|
||||
} else if (type == TSDB_FILL_NULL) {
|
||||
|
@ -3677,7 +3679,7 @@ static void interp_function_impl(SQLFunctionCtx *pCtx) {
|
|||
} else if (type == TSDB_FILL_SET_VALUE) {
|
||||
tVariantDump(&pCtx->param[1], pCtx->pOutput, pCtx->inputType, true);
|
||||
} else {
|
||||
if (pCtx->start.key != INT64_MIN && pCtx->start.key < pCtx->startTs && pCtx->end.key > pCtx->startTs) {
|
||||
if (pCtx->start.key != INT64_MIN && ((ascQuery && pCtx->start.key <= pCtx->startTs && pCtx->end.key >= pCtx->startTs) || ((!ascQuery) && pCtx->start.key >= pCtx->startTs && pCtx->end.key <= pCtx->startTs))) {
|
||||
if (type == TSDB_FILL_PREV) {
|
||||
if (IS_NUMERIC_TYPE(pCtx->inputType) || pCtx->inputType == TSDB_DATA_TYPE_BOOL) {
|
||||
SET_TYPED_DATA(pCtx->pOutput, pCtx->inputType, pCtx->start.val);
|
||||
|
@ -3716,13 +3718,14 @@ static void interp_function_impl(SQLFunctionCtx *pCtx) {
|
|||
TSKEY skey = GET_TS_DATA(pCtx, 0);
|
||||
|
||||
if (type == TSDB_FILL_PREV) {
|
||||
if (skey > pCtx->startTs) {
|
||||
if ((ascQuery && skey > pCtx->startTs) || ((!ascQuery) && skey < pCtx->startTs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pCtx->size > 1) {
|
||||
TSKEY ekey = GET_TS_DATA(pCtx, 1);
|
||||
if (ekey > skey && ekey <= pCtx->startTs) {
|
||||
if ((ascQuery && ekey > skey && ekey <= pCtx->startTs) ||
|
||||
((!ascQuery) && ekey < skey && ekey >= pCtx->startTs)){
|
||||
skey = ekey;
|
||||
}
|
||||
}
|
||||
|
@ -3731,10 +3734,10 @@ static void interp_function_impl(SQLFunctionCtx *pCtx) {
|
|||
TSKEY ekey = skey;
|
||||
char* val = NULL;
|
||||
|
||||
if (ekey < pCtx->startTs) {
|
||||
if ((ascQuery && ekey < pCtx->startTs) || ((!ascQuery) && ekey > pCtx->startTs)) {
|
||||
if (pCtx->size > 1) {
|
||||
ekey = GET_TS_DATA(pCtx, 1);
|
||||
if (ekey < pCtx->startTs) {
|
||||
if ((ascQuery && ekey < pCtx->startTs) || ((!ascQuery) && ekey > pCtx->startTs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3755,12 +3758,11 @@ static void interp_function_impl(SQLFunctionCtx *pCtx) {
|
|||
TSKEY ekey = GET_TS_DATA(pCtx, 1);
|
||||
|
||||
// no data generated yet
|
||||
if (!(skey < pCtx->startTs && ekey > pCtx->startTs)) {
|
||||
if ((ascQuery && !(skey <= pCtx->startTs && ekey >= pCtx->startTs))
|
||||
|| ((!ascQuery) && !(skey >= pCtx->startTs && ekey <= pCtx->startTs))) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(pCtx->start.key == INT64_MIN && skey < pCtx->startTs && ekey > pCtx->startTs);
|
||||
|
||||
char *start = GET_INPUT_DATA(pCtx, 0);
|
||||
char *end = GET_INPUT_DATA(pCtx, 1);
|
||||
|
||||
|
|
|
@ -1595,6 +1595,7 @@ static void hashAllIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
|||
SResultRow* pResult = NULL;
|
||||
int32_t forwardStep = 0;
|
||||
int32_t ret = 0;
|
||||
STimeWindow preWin = win;
|
||||
|
||||
while (1) {
|
||||
// null data, failed to allocate more memory buffer
|
||||
|
@ -1609,12 +1610,13 @@ static void hashAllIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
|||
|
||||
// window start(end) key interpolation
|
||||
doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->pCtx, pResult, &win, startPos, forwardStep);
|
||||
doApplyFunctions(pRuntimeEnv, pInfo->pCtx, &win, startPos, forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput);
|
||||
|
||||
doApplyFunctions(pRuntimeEnv, pInfo->pCtx, ascQuery ? &win : &preWin, startPos, forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput);
|
||||
preWin = win;
|
||||
|
||||
int32_t prevEndPos = (forwardStep - 1) * step + startPos;
|
||||
startPos = getNextQualifiedWindow(pQueryAttr, &win, &pSDataBlock->info, tsCols, binarySearchForKey, prevEndPos);
|
||||
if (startPos < 0) {
|
||||
if (win.skey <= pQueryAttr->window.ekey) {
|
||||
if ((ascQuery && win.skey <= pQueryAttr->window.ekey) || ((!ascQuery) && win.ekey >= pQueryAttr->window.ekey)) {
|
||||
int32_t code = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, tableGroupId,
|
||||
pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset);
|
||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
|
@ -1625,7 +1627,7 @@ static void hashAllIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
|||
|
||||
// window start(end) key interpolation
|
||||
doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->pCtx, pResult, &win, startPos, forwardStep);
|
||||
doApplyFunctions(pRuntimeEnv, pInfo->pCtx, &win, startPos, forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput);
|
||||
doApplyFunctions(pRuntimeEnv, pInfo->pCtx, ascQuery ? &win : &preWin, startPos, forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -693,7 +693,7 @@ SArray* createGlobalMergePlan(SQueryAttr* pQueryAttr) {
|
|||
}
|
||||
|
||||
// fill operator
|
||||
if (pQueryAttr->fillType != TSDB_FILL_NONE && (!pQueryAttr->pointInterpQuery)) {
|
||||
if (pQueryAttr->fillType != TSDB_FILL_NONE && pQueryAttr->interval.interval > 0) {
|
||||
op = OP_Fill;
|
||||
taosArrayPush(plan, &op);
|
||||
}
|
||||
|
|
|
@ -930,8 +930,254 @@ if $data44 != @18-11-25 19:06:00.000@ then
|
|||
endi
|
||||
|
||||
|
||||
sql select interp(c1) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:42:00.000' interval(1m) fill(linear);
|
||||
if $rows != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 20:35:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @18-09-17 20:36:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @18-09-17 20:37:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data21 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @18-09-17 20:38:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data40 != @18-09-17 20:39:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data50 != @18-09-17 20:40:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data51 != 0 then
|
||||
return -1
|
||||
endi
|
||||
if $data60 != @18-09-17 20:41:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data61 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data70 != @18-09-17 20:42:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data71 != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
sql select interp(c1) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:42:00.000' interval(1m) fill(linear) order by ts desc;
|
||||
if $rows != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 20:42:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @18-09-17 20:41:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @18-09-17 20:40:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data21 != 0 then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @18-09-17 20:39:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data40 != @18-09-17 20:38:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data50 != @18-09-17 20:37:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data51 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data60 != @18-09-17 20:36:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data61 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data70 != @18-09-17 20:35:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data71 != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' interval(2m) fill(linear) order by ts;
|
||||
if $rows != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 20:34:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @18-09-17 20:36:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @18-09-17 20:38:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data21 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @18-09-17 20:40:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != 0.00000 then
|
||||
return -1
|
||||
endi
|
||||
if $data40 != @18-09-17 20:42:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != 0.20000 then
|
||||
return -1
|
||||
endi
|
||||
if $data50 != @18-09-17 20:44:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data51 != 0.40000 then
|
||||
return -1
|
||||
endi
|
||||
if $data60 != @18-09-17 20:46:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data61 != 0.60000 then
|
||||
return -1
|
||||
endi
|
||||
if $data70 != @18-09-17 20:48:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data71 != 0.80000 then
|
||||
return -1
|
||||
endi
|
||||
if $data80 != @18-09-17 20:50:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data81 != 1.00000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' interval(3m) fill(linear) order by ts;
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 20:33:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @18-09-17 20:36:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @18-09-17 20:39:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data21 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @18-09-17 20:42:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != 0.20000 then
|
||||
return -1
|
||||
endi
|
||||
if $data40 != @18-09-17 20:45:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != 0.50000 then
|
||||
return -1
|
||||
endi
|
||||
if $data50 != @18-09-17 20:48:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data51 != 0.80000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' interval(3m) fill(linear) order by ts desc;
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 20:48:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 0.80000 then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @18-09-17 20:45:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != 0.50000 then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @18-09-17 20:42:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data21 != 0.20000 then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @18-09-17 20:39:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data40 != @18-09-17 20:36:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data50 != @18-09-17 20:33:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data51 != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue