Merge pull request #26711 from taosdata/fix/TS-5181/interp_crash

fix: interp crash
This commit is contained in:
dapan1121 2024-07-23 10:23:26 +08:00 committed by GitHub
commit 26c7943279
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 356 additions and 17 deletions

View File

@ -138,6 +138,7 @@ typedef enum EFunctionType {
FUNCTION_TYPE_CACHE_LAST_ROW, FUNCTION_TYPE_CACHE_LAST_ROW,
FUNCTION_TYPE_CACHE_LAST, FUNCTION_TYPE_CACHE_LAST,
FUNCTION_TYPE_TABLE_COUNT, FUNCTION_TYPE_TABLE_COUNT,
FUNCTION_TYPE_GROUP_CONST_VALUE,
// distributed splitting functions // distributed splitting functions
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000, FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
@ -256,6 +257,7 @@ bool fmIsConstantResFunc(SFunctionNode* pFunc);
bool fmIsSkipScanCheckFunc(int32_t funcId); bool fmIsSkipScanCheckFunc(int32_t funcId);
bool fmIsPrimaryKeyFunc(int32_t funcId); bool fmIsPrimaryKeyFunc(int32_t funcId);
bool fmIsProcessByRowFunc(int32_t funcId); bool fmIsProcessByRowFunc(int32_t funcId);
bool fmisSelectGroupConstValueFunc(int32_t funcId);
void getLastCacheDataType(SDataType* pType, int32_t pkBytes); void getLastCacheDataType(SDataType* pType, int32_t pkBytes);
SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList); SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList);

View File

@ -1627,7 +1627,8 @@ static int32_t setSelectValueColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutpu
SHashObj* pSelectFuncs = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); SHashObj* pSelectFuncs = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
for (int32_t i = 0; i < numOfOutput; ++i) { for (int32_t i = 0; i < numOfOutput; ++i) {
const char* pName = pCtx[i].pExpr->pExpr->_function.functionName; const char* pName = pCtx[i].pExpr->pExpr->_function.functionName;
if ((strcmp(pName, "_select_value") == 0) || (strcmp(pName, "_group_key") == 0)) { if ((strcmp(pName, "_select_value") == 0) || (strcmp(pName, "_group_key") == 0)
|| (strcmp(pName, "_group_const_value") == 0)) {
pValCtx[num++] = &pCtx[i]; pValCtx[num++] = &pCtx[i];
} else if (fmIsSelectFunc(pCtx[i].functionId)) { } else if (fmIsSelectFunc(pCtx[i].functionId)) {
void* data = taosHashGet(pSelectFuncs, pName, strlen(pName)); void* data = taosHashGet(pSelectFuncs, pName, strlen(pName));

View File

@ -638,7 +638,8 @@ void copyResultrowToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SResultR
pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset); pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
if (pCtx[j].fpSet.finalize) { if (pCtx[j].fpSet.finalize) {
if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_key") == 0) { if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_key") == 0 ||
strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_const_value") == 0) {
// for groupkey along with functions that output multiple lines(e.g. Histogram) // for groupkey along with functions that output multiple lines(e.g. Histogram)
// need to match groupkey result for each output row of that function. // need to match groupkey result for each output row of that function.
if (pCtx[j].resultInfo->numOfRes != 0) { if (pCtx[j].resultInfo->numOfRes != 0) {

View File

@ -233,6 +233,11 @@ static bool isGroupKeyFunc(SExprInfo* pExprInfo) {
return (functionType == FUNCTION_TYPE_GROUP_KEY); return (functionType == FUNCTION_TYPE_GROUP_KEY);
} }
static bool isSelectGroupConstValueFunc(SExprInfo* pExprInfo) {
int32_t functionType = pExprInfo->pExpr->_function.functionType;
return (functionType == FUNCTION_TYPE_GROUP_CONST_VALUE);
}
static bool getIgoreNullRes(SExprSupp* pExprSup) { static bool getIgoreNullRes(SExprSupp* pExprSup) {
for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) { for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) {
SExprInfo* pExprInfo = &pExprSup->pExprInfo[i]; SExprInfo* pExprInfo = &pExprSup->pExprInfo[i];
@ -296,7 +301,7 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
colDataSetVal(pDst, pResBlock->info.rows, (char*)&isFilled, false); colDataSetVal(pDst, pResBlock->info.rows, (char*)&isFilled, false);
continue; continue;
} else if (!isInterpFunc(pExprInfo)) { } else if (!isInterpFunc(pExprInfo)) {
if (isGroupKeyFunc(pExprInfo)) { if (isGroupKeyFunc(pExprInfo) || isSelectGroupConstValueFunc(pExprInfo)) {
if (pSrcBlock != NULL) { if (pSrcBlock != NULL) {
int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId;
SColumnInfoData* pSrc = taosArrayGet(pSrcBlock->pDataBlock, srcSlot); SColumnInfoData* pSrc = taosArrayGet(pSrcBlock->pDataBlock, srcSlot);
@ -308,7 +313,7 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
char* v = colDataGetData(pSrc, index); char* v = colDataGetData(pSrc, index);
colDataSetVal(pDst, pResBlock->info.rows, v, false); colDataSetVal(pDst, pResBlock->info.rows, v, false);
} else { } else if(!isSelectGroupConstValueFunc(pExprInfo)){
// use stored group key // use stored group key
SGroupKeys* pkey = pSliceInfo->pPrevGroupKey; SGroupKeys* pkey = pSliceInfo->pPrevGroupKey;
if (pkey->isNull == false) { if (pkey->isNull == false) {
@ -316,6 +321,14 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
} else { } else {
colDataSetNULL(pDst, rows); colDataSetNULL(pDst, rows);
} }
} else {
int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId;
SGroupKeys* pkey = taosArrayGet(pSliceInfo->pPrevRow, srcSlot);
if (pkey->isNull == false) {
colDataSetVal(pDst, rows, pkey->pData, false);
} else {
colDataSetNULL(pDst, rows);
}
} }
} }
continue; continue;

View File

@ -254,6 +254,8 @@ bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv);
int32_t groupKeyFunction(SqlFunctionCtx* pCtx); int32_t groupKeyFunction(SqlFunctionCtx* pCtx);
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
int32_t groupConstValueFunction(SqlFunctionCtx* pCtx);
int32_t groupConstValueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -4108,6 +4108,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.sprocessFunc = md5Function, .sprocessFunc = md5Function,
.finalizeFunc = NULL .finalizeFunc = NULL
}, },
{
.name = "_group_const_value",
.type = FUNCTION_TYPE_GROUP_CONST_VALUE,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
.translateFunc = translateSelectValue,
.getEnvFunc = getSelectivityFuncEnv,
.initFunc = functionSetup,
.processFunc = groupConstValueFunction,
.finalizeFunc = groupConstValueFinalize,
},
}; };
// clang-format on // clang-format on

View File

@ -6615,7 +6615,7 @@ int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
return pResInfo->numOfRes; return pResInfo->numOfRes;
} }
int32_t groupKeyFunction(SqlFunctionCtx* pCtx) { int32_t groupConstValueFunction(SqlFunctionCtx* pCtx) {
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
@ -6626,13 +6626,13 @@ int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
// escape rest of data blocks to avoid first entry to be overwritten. // escape rest of data blocks to avoid first entry to be overwritten.
if (pInfo->hasResult) { if (pInfo->hasResult) {
goto _group_key_over; goto _group_value_over;
} }
if (pInputCol->pData == NULL || colDataIsNull_s(pInputCol, startIndex)) { if (pInputCol->pData == NULL || colDataIsNull_s(pInputCol, startIndex)) {
pInfo->isNull = true; pInfo->isNull = true;
pInfo->hasResult = true; pInfo->hasResult = true;
goto _group_key_over; goto _group_value_over;
} }
char* data = colDataGetData(pInputCol, startIndex); char* data = colDataGetData(pInputCol, startIndex);
@ -6644,13 +6644,17 @@ int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
} }
pInfo->hasResult = true; pInfo->hasResult = true;
_group_key_over: _group_value_over:
SET_VAL(pResInfo, 1, 1); SET_VAL(pResInfo, 1, 1);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
return groupConstValueFunction(pCtx);
}
int32_t groupConstValueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
int32_t slotId = pCtx->pExpr->base.resSchema.slotId; int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
@ -6670,6 +6674,10 @@ int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
return pResInfo->numOfRes; return pResInfo->numOfRes;
} }
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock){
return groupConstValueFinalize(pCtx, pBlock);
}
int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
SGroupKeyInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); SGroupKeyInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo);

View File

@ -268,6 +268,13 @@ bool fmIsGroupKeyFunc(int32_t funcId) {
return FUNCTION_TYPE_GROUP_KEY == funcMgtBuiltins[funcId].type; return FUNCTION_TYPE_GROUP_KEY == funcMgtBuiltins[funcId].type;
} }
bool fmisSelectGroupConstValueFunc(int32_t funcId) {
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
return false;
}
return FUNCTION_TYPE_GROUP_CONST_VALUE == funcMgtBuiltins[funcId].type;
}
bool fmIsBlockDistFunc(int32_t funcId) { bool fmIsBlockDistFunc(int32_t funcId) {
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
return false; return false;

View File

@ -3162,6 +3162,25 @@ static EDealRes rewriteExprToGroupKeyFunc(STranslateContext* pCxt, SNode** pNode
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR); return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
} }
static EDealRes rewriteExprToSelectTagFunc(STranslateContext* pCxt, SNode** pNode) {
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
if (NULL == pFunc) {
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
return DEAL_RES_ERROR;
}
strcpy(pFunc->functionName, "_group_const_value");
strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName);
strcpy(pFunc->node.userAlias, ((SExprNode*)*pNode)->userAlias);
pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode);
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
*pNode = (SNode*)pFunc;
pCxt->errCode = fmGetFuncInfo(pFunc, pCxt->msgBuf.buf, pCxt->msgBuf.len);
}
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
}
static bool isWindowJoinProbeTablePrimCol(SSelectStmt* pSelect, SNode* pNode) { static bool isWindowJoinProbeTablePrimCol(SSelectStmt* pSelect, SNode* pNode) {
if (QUERY_NODE_COLUMN != nodeType(pNode)) { if (QUERY_NODE_COLUMN != nodeType(pNode)) {
return false; return false;
@ -3388,13 +3407,13 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
if (nodesEqualNode(pActualNode, *pNode)) { if (nodesEqualNode(pActualNode, *pNode)) {
return DEAL_RES_IGNORE_CHILD; return DEAL_RES_IGNORE_CHILD;
} }
if (isTbnameFuction(pActualNode) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
return rewriteExprToGroupKeyFunc(pCxt, pNode);
}
if (IsEqualTbNameFuncNode(pSelect, pActualNode, *pNode)) { if (IsEqualTbNameFuncNode(pSelect, pActualNode, *pNode)) {
return rewriteExprToGroupKeyFunc(pCxt, pNode); return rewriteExprToGroupKeyFunc(pCxt, pNode);
} }
if (isTbnameFuction(pActualNode) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
return rewriteExprToSelectTagFunc(pCxt, pNode);
}
} }
SNode* pPartKey = NULL; SNode* pPartKey = NULL;
bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList); bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList);
@ -3494,10 +3513,13 @@ static EDealRes doCheckAggColCoexist(SNode** pNode, void* pContext) {
} }
} }
if (partionByTbname && if (partionByTbname &&
((QUERY_NODE_COLUMN == nodeType(*pNode) && ((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) || (QUERY_NODE_FUNCTION == nodeType(*pNode) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)*pNode)->funcType)) {
(QUERY_NODE_FUNCTION == nodeType(*pNode) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)*pNode)->funcType))) {
return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode); return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode);
} }
if (partionByTbname &&
((QUERY_NODE_COLUMN == nodeType(*pNode) && ((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG))) {
return rewriteExprToSelectTagFunc(pCxt->pTranslateCxt, pNode);
}
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
pCxt->existCol = true; pCxt->existCol = true;
} }
@ -4951,7 +4973,8 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
} }
static EDealRes needFillImpl(SNode* pNode, void* pContext) { static EDealRes needFillImpl(SNode* pNode, void* pContext) {
if ((isAggFunc(pNode) || isInterpFunc(pNode)) && FUNCTION_TYPE_GROUP_KEY != ((SFunctionNode*)pNode)->funcType) { if ((isAggFunc(pNode) || isInterpFunc(pNode)) && FUNCTION_TYPE_GROUP_KEY != ((SFunctionNode*)pNode)->funcType
&& FUNCTION_TYPE_GROUP_CONST_VALUE != ((SFunctionNode*)pNode)->funcType) {
*(bool*)pContext = true; *(bool*)pContext = true;
return DEAL_RES_END; return DEAL_RES_END;
} }

View File

@ -891,7 +891,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
} }
static bool isInterpFunc(int32_t funcId) { static bool isInterpFunc(int32_t funcId) {
return fmIsInterpFunc(funcId) || fmIsInterpPseudoColumnFunc(funcId) || fmIsGroupKeyFunc(funcId); return fmIsInterpFunc(funcId) || fmIsInterpPseudoColumnFunc(funcId) || fmIsGroupKeyFunc(funcId) || fmisSelectGroupConstValueFunc(funcId);
} }
static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {

View File

@ -452,6 +452,43 @@ if $data04 != @abc0@ then
return -1 return -1
endi endi
sql select ts, top(c1, 100), tbname, t1, t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') partition by tbname order by ts;
if $row != 200 then
return -1
endi
if $data00 != @70-01-01 08:01:40.087@ then
return -1
endi
if $data10 != @70-01-01 08:01:40.088@ then
return -1
endi
if $data20 != @70-01-01 08:01:40.089@ then
return -1
endi
if $data90 != @70-01-01 08:01:40.096@ then
return -1
endi
if $data01 != 87 then
return -1
endi
if $data02 != @select_tags_tb0@ then
return -1
endi
if $data03 != 0 then
return -1
endi
if $data04 != @abc0@ then
return -1
endi
sql select ts, top(c1, 2), t2, tbname, t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2 order by ts; sql select ts, top(c1, 2), t2, tbname, t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2 order by ts;
if $row != 4 then if $row != 4 then
return -1 return -1

View File

@ -39,6 +39,240 @@ class TDTestCase:
tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(value, 2)") tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(value, 2)")
tdSql.checkRows(0) tdSql.checkRows(0)
def ts5181(self):
tdSql.execute("create database db1 keep 36500")
tdSql.execute("use db1")
tdSql.execute("CREATE STABLE db1.`stb1` (`ts` TIMESTAMP ENCODE 'delta-i' COMPRESS 'lz4' LEVEL 'medium', `v1` INT ENCODE 'simple8b' COMPRESS 'lz4' LEVEL 'medium') TAGS (`t1` INT, t2 nchar(20))")
tdSql.execute("insert into db1.ttt_10000 using db1.stb1 tags(44400, '_ttt_10000') values('2024-02-19 16:05:17.649', 22300 ); ")
tdSql.execute("insert into db1.ttt_10000 using db1.stb1 tags(44400, '_ttt_10000') values('2024-02-19 16:05:48.818', 22300 ); ")
tdSql.execute("insert into db1.ttt_10 using db1.stb1 tags( 40 , '_ttt_10') values('2024-02-19 16:25:36.013', 20 ); ")
tdSql.execute("insert into db1.ttt_11 using db1.stb1 tags( 11 , '_ttt_11') values('2024-02-19 16:39:50.385' , 20 ); ")
tdSql.execute("insert into db1.ttt_11 using db1.stb1 tags( 11 , '_ttt_11') values('2024-02-19 16:43:51.742' , 20 ); ")
tdSql.execute("insert into db1.ttt_11 using db1.stb1 tags( 11 , '_ttt_11') values('2024-02-20 08:35:13.518' , 20 ); ")
tdSql.execute("insert into db1.ttt_11 using db1.stb1 tags( 11 , '_ttt_11') values('2024-02-20 08:58:42.255' , 20 ); ")
tdSql.execute("insert into db1.ttt_11 using db1.stb1 tags( 11 , '_ttt_11') values('2024-02-21 09:57:49.477' , 20 ); ")
tdSql.execute("insert into db1.`ttt_2024-2-21` using db1.stb1 tags( 11 , '_ttt_2024-2-21') values('2024-02-21 09:58:21.882' , 20 ); ")
tdSql.execute("insert into db1.`ttt_2024-2-21` using db1.stb1 tags( 11 , '_ttt_2024-2-21') values('2024-02-26 16:08:31.675' , 20 ); ")
tdSql.execute("insert into db1.`ttt_2024-2-21` using db1.stb1 tags( 11 , '_ttt_2024-2-21') values('2024-02-26 16:11:43.445' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:12:30.276' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:07.188' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:07.653' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:07.879' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:08.083' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:08.273' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:08.429' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:08.599' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:08.775' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:08.940' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:09.110' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:09.254' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:09.409' , NULL ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:34.750' , 12 ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:49.820' , 12 ); ")
tdSql.execute("insert into db1.`ttt_2024-2-33` using db1.stb1 tags( 11 , '_ttt_2024-2-33') values('2024-02-26 16:25:59.551' , NULL ); ")
tdSql.execute("insert into db1.ttt_2 using db1.stb1 tags( 2 , '_ttt_2') values('2024-02-19 15:26:39.644' , 2 ); ")
tdSql.execute("insert into db1.ttt_2 using db1.stb1 tags( 2 , '_ttt_2') values('2024-02-19 15:26:40.433' , 2 ); ")
tdSql.execute("insert into db1.ttt_3 using db1.stb1 tags( 3 , '_ttt_3') values('2024-02-19 15:27:22.613' , 1 ); ")
tdSql.execute("insert into db1.ttt_13 using db1.stb1 tags( 3 , '_ttt_13') values('2024-02-19 15:27:39.719' , 1 ); ")
tdSql.execute("insert into db1.ttt_14 using db1.stb1 tags( 3 , '_ttt_14') values('2024-02-19 15:28:36.235' , 222 ); ")
tdSql.execute("insert into db1.ttt_14 using db1.stb1 tags( 3 , '_ttt_14') values('2024-02-19 15:28:59.310' , 222 ); ")
tdSql.execute("insert into db1.ttt_14 using db1.stb1 tags( 3 , '_ttt_14') values('2024-02-19 15:29:18.897' , 222 ); ")
tdSql.execute("insert into db1.ttt_14 using db1.stb1 tags( 3 , '_ttt_14') values('2024-02-19 15:50:24.682' , 223 ); ")
tdSql.execute("insert into db1.ttt_4 using db1.stb1 tags( 3 , '_ttt_4') values('2024-02-19 15:31:19.945' , 222 ); ")
tdSql.execute("insert into db1.ttt_a using db1.stb1 tags( 3 , '_ttt_a') values('2024-02-19 15:31:37.915' , 4 ); ")
tdSql.execute("insert into db1.ttt_axxxx using db1.stb1 tags( NULL, '_ttt_axxxx') values('2024-02-19 15:31:58.953' , 4 ); ")
tdSql.execute("insert into db1.ttt_axxx using db1.stb1 tags( 56 , '_ttt_axxx') values('2024-02-19 15:32:22.323' , NULL ); ")
tdSql.execute("insert into db1.ttt_444 using db1.stb1 tags( 5633, '_ttt_444') values('2024-02-19 15:36:44.625' , 5444 ); ")
tdSql.execute("insert into db1.ttt_444 using db1.stb1 tags( 5633, '_ttt_444') values('2024-02-19 15:38:41.479' , 5444 ); ")
tdSql.execute("insert into db1.ttt_444 using db1.stb1 tags( 5633, '_ttt_444') values('2024-02-19 15:57:23.249' , 5444 ); ")
tdSql.execute("insert into db1.ttt_444 using db1.stb1 tags( 5633, '_ttt_444') values('2024-02-19 16:04:20.465' , 5444 ); ")
tdSql.execute("insert into db1.ttt_444 using db1.stb1 tags( 5633, '_ttt_444') values('2024-02-26 16:11:29.364' , 5444 ); ")
tdSql.execute("insert into db1.ttt_123 using db1.stb1 tags( 0 , '_ttt_123') values('2024-02-19 15:44:52.136' , 223 ); ")
tdSql.execute("insert into db1.ttt_145 using db1.stb1 tags( 0 , '_ttt_145') values('2024-02-19 15:50:28.580' , 223 ); ")
tdSql.execute("insert into db1.ttt_1465 using db1.stb1 tags( 0 , '_ttt_1465') values('2024-02-19 15:50:32.493' , 223 ); ")
tdSql.execute("insert into db1.ttt_1465 using db1.stb1 tags( 0 , '_ttt_1465') values('2024-02-19 15:57:36.866' , 223 ); ")
tdSql.execute("insert into db1.ttt_1465 using db1.stb1 tags( 0 , '_ttt_1465') values('2024-02-19 16:04:52.794' , 221113 ); ")
tdSql.execute("insert into db1.ttt_444 using db1.stb1 tags( 5633, '_ttt_444') values('2024-02-27 08:47:11.366' , 5444 ); ")
tdSql.execute("insert into db1.ttt_444 using db1.stb1 tags( 5633, '_ttt_444') values('2024-02-28 09:35:46.474' , 5444 ); ")
tdSql.query("select *,tbname from db1.stb1 ;")
tdSql.checkRows(51)
tdSql.query("select _irowts as ts,interp(v1),t1,tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) fill(prev)")
tdSql.checkRows(4)
tdSql.query("select _irowts as ts,interp(v1),t1,tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) fill(prev) order by tbname")
tdSql.checkData(0, 2, 3)
tdSql.checkData(1, 2, 3)
tdSql.checkData(2, 2, 2)
tdSql.checkData(3, 2, 3)
tdSql.checkData(0, 3, "ttt_13")
tdSql.checkData(1, 3, "ttt_14")
tdSql.checkData(2, 3, "ttt_2")
tdSql.checkData(3, 3, "ttt_3")
tdSql.query("select _irowts as ts,interp(v1),t1,tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(value, 0) order by tbname")
tdSql.checkRows(12)
tdSql.checkData(0, 2, 0)
tdSql.checkData(0, 3, "ttt_123")
tdSql.checkData(1, 2, 3)
tdSql.checkData(1, 3, "ttt_13")
tdSql.query("select _irowts as ts,interp(v1),tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(value, 0) order by tbname")
tdSql.checkRows(12)
tdSql.checkData(0, 2, "ttt_123")
tdSql.checkData(1, 2, "ttt_13")
tdSql.query("select _irowts as ts,interp(v1),t1,tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(NULL) order by tbname")
tdSql.checkRows(12)
tdSql.checkData(0, 2, 0)
tdSql.checkData(0, 3, "ttt_123")
tdSql.checkData(1, 2, 3)
tdSql.checkData(1, 3, "ttt_13")
tdSql.query("select _irowts as ts,interp(v1),t1 from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(NULL) order by tbname")
tdSql.checkRows(12)
tdSql.checkData(0, 2, 0)
tdSql.checkData(1, 2, 3)
tdSql.query("select _irowts as ts,interp(v1), tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(NULL) order by tbname")
tdSql.checkRows(12)
tdSql.checkData(0, 2, "ttt_123")
tdSql.checkData(1, 2, "ttt_13")
tdSql.query("select _irowts as ts,interp(v1),t1,tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(NULL) order by tbname")
tdSql.checkRows(12)
tdSql.checkData(0, 2, 0)
tdSql.checkData(0, 3, "ttt_123")
tdSql.checkData(1, 2, 3)
tdSql.checkData(1, 3, "ttt_13")
tdSql.query("select _irowts as ts,interp(v1),t1,tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(LINEAR) order by tbname")
tdSql.checkRows(1)
tdSql.checkData(0, 2, 3)
tdSql.checkData(0, 3, "ttt_14")
tdSql.query("select _irowts as ts,interp(v1), tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(LINEAR) order by tbname")
tdSql.checkRows(1)
tdSql.checkData(0, 2, "ttt_14")
tdSql.query("select _irowts as ts,interp(v1),t1 from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(LINEAR) order by tbname")
tdSql.checkRows(1)
tdSql.checkData(0, 2, 3)
tdSql.query("select _irowts as ts,interp(v1),t1, tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(NEXT) order by tbname")
tdSql.checkRows(9)
tdSql.checkData(0, 2, 0)
tdSql.checkData(0, 3, "ttt_123")
tdSql.query("select _irowts as ts,interp(v1),t1 from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(NEXT) order by tbname")
tdSql.checkRows(9)
tdSql.checkData(0, 2, 0)
tdSql.query("select _irowts as ts,interp(v1),tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(NEXT) order by tbname")
tdSql.checkRows(9)
tdSql.checkData(0, 2, "ttt_123")
tdSql.query("select _irowts as ts,interp(v1),t1, tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(NULL_F) order by tbname")
tdSql.checkRows(12)
tdSql.checkData(0, 2, 0)
tdSql.checkData(0, 3, "ttt_123")
tdSql.query("select _irowts as ts,interp(v1),t1, tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(VALUE_F, 5) order by tbname")
tdSql.checkRows(12)
tdSql.checkData(0, 1, 5)
tdSql.checkData(0, 2, 0)
tdSql.checkData(0, 3, "ttt_123")
tdSql.query("select _irowts as ts,interp(v1),t1, t2, tbname from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(VALUE_F, 5) order by tbname")
tdSql.checkRows(12)
tdSql.checkData(0, 1, 5)
tdSql.checkData(0, 2, 0)
tdSql.checkData(0, 3, "_ttt_123")
tdSql.checkData(0, 4, "ttt_123")
tdSql.query("select _irowts as ts,interp(v1),t1,tbname, t2 from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) fill(prev)")
tdSql.checkRows(4)
tdSql.query("select _irowts as ts,interp(v1),t1,tbname, t2 from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) fill(prev) order by tbname")
tdSql.checkData(0, 2, 3)
tdSql.checkData(1, 2, 3)
tdSql.checkData(2, 2, 2)
tdSql.checkData(3, 2, 3)
tdSql.checkData(0, 3, "ttt_13")
tdSql.checkData(1, 3, "ttt_14")
tdSql.checkData(2, 3, "ttt_2")
tdSql.checkData(3, 3, "ttt_3")
tdSql.checkData(0, 4, "_ttt_13")
tdSql.checkData(1, 4, "_ttt_14")
tdSql.checkData(2, 4, "_ttt_2")
tdSql.checkData(3, 4, "_ttt_3")
tdSql.query("select _irowts as ts,interp(v1),t1,t2 from db1.stb1 \
where ts>'2024-02-19T15:25:00+08:00' and ts<'2024-02-19T16:05:00+08:00' \
partition by tbname range('2024-02-19T15:30:00+08:00','2024-02-19T15:30:00+08:00') every(1m) \
fill(value, 0) order by tbname")
tdSql.checkRows(12)
tdSql.checkData(0, 2, 0)
tdSql.checkData(0, 3, "_ttt_123")
tdSql.checkData(1, 2, 3)
tdSql.checkData(1, 3, "_ttt_13")
def run(self): def run(self):
dbname = "db" dbname = "db"
tbname = "tb" tbname = "tb"
@ -5683,6 +5917,7 @@ class TDTestCase:
tdSql.checkData(0, 1, None) tdSql.checkData(0, 1, None)
self.interp_on_empty_table() self.interp_on_empty_table()
self.ts5181()
def stop(self): def stop(self):