diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index 7e45ffa1df1f8b9814daafeee7a28016eca911e4..a204415d651f0b8f784fc1602133eff3ff378133 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -867,10 +867,16 @@ FIRST(expr) ### INTERP ```sql -INTERP(expr) +INTERP(expr [, ignore_null_values]) + +ignore_null_values: { + 0 + | 1 +} ``` -**Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned. +**Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned. The value of `ignore_null_values` can be 0 or 1, 1 means null values are ignored. The default value of this parameter is 0. + **Return value type**: Same as the column being operated upon diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 458fc9c7a2bd434822c414d80adab69f17ce58b0..248554f931c4b5481c55976fd36a40793c9c3985 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -869,10 +869,15 @@ FIRST(expr) ### INTERP ```sql -INTERP(expr) +INTERP(expr [, ignore_null_values]) + +ignore_null_values: { + 0 + | 1 +} ``` -**功能说明**:返回指定时间截面指定列的记录值或插值。 +**功能说明**:返回指定时间截面指定列的记录值或插值。ignore_null_values 参数的值可以是 0 或 1,为 1 时表示忽略 NULL 值, 缺省值为0。 **返回数据类型**:同字段类型。 diff --git a/source/libs/executor/src/timesliceoperator.c b/source/libs/executor/src/timesliceoperator.c index 4348bce1b8f4af05916429003b1a6ee1194acd8f..432a627957c35d48301e6e2c3f5f2f239076befc 100644 --- a/source/libs/executor/src/timesliceoperator.c +++ b/source/libs/executor/src/timesliceoperator.c @@ -209,6 +209,45 @@ static bool isGroupKeyFunc(SExprInfo* pExprInfo) { return (functionType == FUNCTION_TYPE_GROUP_KEY); } +static bool getIgoreNullRes(SExprSupp* pExprSup) { + for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) { + SExprInfo* pExprInfo = &pExprSup->pExprInfo[i]; + + if (isInterpFunc(pExprInfo)) { + for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) { + SFunctParam *pFuncParam = &pExprInfo->base.pParam[j]; + if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) { + return pFuncParam->param.i ? true : false; + } + } + } + } + + return false; +} + +static bool checkNullRow(SExprSupp* pExprSup, SSDataBlock* pSrcBlock, int32_t index, bool ignoreNull) { + if (!ignoreNull) { + return false; + } + + for (int32_t j = 0; j < pExprSup->numOfExprs; ++j) { + SExprInfo* pExprInfo = &pExprSup->pExprInfo[j]; + + if (isInterpFunc(pExprInfo)) { + int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; + SColumnInfoData* pSrc = taosArrayGet(pSrcBlock->pDataBlock, srcSlot); + + if (colDataIsNull_s(pSrc, index)) { + return true; + } + } + } + + return false; +} + + static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock, SSDataBlock* pSrcBlock, int32_t index, bool beforeTs) { int32_t rows = pResBlock->info.rows; @@ -602,7 +641,7 @@ static int32_t resetKeeperInfo(STimeSliceOperatorInfo* pInfo) { } static void doTimesliceImpl(SOperatorInfo* pOperator, STimeSliceOperatorInfo* pSliceInfo, SSDataBlock* pBlock, - SExecTaskInfo* pTaskInfo) { + SExecTaskInfo* pTaskInfo, bool ignoreNull) { SSDataBlock* pResBlock = pSliceInfo->pRes; SInterval* pInterval = &pSliceInfo->interval; @@ -615,6 +654,10 @@ static void doTimesliceImpl(SOperatorInfo* pOperator, STimeSliceOperatorInfo* pS T_LONG_JMP(pTaskInfo->env, TSDB_CODE_FUNC_DUP_TIMESTAMP); } + if (checkNullRow(&pOperator->exprSupp, pBlock, i, ignoreNull)) { + continue; + } + if (pSliceInfo->current > pSliceInfo->win.ekey) { break; } @@ -744,6 +787,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { STimeSliceOperatorInfo* pSliceInfo = pOperator->info; SSDataBlock* pResBlock = pSliceInfo->pRes; SExprSupp* pSup = &pOperator->exprSupp; + bool ignoreNull = getIgoreNullRes(pSup); int32_t order = TSDB_ORDER_ASC; SInterval* pInterval = &pSliceInfo->interval; @@ -754,7 +798,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { while (1) { if (pSliceInfo->pNextGroupRes != NULL) { setInputDataBlock(pSup, pSliceInfo->pNextGroupRes, order, MAIN_SCAN, true); - doTimesliceImpl(pOperator, pSliceInfo, pSliceInfo->pNextGroupRes, pTaskInfo); + doTimesliceImpl(pOperator, pSliceInfo, pSliceInfo->pNextGroupRes, pTaskInfo, ignoreNull); copyPrevGroupKey(&pOperator->exprSupp, pSliceInfo->pPrevGroupKey, pSliceInfo->pNextGroupRes); pSliceInfo->pNextGroupRes = NULL; } @@ -788,7 +832,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pSup, pBlock, order, MAIN_SCAN, true); - doTimesliceImpl(pOperator, pSliceInfo, pBlock, pTaskInfo); + doTimesliceImpl(pOperator, pSliceInfo, pBlock, pTaskInfo, ignoreNull); copyPrevGroupKey(&pOperator->exprSupp, pSliceInfo->pPrevGroupKey, pBlock); } diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index fe98a1dd537af5fc48b66c431dcfe524fdefe972..752b84b5ad105fcf83b2820327145c3aad8ba5d6 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1568,17 +1568,32 @@ static int32_t translateInterp(SFunctionNode* pFunc, char* pErrBuf, int32_t len) int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList); uint8_t dbPrec = pFunc->node.resType.precision; - // if (1 != numOfParams && 3 != numOfParams && 4 != numOfParams) { - if (1 != numOfParams) { + if (2 < numOfParams) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); } uint8_t nodeType = nodeType(nodesListGetNode(pFunc->pParameterList, 0)); uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if ((!IS_NUMERIC_TYPE(paraType) && !IS_BOOLEAN_TYPE(paraType))|| QUERY_NODE_VALUE == nodeType) { + if ((!IS_NUMERIC_TYPE(paraType) && !IS_BOOLEAN_TYPE(paraType)) || QUERY_NODE_VALUE == nodeType) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } + if (2 == numOfParams) { + nodeType = nodeType(nodesListGetNode(pFunc->pParameterList, 1)); + paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + if (!IS_INTEGER_TYPE(paraType) || QUERY_NODE_VALUE != nodeType) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1); + if (pValue->datum.i != 0 && pValue->datum.i != 1) { + return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, + "INTERP function second parameter should be 0/1"); + } + + pValue->notReserved = true; + } + #if 0 if (3 <= numOfParams) { int64_t timeVal[2] = {0}; @@ -1624,6 +1639,15 @@ static int32_t translateInterp(SFunctionNode* pFunc, char* pErrBuf, int32_t len) return TSDB_CODE_SUCCESS; } +static EFuncReturnRows interpEstReturnRows(SFunctionNode* pFunc) { + int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList); + if (1 < numOfParams && 1 == ((SValueNode*)nodesListGetNode(pFunc->pParameterList, 1))->datum.i) { + return FUNC_RETURN_ROWS_INDEFINITE; + } else { + return FUNC_RETURN_ROWS_N; + } +} + static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { // forbid null as first/last input, since first(c0, null, 1) may have different number of input int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList); @@ -2484,7 +2508,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .getEnvFunc = getSelectivityFuncEnv, .initFunc = functionSetup, .processFunc = NULL, - .finalizeFunc = NULL + .finalizeFunc = NULL, + .estimateReturnRowsFunc = interpEstReturnRows }, { .name = "derivative", diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 2a586a44a2ad7863ed5bbb08159a33ae48eba71e..a8edee4a33f9a315d60901d4920b0a108e72a407 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1526,6 +1526,12 @@ static int32_t translateInterpFunc(STranslateContext* pCxt, SFunctionNode* pFunc if (pSelect->hasAggFuncs || pSelect->hasMultiRowsFunc || pSelect->hasIndefiniteRowsFunc) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); } + + if (pSelect->hasInterpFunc && (FUNC_RETURN_ROWS_INDEFINITE == pSelect->returnRows || pSelect->returnRows != fmGetFuncReturnRows(pFunc))) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, + "%s ignoring null value options cannot be used when applying to multiple columns", pFunc->functionName); + } + if (NULL != pSelect->pWindow || NULL != pSelect->pGroupByList) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, "%s function is not supported in window query or group query", pFunc->functionName); @@ -1726,7 +1732,10 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) { if (fmIsIndefiniteRowsFunc(pFunc->funcId)) { pSelect->hasIndefiniteRowsFunc = true; pSelect->returnRows = fmGetFuncReturnRows(pFunc); + } else if (fmIsInterpFunc(pFunc->funcId)) { + pSelect->returnRows = fmGetFuncReturnRows(pFunc); } + pSelect->hasMultiRowsFunc = pSelect->hasMultiRowsFunc ? true : fmIsMultiRowsFunc(pFunc->funcId); if (fmIsSelectFunc(pFunc->funcId)) { pSelect->hasSelectFunc = true; diff --git a/tests/system-test/2-query/interp.py b/tests/system-test/2-query/interp.py index 6630713f73389f4fabe2f6542f3c89c7da982638..121d4dcff6e3187938b4d1c386fec6ce7f7f3b37 100644 --- a/tests/system-test/2-query/interp.py +++ b/tests/system-test/2-query/interp.py @@ -26,6 +26,12 @@ class TDTestCase: ctbname3 = "ctb3" num_of_ctables = 3 + tbname_null = "tb_null" + ctbname1_null = "ctb1_null" + ctbname2_null = "ctb2_null" + ctbname3_null = "ctb3_null" + stbname_null = "stb_null" + tdSql.prepare() tdLog.printNoPrefix("==========step1:create table") @@ -2943,8 +2949,1075 @@ class TDTestCase: tdSql.error(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname} range('2020-02-01 00:00:00', '2020-02-01 00:00:18') every(1s) fill(null)") tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname} partition by tbname range('2020-02-01 00:00:00', '2020-02-01 00:00:18') every(1s) fill(null)") + tdLog.printNoPrefix("======step 14: test interp ignore null values") + tdSql.execute( + f'''create table if not exists {dbname}.{tbname_null} + (ts timestamp, c0 int, c1 float, c2 bool) + ''' + ) + + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:01', 1, 1.0, true)") + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:02', NULL, NULL, NULL)") + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:03', 3, 3.0, false)") + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:04', NULL, NULL, NULL)") + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:05', NULL, NULL, NULL)") + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:06', 6, 6.0, true)") + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:07', NULL, NULL, NULL)") + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:08', 8, 8.0, false)") + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:09', 9, 9.0, true)") + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:10', NULL, NULL, NULL)") + tdSql.execute(f"insert into {dbname}.{tbname_null} values ('2020-02-02 00:00:11', NULL, NULL, NULL)") + + tdSql.execute( + f'''create table if not exists {dbname}.{stbname_null} + (ts timestamp, c0 int, c1 float, c2 bool) tags (t0 int) + ''' + ) + + tdSql.execute( + f'''create table if not exists {dbname}.{ctbname1_null} using {dbname}.{stbname_null} tags(1) + ''' + ) + + tdSql.execute( + f'''create table if not exists {dbname}.{ctbname2_null} using {dbname}.{stbname_null} tags(2) + ''' + ) + + tdSql.execute( + f'''create table if not exists {dbname}.{ctbname3_null} using {dbname}.{stbname_null} tags(3) + ''' + ) + + tdSql.execute(f"insert into {dbname}.{ctbname1_null} values ('2020-02-01 00:00:01', 1, 1.0, true)") + tdSql.execute(f"insert into {dbname}.{ctbname1_null} values ('2020-02-01 00:00:07', NULL, NULL, NULL)") + tdSql.execute(f"insert into {dbname}.{ctbname1_null} values ('2020-02-01 00:00:13', 13, 13.0, false)") + + tdSql.execute(f"insert into {dbname}.{ctbname2_null} values ('2020-02-01 00:00:03', NULL, NULL, NULL)") + tdSql.execute(f"insert into {dbname}.{ctbname2_null} values ('2020-02-01 00:00:09', 9, 9.0, true)") + tdSql.execute(f"insert into {dbname}.{ctbname2_null} values ('2020-02-01 00:00:15', 15, 15.0, false)") + + tdSql.execute(f"insert into {dbname}.{ctbname3_null} values ('2020-02-01 00:00:05', NULL, NULL, NULL)") + tdSql.execute(f"insert into {dbname}.{ctbname3_null} values ('2020-02-01 00:00:11', NULL, NULL, NULL)") + tdSql.execute(f"insert into {dbname}.{ctbname3_null} values ('2020-02-01 00:00:17', NULL, NULL, NULL)") + + # fill null + # normal table + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(NULL)") + + tdSql.checkRows(11) + for i in range (11): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(NULL)") + + tdSql.checkRows(11) + for i in range (11): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 1) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(NULL)") + + tdSql.checkRows(11) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, False) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, True) + tdSql.checkData(5, 1, False) + tdSql.checkData(6, 1, True) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, False) + tdSql.checkData(9, 1, True) + tdSql.checkData(10, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{tbname_null} where c0 is not null range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(NULL)") + + tdSql.checkRows(11) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, False) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, True) + tdSql.checkData(5, 1, False) + tdSql.checkData(6, 1, True) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, False) + tdSql.checkData(9, 1, True) + tdSql.checkData(10, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + # super table + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(NULL)") + + tdSql.checkRows(9) + for i in range (9): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(NULL)") + + tdSql.checkRows(9) + for i in range (9): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 1) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(NULL)") + + tdSql.checkRows(9) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, True) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, False) + tdSql.checkData(5, 1, True) + tdSql.checkData(6, 1, False) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} where c0 is not null range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(NULL)") + + tdSql.checkRows(9) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, True) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, False) + tdSql.checkData(5, 1, True) + tdSql.checkData(6, 1, False) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select tbname, _irowts, _isfilled, interp(c0, 1) from {dbname}.{stbname_null} partition by tbname range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(NULL)") + + tdSql.checkRows(27) + for i in range(0, 9): + tdSql.checkData(i, 0, 'ctb1_null') + + for i in range(9, 18): + tdSql.checkData(i, 0, 'ctb2_null') + + for i in range(18, 27): + tdSql.checkData(i, 0, 'ctb3_null') + + tdSql.checkData(0, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(8, 1, '2020-02-01 00:00:17.000') + + tdSql.checkData(9, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(17, 1, '2020-02-01 00:00:17.000') + + tdSql.checkData(18, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(26, 1, '2020-02-01 00:00:17.000') + + tdSql.query(f"select tbname, _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} where c0 is not null partition by tbname range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(NULL)") + + tdSql.checkRows(18) + for i in range(0, 9): + tdSql.checkData(i, 0, 'ctb1_null') + + for i in range(9, 17): + tdSql.checkData(i, 0, 'ctb2_null') + + tdSql.checkData(0, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(8, 1, '2020-02-01 00:00:17.000') + + tdSql.checkData(9, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(17, 1, '2020-02-01 00:00:17.000') + + # fill value + # normal table + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(value, 0)") + + tdSql.checkRows(11) + for i in range (11): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(value, 0)") + + tdSql.checkRows(11) + for i in range (11): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 1) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(value, 0)") + + tdSql.checkRows(11) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, False) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, True) + tdSql.checkData(5, 1, False) + tdSql.checkData(6, 1, True) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, False) + tdSql.checkData(9, 1, True) + tdSql.checkData(10, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 0) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, 0) + tdSql.checkData(4, 2, 0) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, 0) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, 0) + tdSql.checkData(10, 2, 0) + + + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{tbname_null} where c0 is not null range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(value, 0)") + + tdSql.checkRows(11) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, False) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, True) + tdSql.checkData(5, 1, False) + tdSql.checkData(6, 1, True) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, False) + tdSql.checkData(9, 1, True) + tdSql.checkData(10, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 0) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, 0) + tdSql.checkData(4, 2, 0) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, 0) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, 0) + tdSql.checkData(10, 2, 0) + + # super table + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(value, 0)") + + tdSql.checkRows(9) + for i in range (9): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(value, 0)") + + tdSql.checkRows(9) + for i in range (9): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 1) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(value, 0)") + + tdSql.checkRows(9) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, True) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, False) + tdSql.checkData(5, 1, True) + tdSql.checkData(6, 1, False) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 0) + tdSql.checkData(2, 2, 0) + tdSql.checkData(3, 2, 0) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, 0) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, 0) + + + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} where c0 is not null range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(value, 0)") + + tdSql.checkRows(9) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, True) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, False) + tdSql.checkData(5, 1, True) + tdSql.checkData(6, 1, False) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 0) + tdSql.checkData(2, 2, 0) + tdSql.checkData(3, 2, 0) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, 0) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, 0) + + tdSql.query(f"select tbname, _irowts, _isfilled, interp(c0, 1) from {dbname}.{stbname_null} partition by tbname range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(value, 0)") + + tdSql.checkRows(27) + for i in range(0, 9): + tdSql.checkData(i, 0, 'ctb1_null') + + for i in range(9, 18): + tdSql.checkData(i, 0, 'ctb2_null') + + for i in range(18, 27): + tdSql.checkData(i, 0, 'ctb3_null') + + tdSql.checkData(0, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(8, 1, '2020-02-01 00:00:17.000') + + tdSql.checkData(9, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(17, 1, '2020-02-01 00:00:17.000') + + tdSql.checkData(18, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(26, 1, '2020-02-01 00:00:17.000') + + tdSql.query(f"select tbname, _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} where c0 is not null partition by tbname range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(value, 0)") + + tdSql.checkRows(18) + for i in range(0, 9): + tdSql.checkData(i, 0, 'ctb1_null') + + for i in range(9, 18): + tdSql.checkData(i, 0, 'ctb2_null') + + tdSql.checkData(0, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(8, 1, '2020-02-01 00:00:17.000') + + tdSql.checkData(9, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(17, 1, '2020-02-01 00:00:17.000') + + # fill prev + # normal table + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(prev)") + + tdSql.checkRows(11) + for i in range (11): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(prev)") + + tdSql.checkRows(11) + for i in range (11): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 1) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(prev)") + + tdSql.checkRows(11) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, False) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, True) + tdSql.checkData(5, 1, False) + tdSql.checkData(6, 1, True) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, False) + tdSql.checkData(9, 1, True) + tdSql.checkData(10, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 1) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, 3) + tdSql.checkData(4, 2, 3) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, 6) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, 9) + tdSql.checkData(10, 2, 9) + + + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{tbname_null} where c0 is not null range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(prev)") + + tdSql.checkRows(11) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, False) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, True) + tdSql.checkData(5, 1, False) + tdSql.checkData(6, 1, True) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, False) + tdSql.checkData(9, 1, True) + tdSql.checkData(10, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 1) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, 3) + tdSql.checkData(4, 2, 3) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, 6) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, 9) + tdSql.checkData(10, 2, 9) + + # super table + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(prev)") + + tdSql.checkRows(9) + for i in range (9): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(prev)") + + tdSql.checkRows(9) + for i in range (9): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 1) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(prev)") + + tdSql.checkRows(9) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, True) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, False) + tdSql.checkData(5, 1, True) + tdSql.checkData(6, 1, False) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 1) + tdSql.checkData(2, 2, 1) + tdSql.checkData(3, 2, 1) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, 9) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, 15) + + + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} where c0 is not null range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(prev)") + + tdSql.checkRows(9) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, True) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, False) + tdSql.checkData(5, 1, True) + tdSql.checkData(6, 1, False) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, True) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 1) + tdSql.checkData(2, 2, 1) + tdSql.checkData(3, 2, 1) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, 9) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, 15) + + tdSql.query(f"select tbname, _irowts, _isfilled, interp(c0, 1) from {dbname}.{stbname_null} partition by tbname range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(prev)") + + tdSql.checkRows(14) + for i in range(0, 9): + tdSql.checkData(i, 0, 'ctb1_null') + + for i in range(9, 13): + tdSql.checkData(i, 0, 'ctb2_null') + + tdSql.checkData(0, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(8, 1, '2020-02-01 00:00:17.000') + + tdSql.checkData(9, 1, '2020-02-01 00:00:09.000') + tdSql.checkData(13, 1, '2020-02-01 00:00:17.000') + + tdSql.query(f"select tbname, _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} where c0 is not null partition by tbname range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(prev)") + + tdSql.checkRows(14) + for i in range(0, 9): + tdSql.checkData(i, 0, 'ctb1_null') + + for i in range(9, 13): + tdSql.checkData(i, 0, 'ctb2_null') + + tdSql.checkData(0, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(8, 1, '2020-02-01 00:00:17.000') + + tdSql.checkData(9, 1, '2020-02-01 00:00:09.000') + tdSql.checkData(13, 1, '2020-02-01 00:00:17.000') + + # fill next + # normal table + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(next)") + + tdSql.checkRows(11) + for i in range (11): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(next)") + + tdSql.checkRows(11) + for i in range (11): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 1) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(next)") + + tdSql.checkRows(9) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, False) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, True) + tdSql.checkData(5, 1, False) + tdSql.checkData(6, 1, True) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 3) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, 6) + tdSql.checkData(4, 2, 6) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, 8) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + + + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{tbname_null} where c0 is not null range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(next)") + + tdSql.checkRows(9) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, False) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, True) + tdSql.checkData(5, 1, False) + tdSql.checkData(6, 1, True) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 3) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, 6) + tdSql.checkData(4, 2, 6) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, 8) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + + # super table + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(next)") + + tdSql.checkRows(9) + for i in range (9): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(next)") + + tdSql.checkRows(9) + for i in range (9): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 1) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(next)") + + tdSql.checkRows(8) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, True) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, False) + tdSql.checkData(5, 1, True) + tdSql.checkData(6, 1, False) + tdSql.checkData(7, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 9) + tdSql.checkData(2, 2, 9) + tdSql.checkData(3, 2, 9) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, 13) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + + + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} where c0 is not null range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(next)") + + tdSql.checkRows(8) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, True) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, False) + tdSql.checkData(5, 1, True) + tdSql.checkData(6, 1, False) + tdSql.checkData(7, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 9) + tdSql.checkData(2, 2, 9) + tdSql.checkData(3, 2, 9) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, 13) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + + tdSql.query(f"select tbname, _irowts, _isfilled, interp(c0, 1) from {dbname}.{stbname_null} partition by tbname range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(next)") + + tdSql.checkRows(15) + for i in range(0, 7): + tdSql.checkData(i, 0, 'ctb1_null') + + for i in range(7, 15): + tdSql.checkData(i, 0, 'ctb2_null') + + tdSql.checkData(0, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(6, 1, '2020-02-01 00:00:13.000') + + tdSql.checkData(7, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(14, 1, '2020-02-01 00:00:15.000') + + tdSql.query(f"select tbname, _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} where c0 is not null partition by tbname range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(next)") + + tdSql.checkRows(15) + for i in range(0, 7): + tdSql.checkData(i, 0, 'ctb1_null') + + for i in range(7, 15): + tdSql.checkData(i, 0, 'ctb2_null') + + tdSql.checkData(0, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(6, 1, '2020-02-01 00:00:13.000') + + tdSql.checkData(7, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(14, 1, '2020-02-01 00:00:15.000') + + # fill linear + # normal table + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(linear)") + + tdSql.checkRows(11) + for i in range (11): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(linear)") + + tdSql.checkRows(11) + for i in range (11): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + tdSql.checkData(9, 2, None) + tdSql.checkData(10, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 1) from {dbname}.{tbname_null} range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(linear)") + + tdSql.checkRows(9) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, False) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, True) + tdSql.checkData(5, 1, False) + tdSql.checkData(6, 1, True) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 2) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, 4) + tdSql.checkData(4, 2, 5) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, 7) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + + + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{tbname_null} where c0 is not null range('2020-02-02 00:00:01', '2020-02-02 00:00:11') every(1s) fill(linear)") + + tdSql.checkRows(9) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, False) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, True) + tdSql.checkData(5, 1, False) + tdSql.checkData(6, 1, True) + tdSql.checkData(7, 1, False) + tdSql.checkData(8, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 2) + tdSql.checkData(2, 2, 3) + tdSql.checkData(3, 2, 4) + tdSql.checkData(4, 2, 5) + tdSql.checkData(5, 2, 6) + tdSql.checkData(6, 2, 7) + tdSql.checkData(7, 2, 8) + tdSql.checkData(8, 2, 9) + + # super table + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + + tdSql.checkRows(9) + for i in range (9): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + + tdSql.checkRows(9) + for i in range (9): + tdSql.checkData(i, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, None) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, None) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, None) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + tdSql.checkData(8, 2, None) + + tdSql.query(f"select _irowts, _isfilled, interp(c0, 1) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + + tdSql.checkRows(8) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, True) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, False) + tdSql.checkData(5, 1, True) + tdSql.checkData(6, 1, False) + tdSql.checkData(7, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 3) + tdSql.checkData(2, 2, 5) + tdSql.checkData(3, 2, 7) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, 11) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + + + tdSql.query(f"select _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} where c0 is not null range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + + tdSql.checkRows(8) + tdSql.checkData(0, 1, False) + tdSql.checkData(1, 1, True) + tdSql.checkData(2, 1, True) + tdSql.checkData(3, 1, True) + tdSql.checkData(4, 1, False) + tdSql.checkData(5, 1, True) + tdSql.checkData(6, 1, False) + tdSql.checkData(7, 1, False) + + tdSql.checkData(0, 2, 1) + tdSql.checkData(1, 2, 3) + tdSql.checkData(2, 2, 5) + tdSql.checkData(3, 2, 7) + tdSql.checkData(4, 2, 9) + tdSql.checkData(5, 2, 11) + tdSql.checkData(6, 2, 13) + tdSql.checkData(7, 2, 15) + + tdSql.query(f"select tbname, _irowts, _isfilled, interp(c0, 1) from {dbname}.{stbname_null} partition by tbname range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + + tdSql.checkRows(11) + for i in range(0, 7): + tdSql.checkData(i, 0, 'ctb1_null') + + for i in range(7, 11): + tdSql.checkData(i, 0, 'ctb2_null') + + tdSql.checkData(0, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(6, 1, '2020-02-01 00:00:13.000') + + tdSql.checkData(7, 1, '2020-02-01 00:00:09.000') + tdSql.checkData(10, 1, '2020-02-01 00:00:15.000') + + tdSql.query(f"select tbname, _irowts, _isfilled, interp(c0) from {dbname}.{stbname_null} where c0 is not null partition by tbname range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + + tdSql.checkRows(11) + for i in range(0, 7): + tdSql.checkData(i, 0, 'ctb1_null') + + for i in range(7, 11): + tdSql.checkData(i, 0, 'ctb2_null') + + tdSql.checkData(0, 1, '2020-02-01 00:00:01.000') + tdSql.checkData(6, 1, '2020-02-01 00:00:13.000') + + tdSql.checkData(7, 1, '2020-02-01 00:00:09.000') + tdSql.checkData(10, 1, '2020-02-01 00:00:15.000') + + # multiple column with ignoring null value is not allowed + + tdSql.query(f"select _irowts, _isfilled, interp(c0), interp(c1), interp(c2) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + tdSql.query(f"select _irowts, _isfilled, interp(c0, 0), interp(c1, 0), interp(c2, 0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + tdSql.query(f"select _irowts, _isfilled, interp(c0), interp(c1, 0), interp(c2) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + + tdSql.error(f"select _irowts, _isfilled, interp(c0), interp(c1, 1), interp(c2) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + tdSql.error(f"select _irowts, _isfilled, interp(c0, 1), interp(c1, 0), interp(c2, 0) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + tdSql.error(f"select _irowts, _isfilled, interp(c0), interp(c1, 0), interp(c2, 1) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + tdSql.error(f"select _irowts, _isfilled, interp(c0, 1), interp(c1, 1), interp(c2, 1) from {dbname}.{stbname_null} range('2020-02-01 00:00:01', '2020-02-01 00:00:17') every(2s) fill(linear)") + + - tdLog.printNoPrefix("======step 14: test interp pseudo columns") + tdLog.printNoPrefix("======step 15: test interp pseudo columns") tdSql.error(f"select _irowts, c6 from {dbname}.{tbname}") tdLog.printNoPrefix("======step 15: test interp in nested query")