diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index 16e1a1c395cee8a09d5cf5f765003811d45abc07..65244ec11af548c1ed58dd482257631d51c6785f 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -64,7 +64,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers); * @param SReadHandle * @return */ -qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols); +qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, SSchemaWrapper** pSchemaWrapper); /** * Set the input data block for the stream scan. diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 7927c1e008c66c4fc54156be1d3509574555d01b..2caf81317da77e6e689980f7612a383ab5f16a68 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -826,7 +826,7 @@ TEST(testCase, update_test) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); - TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1"); + TAOS_RES* pRes = taos_query(pConn, "select cast(0 as timestamp)-1y"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { printf("failed to create database, code:%s", taos_errstr(pRes)); taos_free_result(pRes); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index c674728fe60ebe64fe310fe16f84574290277aa2..1792a18c07b0d8acd144ee788612d5c81ebf6115 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1163,9 +1163,15 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows) { if (IS_VAR_DATA_TYPE(pColumn->info.type)) { pColumn->varmeta.length = 0; + if (pColumn->varmeta.offset > 0) { + memset(pColumn->varmeta.offset, 0, sizeof(int32_t) * numOfRows); + } } else { if (pColumn->nullbitmap != NULL) { memset(pColumn->nullbitmap, 0, BitmapLen(numOfRows)); + if (pColumn->pData != NULL) { + memset(pColumn->pData, 0, pColumn->info.bytes * numOfRows); + } } } } diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index abac77dc01172bac044f05e6f2c82293cc36180a..c2006a25350679753828fe0eb5705efa44d06aea 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -88,7 +88,8 @@ typedef struct { STqExecTb execTb; STqExecDb execDb; }; - int32_t numOfCols; // number of out pout column, temporarily used + int32_t numOfCols; // number of out pout column, temporarily used + SSchemaWrapper *pSchemaWrapper; // columns that are involved in query } STqExecHandle; typedef struct { diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 054a8b6edf59105969c49403491d3b2c6f1e3dab..cecf899591dc9c469fb4749cd7f692d352af9b45 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -579,9 +579,11 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche while (1) { SSDataBlock *output = NULL; uint64_t ts; - if (qExecTask(pItem->taskInfo, &output, &ts) < 0) { + + int32_t code = qExecTask(pItem->taskInfo, &output, &ts); + if (code < 0) { smaError("vgId:%d, qExecTask for rsma table %" PRIi64 "l evel %" PRIi8 " failed since %s", SMA_VID(pSma), suid, - pItem->level, terrstr()); + pItem->level, terrstr(code)); goto _err; } if (!output) { @@ -597,35 +599,36 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche } taosArrayPush(pResult, output); - } - if (taosArrayGetSize(pResult) > 0) { + if (taosArrayGetSize(pResult) > 0) { #if 1 - char flag[10] = {0}; - snprintf(flag, 10, "level %" PRIi8, pItem->level); - blockDebugShowDataBlocks(pResult, flag); + char flag[10] = {0}; + snprintf(flag, 10, "level %" PRIi8, pItem->level); + blockDebugShowDataBlocks(pResult, flag); #endif - STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]); - SSubmitReq *pReq = NULL; - // TODO: the schema update should be handled - if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) { - smaError("vgId:%d, build submit req for rsma table %" PRIi64 "l evel %" PRIi8 " failed since %s", SMA_VID(pSma), - suid, pItem->level, terrstr()); - goto _err; - } + STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]); + SSubmitReq *pReq = NULL; + // TODO: the schema update should be handled + if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) { + smaError("vgId:%d, build submit req for rsma table %" PRIi64 "l evel %" PRIi8 " failed since %s", SMA_VID(pSma), + suid, pItem->level, terrstr()); + goto _err; + } + + if (pReq && tdProcessSubmitReq(sinkTsdb, atomic_add_fetch_64(&pStat->submitVer, 1), pReq) < 0) { + taosMemoryFreeClear(pReq); + smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", + SMA_VID(pSma), suid, pItem->level, terrstr()); + goto _err; + } - if (pReq && tdProcessSubmitReq(sinkTsdb, atomic_add_fetch_64(&pStat->submitVer, 1), pReq) < 0) { taosMemoryFreeClear(pReq); - smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), - suid, pItem->level, terrstr()); - goto _err; + taosArrayClear(pResult); + } else if (terrno == 0) { + smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level); + } else { + smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, tstrerror(terrno)); } - - taosMemoryFreeClear(pReq); - } else if (terrno == 0) { - smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level); - } else { - smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, tstrerror(terrno)); } tdDestroySDataBlockArray(pResult); @@ -1364,4 +1367,4 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { _end: tdReleaseSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__); -} +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 5469960ce68dca5c6c9d2411eb23c4b959e3a03b..23514c8c76239dfebae80a4322a43a0a4692930e 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -526,8 +526,8 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) { .initTqReader = true, .version = ver, }; - pHandle->execHandle.execCol.task[i] = - qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, &pHandle->execHandle.numOfCols); + pHandle->execHandle.execCol.task[i] = qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, &pHandle->execHandle.numOfCols, + &pHandle->execHandle.pSchemaWrapper); ASSERT(pHandle->execHandle.execCol.task[i]); void* scanner = NULL; qExtractStreamScanner(pHandle->execHandle.execCol.task[i], &scanner); diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index 468490350a70331104f6c1eec67d28b707baa99e..83e852c79eb58c5ee2937af6aeacf5912afb6e9b 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -93,7 +93,8 @@ int32_t tqMetaOpen(STQ* pTq) { .version = handle.snapshotVer, }; - handle.execHandle.execCol.task[i] = qCreateQueueExecTaskInfo(handle.execHandle.execCol.qmsg, &reader, &handle.execHandle.numOfCols); + handle.execHandle.execCol.task[i] = qCreateQueueExecTaskInfo(handle.execHandle.execCol.qmsg, &reader, &handle.execHandle.numOfCols, + &handle.execHandle.pSchemaWrapper); ASSERT(handle.execHandle.execCol.task[i]); void* scanner = NULL; qExtractStreamScanner(handle.execHandle.execCol.task[i], &scanner); diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 6be79f7578139ed5284c10e882ca6b835778cece..23763bd16cde12b1b918e24e6224eff6528ab9d9 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -1940,17 +1940,20 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* if (pDelFile) { SDelFReader* pDelFReader = NULL; code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL); - if (code) { + if (code != TSDB_CODE_SUCCESS) { goto _err; } SArray* aDelIdx = taosArrayInit(4, sizeof(SDelIdx)); if (aDelIdx == NULL) { + tsdbDelFReaderClose(&pDelFReader); goto _err; } code = tsdbReadDelIdx(pDelFReader, aDelIdx, NULL); - if (code) { + if (code != TSDB_CODE_SUCCESS) { + taosArrayDestroy(aDelIdx); + tsdbDelFReaderClose(&pDelFReader); goto _err; } @@ -1959,9 +1962,13 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* if (pIdx != NULL) { code = tsdbReadDelData(pDelFReader, pIdx, pDelData, NULL); - if (code != TSDB_CODE_SUCCESS) { - goto _err; - } + } + + taosArrayDestroy(aDelIdx); + tsdbDelFReaderClose(&pDelFReader); + + if (code != TSDB_CODE_SUCCESS) { + goto _err; } } @@ -2529,8 +2536,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn pDumpInfo->rowIndex = doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->verRange, step); - - if (pDumpInfo->rowIndex >= pBlock->nRow) { + if (pDumpInfo->rowIndex >= pDumpInfo->totalRows) { *state = CHECK_FILEBLOCK_CONT; } } diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 2cc4058b3b5ca5e87230379ec2e8a90a2c217c43..b36a5ebdd1d481a957f6c53e1629e203551771e9 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -164,6 +164,7 @@ typedef struct { char* dbname; int32_t tversion; SSchemaWrapper* sw; + SSchemaWrapper* qsw; } SSchemaInfo; typedef struct SExecTaskInfo { @@ -868,7 +869,7 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* re SExecTaskInfo* pTaskInfo); SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond, - SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup); + SExecTaskInfo* pTaskInfo); SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode, SExecTaskInfo* pTaskInfo); diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index ff7d934c4b4133daf7fcdb2cfd12ad64aa3bfea0..b00dc9dba54db4ed2851cf09101f8fb244aed266 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -120,7 +120,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO return code; } -qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols) { +qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, SSchemaWrapper** pSchemaWrapper) { if (msg == NULL) { // TODO create raw scan return NULL; @@ -154,6 +154,7 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* n } } + *pSchemaWrapper = tCloneSSchemaWrapper(((SExecTaskInfo*)pTaskInfo)->schemaInfo.qsw); return pTaskInfo; } diff --git a/source/libs/executor/src/executorMain.c b/source/libs/executor/src/executorMain.c index c3efbf9336d9a1ffb84f2a9b91e36beb794e9b35..e0020a496ea9d7bc0ab268f11c78d2823f690e55 100644 --- a/source/libs/executor/src/executorMain.c +++ b/source/libs/executor/src/executorMain.c @@ -199,6 +199,10 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) { void qDestroyTask(qTaskInfo_t qTaskHandle) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)qTaskHandle; + if (pTaskInfo == NULL) { + return; + } + qDebug("%s execTask completed, numOfRows:%" PRId64, GET_TASKID(pTaskInfo), pTaskInfo->pRoot->resultInfo.totalRows); queryCostStatis(pTaskInfo); // print the query cost summary diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 292e435732f68d6b728565a3e917d2a53923984e..c42d477b33ec1c96c5bb03aa9dad726aa6be7c10 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1647,11 +1647,6 @@ static int32_t compressQueryColData(SColumnInfoData* pColRes, int32_t numOfRows, colSize + COMP_OVERFLOW_BYTES, compressed, NULL, 0); } -int32_t doFillTimeIntervalGapsInResults(struct SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t capacity) { - int32_t numOfRows = (int32_t)taosFillResultDataBlock(pFillInfo, pBlock, capacity - pBlock->info.rows); - return pBlock->info.rows; -} - void queryCostStatis(SExecTaskInfo* pTaskInfo) { STaskCostInfo* pSummary = &pTaskInfo->cost; @@ -4147,35 +4142,62 @@ static STsdbReader* doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRea static SArray* extractColumnInfo(SNodeList* pNodeList); -int32_t extractTableSchemaInfo(SReadHandle* pHandle, uint64_t uid, SExecTaskInfo* pTaskInfo) { +SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode); + +int32_t extractTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode, SExecTaskInfo* pTaskInfo) { SMetaReader mr = {0}; metaReaderInit(&mr, pHandle->meta, 0); - int32_t code = metaGetTableEntryByUid(&mr, uid); + int32_t code = metaGetTableEntryByUid(&mr, pScanNode->uid); if (code != TSDB_CODE_SUCCESS) { + qError("failed to get the table meta, uid:0x%"PRIx64", suid:0x%"PRIx64 ", %s", pScanNode->uid, pScanNode->suid, + GET_TASKID(pTaskInfo)); + metaReaderClear(&mr); return terrno; } - pTaskInfo->schemaInfo.tablename = strdup(mr.me.name); + SSchemaInfo* pSchemaInfo = &pTaskInfo->schemaInfo; + pSchemaInfo->tablename = strdup(mr.me.name); if (mr.me.type == TSDB_SUPER_TABLE) { - pTaskInfo->schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow); - pTaskInfo->schemaInfo.tversion = mr.me.stbEntry.schemaTag.version; + pSchemaInfo->sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow); + pSchemaInfo->tversion = mr.me.stbEntry.schemaTag.version; } else if (mr.me.type == TSDB_CHILD_TABLE) { tDecoderClear(&mr.coder); tb_uid_t suid = mr.me.ctbEntry.suid; metaGetTableEntryByUid(&mr, suid); - pTaskInfo->schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow); - pTaskInfo->schemaInfo.tversion = mr.me.stbEntry.schemaTag.version; + pSchemaInfo->sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow); + pSchemaInfo->tversion = mr.me.stbEntry.schemaTag.version; } else { - pTaskInfo->schemaInfo.sw = tCloneSSchemaWrapper(&mr.me.ntbEntry.schemaRow); + pSchemaInfo->sw = tCloneSSchemaWrapper(&mr.me.ntbEntry.schemaRow); } metaReaderClear(&mr); + + pSchemaInfo->qsw = extractQueriedColumnSchema(pScanNode); return TSDB_CODE_SUCCESS; } +SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode) { + int32_t numOfCols = LIST_LENGTH(pScanNode->pScanCols); + SSchemaWrapper* pqSw = taosMemoryCalloc(1, sizeof(SSchemaWrapper)); + pqSw->pSchema = taosMemoryCalloc(numOfCols, sizeof(SSchema)); + + for(int32_t i = 0; i < numOfCols; ++i) { + STargetNode* pNode = (STargetNode*)nodesListGetNode(pScanNode->pScanCols, i); + SColumnNode* pColNode = (SColumnNode*)pNode->pExpr; + + SSchema* pSchema = &pqSw->pSchema[pqSw->nCols++]; + pSchema->colId = pColNode->colId; + pSchema->type = pColNode->node.resType.type; + pSchema->type = pColNode->node.resType.bytes; + strncpy(pSchema->name, pColNode->colName, tListLen(pSchema->name)); + } + + return pqSw; +} + static void cleanupTableSchemaInfo(SSchemaInfo* pSchemaInfo) { taosMemoryFreeClear(pSchemaInfo->dbname); if (pSchemaInfo->sw == NULL) { @@ -4183,8 +4205,8 @@ static void cleanupTableSchemaInfo(SSchemaInfo* pSchemaInfo) { } taosMemoryFree(pSchemaInfo->tablename); - taosMemoryFree(pSchemaInfo->sw->pSchema); - taosMemoryFree(pSchemaInfo->sw); + tDeleteSSchemaWrapper(pSchemaInfo->sw); + tDeleteSSchemaWrapper(pSchemaInfo->qsw); } static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum) { @@ -4385,7 +4407,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - code = extractTableSchemaInfo(pHandle, pTableScanNode->scan.uid, pTaskInfo); + code = extractTableSchemaInfo(pHandle, &pTableScanNode->scan, pTaskInfo); if (code) { pTaskInfo->code = terrno; return NULL; @@ -4405,7 +4427,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - code = extractTableSchemaInfo(pHandle, pTableScanNode->scan.uid, pTaskInfo); + code = extractTableSchemaInfo(pHandle, &pTableScanNode->scan, pTaskInfo); if (code) { pTaskInfo->code = terrno; return NULL; @@ -4422,11 +4444,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) { STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode; - STimeWindowAggSupp twSup = { - .waterMark = pTableScanNode->watermark, - .calTrigger = pTableScanNode->triggerType, - .maxTs = INT64_MIN, - }; if (pHandle->vnode) { int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort, pHandle, pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo)); @@ -4436,7 +4453,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } } - SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTaskInfo, &twSup); + pTaskInfo->schemaInfo.qsw = extractQueriedColumnSchema(&pTableScanNode->scan); + SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTaskInfo); return pOperator; } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) { @@ -4487,7 +4505,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - code = extractTableSchemaInfo(pHandle, pScanNode->scan.uid, pTaskInfo); + code = extractTableSchemaInfo(pHandle, &pScanNode->scan, pTaskInfo); if (code != TSDB_CODE_SUCCESS) { pTaskInfo->code = code; return NULL; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 11aac2114dae4bc7db48ade821c5b774df6b0bec..574aa648e5f8efd36b41634e0b417f2409ce813d 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1525,7 +1525,7 @@ static void destroyStreamScanOperatorInfo(void* param, int32_t numOfOutput) { } SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond, - SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup) { + SExecTaskInfo* pTaskInfo) { SStreamScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); @@ -1539,6 +1539,12 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pTagCond = pTagCond; + pInfo->twAggSup = (STimeWindowAggSupp){ + .waterMark = pTableScanNode->watermark, + .calTrigger = pTableScanNode->triggerType, + .maxTs = INT64_MIN, + }; + int32_t numOfCols = 0; pInfo->pColMatchInfo = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID); @@ -1591,7 +1597,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys } if (pTSInfo->interval.interval > 0) { - pInfo->pUpdateInfo = updateInfoInitP(&pTSInfo->interval, pTwSup->waterMark); + pInfo->pUpdateInfo = updateInfoInitP(&pTSInfo->interval, pInfo->twAggSup.waterMark); } else { pInfo->pUpdateInfo = NULL; } @@ -1631,7 +1637,6 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->deleteDataIndex = 0; pInfo->pDeleteDataRes = createPullDataBlock(); pInfo->updateWin = (STimeWindow){.skey = INT64_MAX, .ekey = INT64_MAX}; - pInfo->twAggSup = *pTwSup; pOperator->name = "StreamScanOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN; diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index 31c079e55f908727981b0a07be41ec3cadc26a69..90ffff5fafeed4186ed754c97c4980689d713ced 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -66,12 +66,32 @@ static void setNullRow(SSDataBlock* pBlock, int64_t ts, int32_t rowIndex) { static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey); +static void doSetUserSpecifiedValue(SColumnInfoData* pDst, SVariant* pVar, int32_t rowIndex, int64_t currentKey) { + if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) { + float v = 0; + GET_TYPED_DATA(v, float, pVar->nType, &pVar->i); + colDataAppend(pDst, rowIndex, (char*)&v, false); + } else if (pDst->info.type == TSDB_DATA_TYPE_DOUBLE) { + double v = 0; + GET_TYPED_DATA(v, double, pVar->nType, &pVar->i); + colDataAppend(pDst, rowIndex, (char*)&v, false); + } else if (IS_SIGNED_NUMERIC_TYPE(pDst->info.type)) { + int64_t v = 0; + GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i); + colDataAppend(pDst, rowIndex, (char*)&v, false); + } else if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) { + colDataAppend(pDst, rowIndex, (const char*)¤tKey, false); + } else { // varchar/nchar data + colDataAppendNULL(pDst, rowIndex); + } +} + static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* pSrcBlock, int64_t ts, bool outOfBound) { SPoint point1, point2, point; int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order); -// set the primary timestamp column value + // set the primary timestamp column value int32_t index = pBlock->info.rows; // set the other values @@ -160,30 +180,13 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* } else { // fill with user specified value for each column for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { SFillColInfo* pCol = &pFillInfo->pFillCol[i]; - if (TSDB_COL_IS_TAG(pCol->flag) /* || IS_VAR_DATA_TYPE(pCol->schema.type)*/) { + if (TSDB_COL_IS_TAG(pCol->flag)) { continue; } SVariant* pVar = &pFillInfo->pFillCol[i].fillVal; - SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, i); - if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) { - float v = 0; - GET_TYPED_DATA(v, float, pVar->nType, &pVar->i); - colDataAppend(pDst, index, (char*)&v, false); - } else if (pDst->info.type == TSDB_DATA_TYPE_DOUBLE) { - double v = 0; - GET_TYPED_DATA(v, double, pVar->nType, &pVar->i); - colDataAppend(pDst, index, (char*)&v, false); - } else if (IS_SIGNED_NUMERIC_TYPE(pDst->info.type)) { - int64_t v = 0; - GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i); - colDataAppend(pDst, index, (char*)&v, false); - } else if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) { - colDataAppend(pDst, index, (const char*)&pFillInfo->currentKey, false); - } else { // varchar/nchar data - colDataAppendNULL(pDst, index); - } + doSetUserSpecifiedValue(pDst, pVar, index, pFillInfo->currentKey); } } @@ -273,7 +276,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t return outputRows; } } else { - assert(pFillInfo->currentKey == ts); + ASSERT(pFillInfo->currentKey == ts); int32_t index = pBlock->info.rows; if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) { @@ -295,27 +298,32 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t SColumnInfoData* pSrc = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, srcSlotId); char* src = colDataGetData(pSrc, pFillInfo->index); - if (i == 0 || (/*pCol->functionId != FUNCTION_COUNT &&*/ !colDataIsNull_s(pSrc, pFillInfo->index)) /*|| - (pCol->functionId == FUNCTION_COUNT && GET_INT64_VAL(src) != 0)*/) { + if (/*i == 0 || (*/!colDataIsNull_s(pSrc, pFillInfo->index)) { bool isNull = colDataIsNull_s(pSrc, pFillInfo->index); colDataAppend(pDst, index, src, isNull); saveColData(pFillInfo->prev, i, src, isNull); - } else { // i > 0 and data is null , do interpolation - if (pFillInfo->type == TSDB_FILL_PREV) { - SGroupKeys* pKey = taosArrayGet(pFillInfo->prev, i); - doSetVal(pDst, index, pKey); - } else if (pFillInfo->type == TSDB_FILL_LINEAR) { - bool isNull = colDataIsNull_s(pSrc, pFillInfo->index); - colDataAppend(pDst, index, src, isNull); - saveColData(pFillInfo->prev, i, src, isNull); - } else if (pFillInfo->type == TSDB_FILL_NULL) { - colDataAppendNULL(pDst, index); - } else if (pFillInfo->type == TSDB_FILL_NEXT) { - SGroupKeys* pKey = taosArrayGet(pFillInfo->next, i); - doSetVal(pDst, index, pKey); - } else { - SVariant* pVar = &pFillInfo->pFillCol[i].fillVal; - colDataAppend(pDst, index, (char*)&pVar->i, false); + } else { + if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) { + colDataAppend(pDst, index, (const char*)&pFillInfo->currentKey, false); + } else { // i > 0 and data is null , do interpolation + if (pFillInfo->type == TSDB_FILL_PREV) { + SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev : pFillInfo->next; + SGroupKeys* pKey = taosArrayGet(p, i); + doSetVal(pDst, index, pKey); + } else if (pFillInfo->type == TSDB_FILL_LINEAR) { + bool isNull = colDataIsNull_s(pSrc, pFillInfo->index); + colDataAppend(pDst, index, src, isNull); + saveColData(pFillInfo->prev, i, src, isNull); // todo: + } else if (pFillInfo->type == TSDB_FILL_NULL) { + colDataAppendNULL(pDst, index); + } else if (pFillInfo->type == TSDB_FILL_NEXT) { + SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next : pFillInfo->prev; + SGroupKeys* pKey = taosArrayGet(p, i); + doSetVal(pDst, index, pKey); + } else { + SVariant* pVar = &pFillInfo->pFillCol[i].fillVal; + doSetUserSpecifiedValue(pDst, pVar, index, pFillInfo->currentKey); + } } } } diff --git a/tests/script/tsim/insert/dupinsert.sim b/tests/script/tsim/insert/dupinsert.sim new file mode 100644 index 0000000000000000000000000000000000000000..0526cc19e48da72c97a7ee66ed83fec13f553407 --- /dev/null +++ b/tests/script/tsim/insert/dupinsert.sim @@ -0,0 +1,176 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print =============== create database +sql drop database if exists d0 +sql create database d0 keep 365000d,365000d,365000d +sql use d0 + +print =============== create super table +sql create table if not exists stb (ts timestamp, c1 int unsigned, c2 double, c3 binary(10), c4 nchar(10), c5 double) tags (city binary(20),district binary(20)); + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== create child table +sql create table ct1 using stb tags("BeiJing", "ChaoYang") +sql create table ct2 using stb tags("BeiJing", "HaiDian") +sql create table ct3 using stb tags("BeiJing", "PingGu") +sql create table ct4 using stb tags("BeiJing", "YanQing") + +sql show tables +if $rows != 4 then + print rows $rows != 4 + return -1 +endi + +print =============== step 1 insert records into ct1 - taosd merge +sql insert into ct1(ts,c1,c2) values('2022-05-03 16:59:00.010', 10, 20); +sql insert into ct1(ts,c1,c2,c3,c4) values('2022-05-03 16:59:00.011', 11, NULL, 'binary', 'nchar'); +sql insert into ct1 values('2022-05-03 16:59:00.016', 16, NULL, NULL, 'nchar', NULL); +sql insert into ct1 values('2022-05-03 16:59:00.016', 17, NULL, NULL, 'nchar', 170); +sql insert into ct1 values('2022-05-03 16:59:00.020', 20, NULL, NULL, 'nchar', 200); +sql insert into ct1 values('2022-05-03 16:59:00.016', 18, NULL, NULL, 'nchar', 180); +sql insert into ct1 values('2022-05-03 16:59:00.021', 21, NULL, NULL, 'nchar', 210); +sql insert into ct1 values('2022-05-03 16:59:00.022', 22, NULL, NULL, 'nchar', 220); + +print =============== step 2 insert records into ct1/ct2 - taosc merge for 2022-05-03 16:59:00.010 +sql insert into ct1(ts,c1,c2) values('2022-05-03 16:59:00.010', 10,10), ('2022-05-03 16:59:00.010',20,10.0), ('2022-05-03 16:59:00.010',30,NULL) ct2(ts,c1) values('2022-05-03 16:59:00.010',10), ('2022-05-03 16:59:00.010',20) ct1(ts,c2) values('2022-05-03 16:59:00.010',10), ('2022-05-03 16:59:00.010',100) ct1(ts,c3) values('2022-05-03 16:59:00.010','bin1'), ('2022-05-03 16:59:00.010','bin2') ct1(ts,c4,c5) values('2022-05-03 16:59:00.010',NULL,NULL), ('2022-05-03 16:59:00.010','nchar4',1000.01) ct2(ts,c2,c3,c4,c5) values('2022-05-03 16:59:00.010',20,'xkl','zxc',10); + +print =============== step 3 insert records into ct3 +sql insert into ct3(ts,c1,c5) values('2022-05-03 16:59:00.020', 10,10); +sql insert into ct3(ts,c1,c5) values('2022-05-03 16:59:00.021', 10,10), ('2022-05-03 16:59:00.021',20,20.0); +sql insert into ct3(ts,c1,c5) values('2022-05-03 16:59:00.022', 30,30), ('2022-05-03 16:59:00.022',40,40.0),('2022-05-03 16:59:00.022',50,50.0); +sql insert into ct3(ts,c1,c5) values('2022-05-03 16:59:00.023', 60,60), ('2022-05-03 16:59:00.023',70,70.0),('2022-05-03 16:59:00.023',80,80.0), ('2022-05-03 16:59:00.023',90,90.0); +sql insert into ct3(ts,c1,c5) values('2022-05-03 16:59:00.024', 100,100), ('2022-05-03 16:59:00.025',110,110.0),('2022-05-03 16:59:00.025',120,120.0), ('2022-05-03 16:59:00.025',130,130.0); +sql insert into ct3(ts,c1,c5) values('2022-05-03 16:59:00.030', 140,140), ('2022-05-03 16:59:00.030',150,150.0),('2022-05-03 16:59:00.031',160,160.0), ('2022-05-03 16:59:00.030',170,170.0), ('2022-05-03 16:59:00.031',180,180.0); +sql insert into ct3(ts,c1,c5) values('2022-05-03 16:59:00.042', 190,190), ('2022-05-03 16:59:00.041',200,200.0),('2022-05-03 16:59:00.040',210,210.0); +sql insert into ct3(ts,c1,c5) values('2022-05-03 16:59:00.050', 220,220), ('2022-05-03 16:59:00.051',230,230.0),('2022-05-03 16:59:00.052',240,240.0); + +print =============== step 4 insert records into ct4 +sql insert into ct4(ts,c1,c3,c4) values('2022-05-03 16:59:00.020', 10,'b0','n0'); +sql insert into ct4(ts,c1,c3,c4) values('2022-05-03 16:59:00.021', 20,'b1','n1'), ('2022-05-03 16:59:00.021',30,'b2','n2'); +sql insert into ct4(ts,c1,c3,c4) values('2022-05-03 16:59:00.022', 40,'b3','n3'), ('2022-05-03 16:59:00.022',40,'b4','n4'),('2022-05-03 16:59:00.022',50,'b5','n5'); +sql insert into ct4(ts,c1,c3,c4) values('2022-05-03 16:59:00.023', 60,'b6','n6'), ('2022-05-03 16:59:00.024',70,'b7','n7'),('2022-05-03 16:59:00.024',80,'b8','n8'), ('2022-05-03 16:59:00.023',90,'b9','n9'); + + + +print =============== step 5 query records of ct1 from memory(taosc and taosd merge) +sql select * from ct1; +print $data00 $data01 $data02 $data03 $data04 $data05 +print $data10 $data11 $data12 $data13 $data14 $data15 +print $data20 $data21 $data22 $data23 $data24 $data25 +print $data30 $data31 $data32 $data33 $data34 $data35 +print $data40 $data41 $data42 $data43 $data44 $data45 +print $data50 $data51 $data52 $data53 $data54 $data55 + + + +print =============== step 6 query records of ct2 from memory(taosc and taosd merge) +sql select * from ct2; +print $data00 $data01 $data02 $data03 $data04 $data05 + +if $rows != 1 then + print rows $rows != 1 + return -1 +endi + + + +print =============== step 7 query records of ct3 from memory +sql select * from ct3; +print $data00 $data01 $data02 $data03 $data04 $data05 +print $data10 $data11 $data12 $data13 $data14 $data15 +print $data20 $data21 $data22 $data23 $data24 $data25 +print $data30 $data31 $data32 $data33 $data34 $data35 +print $data40 $data41 $data42 $data43 $data44 $data45 +print $data50 $data51 $data52 $data53 $data54 $data55 +print $data60 $data61 $data62 $data63 $data64 $data65 +print $data70 $data71 $data72 $data73 $data74 $data75 +print $data80 $data81 $data82 $data83 $data84 $data85 +print $data90 $data91 $data92 $data93 $data94 $data95 +print $data[10][0] $data[10][1] $data[10][2] $data[10][3] $data[10][4] $data[10][5] +print $data[11][0] $data[11][1] $data[11][2] $data[11][3] $data[11][4] $data[11][5] +print $data[12][0] $data[12][1] $data[12][2] $data[12][3] $data[12][4] $data[12][5] +print $data[13][0] $data[13][1] $data[13][2] $data[13][3] $data[13][4] $data[13][5] + +if $rows != 14 then + print rows $rows != 14 + return -1 +endi + + +print =============== step 8 query records of ct4 from memory +sql select * from ct4; +print $data00 $data01 $data02 $data03 $data04 $data05 +print $data10 $data11 $data12 $data13 $data14 $data15 +print $data20 $data21 $data22 $data23 $data24 $data25 +print $data30 $data31 $data32 $data33 $data34 $data35 +print $data40 $data41 $data42 $data43 $data44 $data45 + + +if $rows != 5 then + print rows $rows != 5 + return -1 +endi + + +#==================== reboot to trigger commit data to file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + + +print =============== step 9 query records of ct1 from file +sql select * from ct1; +print $data00 $data01 $data02 $data03 $data04 $data05 +print $data10 $data11 $data12 $data13 $data14 $data15 +print $data20 $data21 $data22 $data23 $data24 $data25 +print $data30 $data31 $data32 $data33 $data34 $data35 +print $data40 $data41 $data42 $data43 $data44 $data45 +print $data50 $data51 $data52 $data53 $data54 $data55 + +if $rows != 6 then + print rows $rows != 6 + return -1 +endi + + +print =============== step 10 query records of ct2 from file +sql select * from ct2; +print $data00 $data01 $data02 $data03 $data04 $data05 + +if $rows != 1 then + print rows $rows != 1 + return -1 +endi + + +print =============== step 11 query records of ct3 from file +sql select * from ct3; +print $data00 $data01 $data02 $data03 $data04 $data05 +print $data10 $data11 $data12 $data13 $data14 $data15 +print $data20 $data21 $data22 $data23 $data24 $data25 +print $data30 $data31 $data32 $data33 $data34 $data35 +print $data40 $data41 $data42 $data43 $data44 $data45 +print $data50 $data51 $data52 $data53 $data54 $data55 +print $data60 $data61 $data62 $data63 $data64 $data65 +print $data70 $data71 $data72 $data73 $data74 $data75 +print $data80 $data81 $data82 $data83 $data84 $data85 +print $data90 $data91 $data92 $data93 $data94 $data95 +print $data[10][0] $data[10][1] $data[10][2] $data[10][3] $data[10][4] $data[10][5] +print $data[11][0] $data[11][1] $data[11][2] $data[11][3] $data[11][4] $data[11][5] +print $data[12][0] $data[12][1] $data[12][2] $data[12][3] $data[12][4] $data[12][5] +print $data[13][0] $data[13][1] $data[13][2] $data[13][3] $data[13][4] $data[13][5] + + +print =============== step 12 query records of ct4 from file +sql select * from ct4; +print $data00 $data01 $data02 $data03 $data04 $data05 +print $data10 $data11 $data12 $data13 $data14 $data15 +print $data20 $data21 $data22 $data23 $data24 $data25 +print $data30 $data31 $data32 $data33 $data34 $data35 +print $data40 $data41 $data42 $data43 $data44 $data45 \ No newline at end of file diff --git a/tests/system-test/2-query/Now.py b/tests/system-test/2-query/Now.py index 3caf63220941f361b385bb6d5516fbc16fd2635b..386c8b9d31c00a104f335ec5bb61e5045056e4c5 100644 --- a/tests/system-test/2-query/Now.py +++ b/tests/system-test/2-query/Now.py @@ -12,24 +12,24 @@ class TDTestCase: tdSql.init(conn.cursor(),True) self.setsql = TDSetSql() # name of normal table - self.ntbname = 'ntb' + self.ntbname = 'ntb' # name of stable - self.stbname = 'stb' + self.stbname = 'stb' # structure of column - self.column_dict = { + self.column_dict = { 'ts':'timestamp', 'c1':'int', 'c2':'float', 'c3':'double' } # structure of tag - self.tag_dict = { + self.tag_dict = { 't0':'int' } # number of child tables - self.tbnum = 2 + self.tbnum = 2 # values of tag,the number of values should equal to tbnum - self.tag_values = [ + self.tag_values = [ f'10', f'100' ] @@ -43,7 +43,7 @@ class TDTestCase: self.db_percision = ['ms','us','ns'] def tbtype_check(self,tb_type): if tb_type == 'normal table' or tb_type == 'child table': - tdSql.checkRows(len(self.values_list)) + tdSql.checkRows(len(self.values_list)) elif tb_type == 'stable': tdSql.checkRows(len(self.values_list) * self.tbnum) def data_check(self,tbname,tb_type): @@ -98,7 +98,7 @@ class TDTestCase: self.now_check_ntb() self.now_check_stb() - + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/distribute_agg_apercentile.py b/tests/system-test/2-query/distribute_agg_apercentile.py index 632bda6bc6fcdf7dfa41c3120d70774c697a0735..eb5e8333c20803c424941bd75321aaa7e1ea1d52 100644 --- a/tests/system-test/2-query/distribute_agg_apercentile.py +++ b/tests/system-test/2-query/distribute_agg_apercentile.py @@ -2,11 +2,11 @@ from util.log import * from util.cases import * from util.sql import * import numpy as np -import random +import random class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } @@ -18,7 +18,7 @@ class TDTestCase: self.ts = 1537146000000 def prepare_datas_of_distribute(self): - + # prepate datas for 20 tables distributed at different vgroups tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") tdSql.execute(" use testdb ") @@ -89,17 +89,17 @@ class TDTestCase: vgroups = tdSql.queryResult vnode_tables={} - + for vgroup_id in vgroups: vnode_tables[vgroup_id[0]]=[] - + # check sub_table of per vnode ,make sure sub_table has been distributed tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - vnode_tables[table_name[6]].append(table_name[0]) + vnode_tables[table_name[6]].append(table_name[0]) self.vnode_disbutes = vnode_tables count = 0 @@ -108,7 +108,7 @@ class TDTestCase: count+=1 if count < 2: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") - + def distribute_agg_query(self): # basic filter tdSql.query("select apercentile(c1 , 20) from stb1 where c1 is null") @@ -129,12 +129,12 @@ class TDTestCase: tdSql.query("select apercentile(c1,20) from stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) - # union all + # union all tdSql.query("select apercentile(c1,20) from stb1 union all select apercentile(c1,20) from stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,7.389181281) - # join + # join tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") @@ -142,7 +142,7 @@ class TDTestCase: tdSql.execute(" create table tb1 using st tags(1) ") tdSql.execute(" create table tb2 using st tags(2) ") - + for i in range(10): ts = i*10 + self.ts tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") @@ -153,7 +153,7 @@ class TDTestCase: tdSql.checkData(0,0,9.000000000) tdSql.checkData(0,0,9.000000000) - # group by + # group by tdSql.execute(" use testdb ") tdSql.query(" select max(c1),c1 from stb1 group by t1 ") tdSql.checkRows(20) @@ -189,7 +189,7 @@ class TDTestCase: self.check_distribute_datas() self.distribute_agg_query() - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/distribute_agg_avg.py b/tests/system-test/2-query/distribute_agg_avg.py index d23a597e92d9300a1ecae51746f82c557848297e..2f449595bd34653ea035867dd3625ca6ea778cbd 100644 --- a/tests/system-test/2-query/distribute_agg_avg.py +++ b/tests/system-test/2-query/distribute_agg_avg.py @@ -7,7 +7,7 @@ import platform class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } @@ -24,7 +24,7 @@ class TDTestCase: avg_sql = f"select avg({col_name}) from {tbname};" same_sql = f"select {col_name} from {tbname} where {col_name} is not null " - + tdSql.query(same_sql) pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'): @@ -35,7 +35,7 @@ class TDTestCase: tdSql.checkData(0,0,pre_avg) def prepare_datas_of_distribute(self): - + # prepate datas for 20 tables distributed at different vgroups tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") tdSql.execute(" use testdb ") @@ -106,17 +106,17 @@ class TDTestCase: vgroups = tdSql.queryResult vnode_tables={} - + for vgroup_id in vgroups: vnode_tables[vgroup_id[0]]=[] - + # check sub_table of per vnode ,make sure sub_table has been distributed tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - vnode_tables[table_name[6]].append(table_name[0]) + vnode_tables[table_name[6]].append(table_name[0]) self.vnode_disbutes = vnode_tables count = 0 @@ -127,14 +127,14 @@ class TDTestCase: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") def check_avg_distribute_diff_vnode(self,col_name): - + vgroup_ids = [] for k ,v in self.vnode_disbutes.items(): if len(v)>=2: vgroup_ids.append(k) - + distribute_tbnames = [] - + for vgroup_id in vgroup_ids: vnode_tables = self.vnode_disbutes[vgroup_id] distribute_tbnames.append(random.sample(vnode_tables,1)[0]) @@ -143,7 +143,7 @@ class TDTestCase: tbname_ins += "'%s' ,"%tbname tbname_filters = tbname_ins[:-1] - + avg_sql = f"select avg({col_name}) from stb1 where tbname in ({tbname_filters});" same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null " @@ -158,8 +158,8 @@ class TDTestCase: tdSql.checkData(0,0,pre_avg) def check_avg_status(self): - # check max function work status - + # check max function work status + tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] @@ -168,26 +168,26 @@ class TDTestCase: tdSql.query("desc stb1") col_names = tdSql.queryResult - + colnames = [] for col_name in col_names: if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]: colnames.append(col_name[0]) - + for tablename in tablenames: for colname in colnames: self.check_avg_functions(tablename,colname) - # check max function for different vnode + # check max function for different vnode for colname in colnames: if colname.startswith("c"): self.check_avg_distribute_diff_vnode(colname) else: - # self.check_avg_distribute_diff_vnode(colname) # bug for tag + # self.check_avg_distribute_diff_vnode(colname) # bug for tag pass - + def distribute_agg_query(self): # basic filter tdSql.query(" select avg(c1) from stb1 ") @@ -211,7 +211,7 @@ class TDTestCase: tdSql.query("select avg(c1) from stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) - # union all + # union all tdSql.query("select avg(c1) from stb1 union all select avg(c1) from stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,14.086956522) @@ -220,7 +220,7 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0,0,14.086956522) - # join + # join tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") @@ -228,7 +228,7 @@ class TDTestCase: tdSql.execute(" create table tb1 using st tags(1) ") tdSql.execute(" create table tb2 using st tags(2) ") - + for i in range(10): ts = i*10 + self.ts tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") @@ -239,7 +239,7 @@ class TDTestCase: tdSql.checkData(0,0,4.500000000) tdSql.checkData(0,1,4.500000000) - # group by + # group by tdSql.execute(" use testdb ") # partition by tbname or partition by tag @@ -270,7 +270,7 @@ class TDTestCase: self.check_avg_status() self.distribute_agg_query() - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/distribute_agg_count.py b/tests/system-test/2-query/distribute_agg_count.py index ebca81545c596f27933009d52096fc7cc4ea268c..67f7e283258cac6db3e2fc2454e60977ccb034b7 100644 --- a/tests/system-test/2-query/distribute_agg_count.py +++ b/tests/system-test/2-query/distribute_agg_count.py @@ -2,11 +2,11 @@ from util.log import * from util.cases import * from util.sql import * import numpy as np -import random +import random class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } @@ -25,7 +25,7 @@ class TDTestCase: same_sql = f"select sum(c) from (select {col_name} ,1 as c from {tbname} where {col_name} is not null) " tdSql.query(max_sql) - max_result = tdSql.queryResult + max_result = tdSql.queryResult tdSql.query(same_sql) same_result = tdSql.queryResult @@ -37,7 +37,7 @@ class TDTestCase: def prepare_datas_of_distribute(self): - + # prepate datas for 20 tables distributed at different vgroups tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") tdSql.execute(" use testdb ") @@ -108,17 +108,17 @@ class TDTestCase: vgroups = tdSql.queryResult vnode_tables={} - + for vgroup_id in vgroups: vnode_tables[vgroup_id[0]]=[] - + # check sub_table of per vnode ,make sure sub_table has been distributed tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - vnode_tables[table_name[6]].append(table_name[0]) + vnode_tables[table_name[6]].append(table_name[0]) self.vnode_disbutes = vnode_tables count = 0 @@ -129,14 +129,14 @@ class TDTestCase: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") def check_count_distribute_diff_vnode(self,col_name): - + vgroup_ids = [] for k ,v in self.vnode_disbutes.items(): if len(v)>=2: vgroup_ids.append(k) - + distribute_tbnames = [] - + for vgroup_id in vgroup_ids: vnode_tables = self.vnode_disbutes[vgroup_id] distribute_tbnames.append(random.sample(vnode_tables,1)[0]) @@ -145,13 +145,13 @@ class TDTestCase: tbname_ins += "'%s' ,"%tbname tbname_filters = tbname_ins[:-1] - + max_sql = f"select count({col_name}) from stb1 where tbname in ({tbname_filters});" same_sql = f"select sum(c) from (select {col_name} ,1 as c from stb1 where tbname in ({tbname_filters}) and {col_name} is not null) " tdSql.query(max_sql) - max_result = tdSql.queryResult + max_result = tdSql.queryResult tdSql.query(same_sql) same_result = tdSql.queryResult @@ -162,8 +162,8 @@ class TDTestCase: tdLog.info(" count function work as expected, sql : %s "% max_sql) def check_count_status(self): - # check max function work status - + # check max function work status + tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] @@ -172,26 +172,26 @@ class TDTestCase: tdSql.query("desc stb1") col_names = tdSql.queryResult - + colnames = [] for col_name in col_names: if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]: colnames.append(col_name[0]) - + for tablename in tablenames: for colname in colnames: self.check_count_functions(tablename,colname) - # check max function for different vnode + # check max function for different vnode for colname in colnames: if colname.startswith("c"): self.check_count_distribute_diff_vnode(colname) else: - # self.check_count_distribute_diff_vnode(colname) # bug for tag + # self.check_count_distribute_diff_vnode(colname) # bug for tag pass - + def distribute_agg_query(self): # basic filter tdSql.query("select count(c1) from stb1 ") @@ -212,12 +212,12 @@ class TDTestCase: tdSql.query("select count(c1) from stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) - # union all + # union all tdSql.query("select count(c1) from stb1 union all select count(c1) from stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,184) - # join + # join tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") @@ -225,7 +225,7 @@ class TDTestCase: tdSql.execute(" create table tb1 using st tags(1) ") tdSql.execute(" create table tb2 using st tags(2) ") - + for i in range(10): ts = i*10 + self.ts tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") @@ -236,7 +236,7 @@ class TDTestCase: tdSql.checkData(0,0,10) tdSql.checkData(0,1,10) - # group by + # group by tdSql.execute(" use testdb ") tdSql.query(" select count(*) from stb1 ") @@ -251,7 +251,7 @@ class TDTestCase: # partition by tbname or partition by tag tdSql.query("select max(c1),tbname from stb1 partition by tbname") query_data = tdSql.queryResult - + for row in query_data: tbname = row[1] tdSql.query(" select max(c1) from %s "%tbname) @@ -259,7 +259,7 @@ class TDTestCase: tdSql.query("select max(c1),tbname from stb1 partition by t1") query_data = tdSql.queryResult - + for row in query_data: tbname = row[1] tdSql.query(" select max(c1) from %s "%tbname) @@ -287,7 +287,7 @@ class TDTestCase: self.check_count_status() self.distribute_agg_query() - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/distribute_agg_max.py b/tests/system-test/2-query/distribute_agg_max.py index c7e074095b061b2e4a61487ff177d0e79ba1a61b..d4b71dbdd77e32bc57f6129ad91d9263cad055c7 100644 --- a/tests/system-test/2-query/distribute_agg_max.py +++ b/tests/system-test/2-query/distribute_agg_max.py @@ -2,11 +2,11 @@ from util.log import * from util.cases import * from util.sql import * import numpy as np -import random +import random class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } @@ -25,7 +25,7 @@ class TDTestCase: same_sql = f"select {col_name} from {tbname} order by {col_name} desc limit 1" tdSql.query(max_sql) - max_result = tdSql.queryResult + max_result = tdSql.queryResult tdSql.query(same_sql) same_result = tdSql.queryResult @@ -37,7 +37,7 @@ class TDTestCase: def prepare_datas_of_distribute(self): - + # prepate datas for 20 tables distributed at different vgroups tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") tdSql.execute(" use testdb ") @@ -108,17 +108,17 @@ class TDTestCase: vgroups = tdSql.queryResult vnode_tables={} - + for vgroup_id in vgroups: vnode_tables[vgroup_id[0]]=[] - + # check sub_table of per vnode ,make sure sub_table has been distributed tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - vnode_tables[table_name[6]].append(table_name[0]) + vnode_tables[table_name[6]].append(table_name[0]) self.vnode_disbutes = vnode_tables count = 0 @@ -129,14 +129,14 @@ class TDTestCase: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") def check_max_distribute_diff_vnode(self,col_name): - + vgroup_ids = [] for k ,v in self.vnode_disbutes.items(): if len(v)>=2: vgroup_ids.append(k) - + distribute_tbnames = [] - + for vgroup_id in vgroup_ids: vnode_tables = self.vnode_disbutes[vgroup_id] distribute_tbnames.append(random.sample(vnode_tables,1)[0]) @@ -145,13 +145,13 @@ class TDTestCase: tbname_ins += "'%s' ,"%tbname tbname_filters = tbname_ins[:-1] - + max_sql = f"select max({col_name}) from stb1 where tbname in ({tbname_filters});" same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) order by {col_name} desc limit 1" tdSql.query(max_sql) - max_result = tdSql.queryResult + max_result = tdSql.queryResult tdSql.query(same_sql) same_result = tdSql.queryResult @@ -162,8 +162,8 @@ class TDTestCase: tdLog.info(" max function work as expected, sql : %s "% max_sql) def check_max_status(self): - # check max function work status - + # check max function work status + tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] @@ -172,26 +172,26 @@ class TDTestCase: tdSql.query("desc stb1") col_names = tdSql.queryResult - + colnames = [] for col_name in col_names: if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]: colnames.append(col_name[0]) - + for tablename in tablenames: for colname in colnames: self.check_max_functions(tablename,colname) - # check max function for different vnode + # check max function for different vnode for colname in colnames: if colname.startswith("c"): self.check_max_distribute_diff_vnode(colname) else: - # self.check_max_distribute_diff_vnode(colname) # bug for tag + # self.check_max_distribute_diff_vnode(colname) # bug for tag pass - + def distribute_agg_query(self): # basic filter tdSql.query("select max(c1) from stb1 where c1 is null") @@ -212,12 +212,12 @@ class TDTestCase: tdSql.query("select max(c1) from stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) - # union all + # union all tdSql.query("select max(c1) from stb1 union all select max(c1) from stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,28) - # join + # join tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") @@ -225,7 +225,7 @@ class TDTestCase: tdSql.execute(" create table tb1 using st tags(1) ") tdSql.execute(" create table tb2 using st tags(2) ") - + for i in range(10): ts = i*10 + self.ts tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") @@ -236,7 +236,7 @@ class TDTestCase: tdSql.checkData(0,0,9) tdSql.checkData(0,0,9.00000) - # group by + # group by tdSql.execute(" use testdb ") tdSql.query(" select max(c1),c1 from stb1 group by t1 ") tdSql.checkRows(20) @@ -263,13 +263,13 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0,0,28) tdSql.checkData(0,1,19) - tdSql.checkData(0,2,311110.000000000) - tdSql.checkData(0,3,2109) + tdSql.checkData(0,2,311110.000000000) + tdSql.checkData(0,3,2109) # partition by tbname or partition by tag tdSql.query("select max(c1),tbname from stb1 partition by tbname") query_data = tdSql.queryResult - + for row in query_data: tbname = row[1] tdSql.query(" select max(c1) from %s "%tbname) @@ -277,7 +277,7 @@ class TDTestCase: tdSql.query("select max(c1),tbname from stb1 partition by t1") query_data = tdSql.queryResult - + for row in query_data: tbname = row[1] tdSql.query(" select max(c1) from %s "%tbname) @@ -305,7 +305,7 @@ class TDTestCase: self.check_max_status() self.distribute_agg_query() - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/distribute_agg_min.py b/tests/system-test/2-query/distribute_agg_min.py index d8f93a01f59e25e43960d03dc0da5989e77ce365..059efe02cddeddc794a70ea255b8460b9d1fa9e1 100644 --- a/tests/system-test/2-query/distribute_agg_min.py +++ b/tests/system-test/2-query/distribute_agg_min.py @@ -2,11 +2,11 @@ from util.log import * from util.cases import * from util.sql import * import numpy as np -import random +import random class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } @@ -25,7 +25,7 @@ class TDTestCase: same_sql = f"select {col_name} from {tbname} where {col_name} is not null order by {col_name} asc limit 1" tdSql.query(min_sql) - min_result = tdSql.queryResult + min_result = tdSql.queryResult tdSql.query(same_sql) same_result = tdSql.queryResult @@ -37,7 +37,7 @@ class TDTestCase: def prepare_datas_of_distribute(self): - + # prepate datas for 20 tables distributed at different vgroups tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") tdSql.execute(" use testdb ") @@ -108,17 +108,17 @@ class TDTestCase: vgroups = tdSql.queryResult vnode_tables={} - + for vgroup_id in vgroups: vnode_tables[vgroup_id[0]]=[] - + # check sub_table of per vnode ,make sure sub_table has been distributed tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - vnode_tables[table_name[6]].append(table_name[0]) + vnode_tables[table_name[6]].append(table_name[0]) self.vnode_disbutes = vnode_tables count = 0 @@ -129,14 +129,14 @@ class TDTestCase: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") def check_min_distribute_diff_vnode(self,col_name): - + vgroup_ids = [] for k ,v in self.vnode_disbutes.items(): if len(v)>=2: vgroup_ids.append(k) - + distribute_tbnames = [] - + for vgroup_id in vgroup_ids: vnode_tables = self.vnode_disbutes[vgroup_id] distribute_tbnames.append(random.sample(vnode_tables,1)[0]) @@ -145,13 +145,13 @@ class TDTestCase: tbname_ins += "'%s' ,"%tbname tbname_filters = tbname_ins[:-1] - + min_sql = f"select min({col_name}) from stb1 where tbname in ({tbname_filters});" same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null order by {col_name} asc limit 1" tdSql.query(min_sql) - min_result = tdSql.queryResult + min_result = tdSql.queryResult tdSql.query(same_sql) same_result = tdSql.queryResult @@ -162,8 +162,8 @@ class TDTestCase: tdLog.info(" min function work as expected, sql : %s "% min_sql) def check_min_status(self): - # check max function work status - + # check max function work status + tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] @@ -172,26 +172,26 @@ class TDTestCase: tdSql.query("desc stb1") col_names = tdSql.queryResult - + colnames = [] for col_name in col_names: if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]: colnames.append(col_name[0]) - + for tablename in tablenames: for colname in colnames: self.check_min_functions(tablename,colname) - # check max function for different vnode + # check max function for different vnode for colname in colnames: if colname.startswith("c"): self.check_min_distribute_diff_vnode(colname) else: - # self.check_min_distribute_diff_vnode(colname) # bug for tag + # self.check_min_distribute_diff_vnode(colname) # bug for tag pass - + def distribute_agg_query(self): # basic filter tdSql.query("select min(c1) from stb1 where c1 is null") @@ -212,12 +212,12 @@ class TDTestCase: tdSql.query("select min(c1) from stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) - # union all + # union all tdSql.query("select min(c1) from stb1 union all select min(c1) from stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,0) - # join + # join tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") @@ -225,7 +225,7 @@ class TDTestCase: tdSql.execute(" create table tb1 using st tags(1) ") tdSql.execute(" create table tb2 using st tags(2) ") - + for i in range(10): ts = i*10 + self.ts tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") @@ -236,7 +236,7 @@ class TDTestCase: tdSql.checkData(0,0,0) tdSql.checkData(0,0,0.00000) - # group by + # group by tdSql.execute(" use testdb ") tdSql.query(" select min(c1),c1 from stb1 group by t1 ") tdSql.checkRows(20) @@ -261,12 +261,12 @@ class TDTestCase: tdSql.query("select min(c1),ceil(t1),pow(c2,1)+2,abs(t3) from stb1 where c1>12") tdSql.checkRows(1) tdSql.checkData(0,0,13) - tdSql.checkData(0,2,144445.000000000) - + tdSql.checkData(0,2,144445.000000000) + # partition by tbname or partition by tag tdSql.query("select min(c1),tbname from stb1 partition by tbname") query_data = tdSql.queryResult - + for row in query_data: tbname = row[1] tdSql.query(" select min(c1) from %s "%tbname) @@ -274,7 +274,7 @@ class TDTestCase: tdSql.query("select min(c1),tbname from stb1 partition by t1") query_data = tdSql.queryResult - + for row in query_data: tbname = row[1] tdSql.query(" select min(c1) from %s "%tbname) @@ -303,7 +303,7 @@ class TDTestCase: self.check_min_status() self.distribute_agg_query() - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/distribute_agg_spread.py b/tests/system-test/2-query/distribute_agg_spread.py index 8d611007f3eaa19a581f31af39eee0061bc84f99..842a74628d7dbc05f10a99ba49364d8ddc7c2c5d 100644 --- a/tests/system-test/2-query/distribute_agg_spread.py +++ b/tests/system-test/2-query/distribute_agg_spread.py @@ -2,11 +2,11 @@ from util.log import * from util.cases import * from util.sql import * import numpy as np -import random +import random class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } @@ -25,7 +25,7 @@ class TDTestCase: same_sql = f"select max({col_name})-min({col_name}) from {tbname}" tdSql.query(spread_sql) - spread_result = tdSql.queryResult + spread_result = tdSql.queryResult tdSql.query(same_sql) same_result = tdSql.queryResult @@ -37,7 +37,7 @@ class TDTestCase: def prepare_datas_of_distribute(self): - + # prepate datas for 20 tables distributed at different vgroups tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") tdSql.execute(" use testdb ") @@ -108,17 +108,17 @@ class TDTestCase: vgroups = tdSql.queryResult vnode_tables={} - + for vgroup_id in vgroups: vnode_tables[vgroup_id[0]]=[] - + # check sub_table of per vnode ,make sure sub_table has been distributed tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - vnode_tables[table_name[6]].append(table_name[0]) + vnode_tables[table_name[6]].append(table_name[0]) self.vnode_disbutes = vnode_tables count = 0 @@ -129,14 +129,14 @@ class TDTestCase: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") def check_spread_distribute_diff_vnode(self,col_name): - + vgroup_ids = [] for k ,v in self.vnode_disbutes.items(): if len(v)>=2: vgroup_ids.append(k) - + distribute_tbnames = [] - + for vgroup_id in vgroup_ids: vnode_tables = self.vnode_disbutes[vgroup_id] distribute_tbnames.append(random.sample(vnode_tables,1)[0]) @@ -145,13 +145,13 @@ class TDTestCase: tbname_ins += "'%s' ,"%tbname tbname_filters = tbname_ins[:-1] - + spread_sql = f"select spread({col_name}) from stb1 where tbname in ({tbname_filters})" same_sql = f"select max({col_name}) - min({col_name}) from stb1 where tbname in ({tbname_filters})" tdSql.query(spread_sql) - spread_result = tdSql.queryResult + spread_result = tdSql.queryResult tdSql.query(same_sql) same_result = tdSql.queryResult @@ -162,8 +162,8 @@ class TDTestCase: tdLog.info(" spread function work as expected, sql : %s "% spread_sql) def check_spread_status(self): - # check max function work status - + # check max function work status + tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] @@ -172,26 +172,26 @@ class TDTestCase: tdSql.query("desc stb1") col_names = tdSql.queryResult - + colnames = [] for col_name in col_names: if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]: colnames.append(col_name[0]) - + for tablename in tablenames: for colname in colnames: self.check_spread_functions(tablename,colname) - # check max function for different vnode + # check max function for different vnode for colname in colnames: if colname.startswith("c"): self.check_spread_distribute_diff_vnode(colname) else: - # self.check_spread_distribute_diff_vnode(colname) # bug for tag + # self.check_spread_distribute_diff_vnode(colname) # bug for tag pass - + def distribute_agg_query(self): # basic filter tdSql.query("select spread(c1) from stb1 where c1 is null") @@ -212,12 +212,12 @@ class TDTestCase: tdSql.query("select spread(c1) from stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) - # union all + # union all tdSql.query("select spread(c1) from stb1 union all select max(c1)-min(c1) from stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,28.000000000) - # join + # join tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") @@ -225,7 +225,7 @@ class TDTestCase: tdSql.execute(" create table tb1 using st tags(1) ") tdSql.execute(" create table tb2 using st tags(2) ") - + for i in range(10): ts = i*10 + self.ts tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") @@ -236,7 +236,7 @@ class TDTestCase: tdSql.checkData(0,0,9.000000000) tdSql.checkData(0,0,9.00000) - # group by + # group by tdSql.execute(" use testdb ") tdSql.query(" select max(c1),c1 from stb1 group by t1 ") tdSql.checkRows(20) @@ -272,7 +272,7 @@ class TDTestCase: self.check_spread_status() self.distribute_agg_query() - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/distribute_agg_sum.py b/tests/system-test/2-query/distribute_agg_sum.py index d4e9dfb1fb8fcdcb31e283a8a487e6d3e0e7b65d..90d1edca9005a8d38598be0354265db52215ed8a 100644 --- a/tests/system-test/2-query/distribute_agg_sum.py +++ b/tests/system-test/2-query/distribute_agg_sum.py @@ -7,7 +7,7 @@ import platform class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } @@ -24,7 +24,7 @@ class TDTestCase: sum_sql = f"select sum({col_name}) from {tbname};" same_sql = f"select {col_name} from {tbname} where {col_name} is not null " - + tdSql.query(same_sql) pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'): @@ -35,7 +35,7 @@ class TDTestCase: tdSql.checkData(0,0,pre_sum) def prepare_datas_of_distribute(self): - + # prepate datas for 20 tables distributed at different vgroups tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") tdSql.execute(" use testdb ") @@ -106,17 +106,17 @@ class TDTestCase: vgroups = tdSql.queryResult vnode_tables={} - + for vgroup_id in vgroups: vnode_tables[vgroup_id[0]]=[] - + # check sub_table of per vnode ,make sure sub_table has been distributed tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: - vnode_tables[table_name[6]].append(table_name[0]) + vnode_tables[table_name[6]].append(table_name[0]) self.vnode_disbutes = vnode_tables count = 0 @@ -127,14 +127,14 @@ class TDTestCase: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") def check_sum_distribute_diff_vnode(self,col_name): - + vgroup_ids = [] for k ,v in self.vnode_disbutes.items(): if len(v)>=2: vgroup_ids.append(k) - + distribute_tbnames = [] - + for vgroup_id in vgroup_ids: vnode_tables = self.vnode_disbutes[vgroup_id] distribute_tbnames.append(random.sample(vnode_tables,1)[0]) @@ -143,7 +143,7 @@ class TDTestCase: tbname_ins += "'%s' ,"%tbname tbname_filters = tbname_ins[:-1] - + sum_sql = f"select sum({col_name}) from stb1 where tbname in ({tbname_filters});" same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null " @@ -158,8 +158,8 @@ class TDTestCase: tdSql.checkData(0,0,pre_sum) def check_sum_status(self): - # check max function work status - + # check max function work status + tdSql.query("show tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] @@ -168,26 +168,26 @@ class TDTestCase: tdSql.query("desc stb1") col_names = tdSql.queryResult - + colnames = [] for col_name in col_names: if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]: colnames.append(col_name[0]) - + for tablename in tablenames: for colname in colnames: self.check_sum_functions(tablename,colname) - # check max function for different vnode + # check max function for different vnode for colname in colnames: if colname.startswith("c"): self.check_sum_distribute_diff_vnode(colname) else: - # self.check_sum_distribute_diff_vnode(colname) # bug for tag + # self.check_sum_distribute_diff_vnode(colname) # bug for tag pass - + def distribute_agg_query(self): # basic filter tdSql.query(" select sum(c1) from stb1 ") @@ -211,7 +211,7 @@ class TDTestCase: tdSql.query("select sum(c1) from stb1 where t1> 4 partition by tbname") tdSql.checkRows(15) - # union all + # union all tdSql.query("select sum(c1) from stb1 union all select sum(c1) from stb1 ") tdSql.checkRows(2) tdSql.checkData(0,0,2592) @@ -220,7 +220,7 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0,0,5184) - # join + # join tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") @@ -228,7 +228,7 @@ class TDTestCase: tdSql.execute(" create table tb1 using st tags(1) ") tdSql.execute(" create table tb2 using st tags(2) ") - + for i in range(10): ts = i*10 + self.ts tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") @@ -239,7 +239,7 @@ class TDTestCase: tdSql.checkData(0,0,45) tdSql.checkData(0,1,45.000000000) - # group by + # group by tdSql.execute(" use testdb ") # partition by tbname or partition by tag @@ -269,7 +269,7 @@ class TDTestCase: self.check_sum_status() self.distribute_agg_query() - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/irate.py b/tests/system-test/2-query/irate.py index e40920c06ca28cb712adce78799c4ce700833992..09a046d6efe3d3502ba868820e7f7275e961896c 100644 --- a/tests/system-test/2-query/irate.py +++ b/tests/system-test/2-query/irate.py @@ -23,7 +23,7 @@ class TDTestCase: self.time_step = 1000 def insert_datas_and_check_irate(self ,tbnums , rownums , time_step ): - + tdLog.info(" prepare datas for auto check irate function ") tdSql.execute(" create database test ") @@ -48,7 +48,7 @@ class TDTestCase: c9 = "'nchar_val'" c10 = ts tdSql.execute(f" insert into {tbname} values ({ts},{c1},{c2},{c3},{c4},{c5},{c6},{c7},{c8},{c9},{c10})") - + tdSql.execute("use test") tbnames = ["stb", "sub_tb_1"] support_types = ["BIGINT", "SMALLINT", "TINYINT", "FLOAT", "DOUBLE", "INT"] @@ -204,11 +204,11 @@ class TDTestCase: # used for sub table tdSql.query("select irate(abs(c1+c2)) from ct1") tdSql.checkData(0, 0, 0.000000000) - + # mix with common col tdSql.error("select c1, irate(c1) from ct1") - + # mix with common functions tdSql.error("select irate(c1), abs(c1) from ct4 ") @@ -236,7 +236,7 @@ class TDTestCase: "select irate(c1+c2)/10 from stb1 where c1 = 5 partition by tbname ") tdSql.checkRows(2) tdSql.checkData(0, 0, 0.000000000) - + def irate_Arithmetic(self): pass diff --git a/tests/system-test/2-query/log.py b/tests/system-test/2-query/log.py index f08a4b20de586224b54822eb42032eb5f6daec28..b8e0aaf52ee38ed22c82a0e28f5fccf85082b347 100644 --- a/tests/system-test/2-query/log.py +++ b/tests/system-test/2-query/log.py @@ -10,13 +10,13 @@ from util.cases import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - + def prepare_datas(self): tdSql.execute( '''create table stb1 @@ -24,7 +24,7 @@ class TDTestCase: tags (t1 int) ''' ) - + tdSql.execute( ''' create table t1 @@ -69,12 +69,12 @@ class TDTestCase: def check_result_auto_log(self ,origin_query , log_query): - + log_result = tdSql.getResult(log_query) origin_result = tdSql.getResult(origin_query) auto_result =[] - + for row in origin_result: row_check = [] for elem in row: @@ -91,20 +91,20 @@ class TDTestCase: for row_index , row in enumerate(log_result): for col_index , elem in enumerate(row): if auto_result[row_index][col_index] != elem: - check_status = False + check_status = False if not check_status: tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query ) sys.exit(1) else: tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query ) - + def check_result_auto_log2(self ,origin_query , log_query): log_result = tdSql.getResult(log_query) origin_result = tdSql.getResult(origin_query) auto_result =[] - + for row in origin_result: row_check = [] for elem in row: @@ -121,7 +121,7 @@ class TDTestCase: for row_index , row in enumerate(log_result): for col_index , elem in enumerate(row): if auto_result[row_index][col_index] != elem: - check_status = False + check_status = False if not check_status: tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query ) sys.exit(1) @@ -133,7 +133,7 @@ class TDTestCase: origin_result = tdSql.getResult(origin_query) auto_result =[] - + for row in origin_result: row_check = [] for elem in row: @@ -150,7 +150,7 @@ class TDTestCase: for row_index , row in enumerate(log_result): for col_index , elem in enumerate(row): if auto_result[row_index][col_index] != elem: - check_status = False + check_status = False if not check_status: tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query ) sys.exit(1) @@ -161,7 +161,7 @@ class TDTestCase: origin_result = tdSql.getResult(origin_query) auto_result =[] - + for row in origin_result: row_check = [] for elem in row: @@ -178,13 +178,13 @@ class TDTestCase: for row_index , row in enumerate(log_result): for col_index , elem in enumerate(row): if auto_result[row_index][col_index] != elem: - check_status = False + check_status = False if not check_status: tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query ) sys.exit(1) else: tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query ) - + def test_errors(self): error_sql_lists = [ "select log from t1", @@ -218,42 +218,42 @@ class TDTestCase: ] for error_sql in error_sql_lists: tdSql.error(error_sql) - + def support_types(self): type_error_sql_lists = [ - "select log(ts ,2 ) from t1" , + "select log(ts ,2 ) from t1" , "select log(c7,c2 ) from t1", "select log(c8,c1 ) from t1", "select log(c9,c2 ) from t1", - "select log(ts,c7 ) from ct1" , + "select log(ts,c7 ) from ct1" , "select log(c7,c9 ) from ct1", "select log(c8,c2 ) from ct1", "select log(c9,c1 ) from ct1", - "select log(ts,2 ) from ct3" , + "select log(ts,2 ) from ct3" , "select log(c7,2 ) from ct3", "select log(c8,2 ) from ct3", "select log(c9,2 ) from ct3", - "select log(ts,2 ) from ct4" , + "select log(ts,2 ) from ct4" , "select log(c7,2 ) from ct4", "select log(c8,2 ) from ct4", "select log(c9,2 ) from ct4", - "select log(ts,2 ) from stb1" , + "select log(ts,2 ) from stb1" , "select log(c7,2 ) from stb1", "select log(c8,2 ) from stb1", "select log(c9,2 ) from stb1" , - "select log(ts,2 ) from stbbb1" , + "select log(ts,2 ) from stbbb1" , "select log(c7,2 ) from stbbb1", "select log(ts,2 ) from tbname", "select log(c9,2 ) from tbname" ] - + for type_sql in type_error_sql_lists: tdSql.error(type_sql) - - + + type_sql_lists = [ "select log(c1,2 ) from t1", "select log(c2,2 ) from t1", @@ -283,16 +283,16 @@ class TDTestCase: "select log(c5,2 ) from stb1", "select log(c6,2 ) from stb1", - "select log(c6,2) as alisb from stb1", - "select log(c6,2) alisb from stb1", + "select log(c6,2) as alisb from stb1", + "select log(c6,2) alisb from stb1", ] for type_sql in type_sql_lists: tdSql.query(type_sql) - + def basic_log_function(self): - # basic query + # basic query tdSql.query("select c1 from ct3") tdSql.checkRows(0) tdSql.query("select c1 from t1") @@ -344,7 +344,7 @@ class TDTestCase: self.check_result_auto_log2( "select c1, c2, c3 , c4, c5 from t1", "select log(c1 ,2), log(c2 ,2) ,log(c3, 2), log(c4 ,2), log(c5 ,2) from t1") self.check_result_auto_log1( "select c1, c2, c3 , c4, c5 from t1", "select log(c1 ,1), log(c2 ,1) ,log(c3, 1), log(c4 ,1), log(c5 ,1) from t1") self.check_result_auto_log__10( "select c1, c2, c3 , c4, c5 from t1", "select log(c1 ,-10), log(c2 ,-10) ,log(c3, -10), log(c4 ,-10), log(c5 ,-10) from t1") - + # used for sub table tdSql.query("select c1 ,log(c1 ,3) from ct1") tdSql.checkData(0, 1, 1.892789261) @@ -382,18 +382,18 @@ class TDTestCase: tdSql.checkData(4 , 2 , None) tdSql.checkData(4 , 3 , None) - # # used for stable table - + # # used for stable table + tdSql.query("select log(c1, 2) from stb1") tdSql.checkRows(25) - + # used for not exists table tdSql.error("select log(c1, 2) from stbbb1") tdSql.error("select log(c1, 2) from tbname") tdSql.error("select log(c1, 2) from ct5") - # mix with common col + # mix with common col tdSql.query("select c1, log(c1 ,2) from ct1") tdSql.checkData(0 , 0 ,8) tdSql.checkData(0 , 1 ,3.000000000) @@ -418,7 +418,7 @@ class TDTestCase: tdSql.checkData(0 , 1 ,None) tdSql.checkData(0 , 2 ,None) tdSql.checkData(0 , 3 ,None) - + tdSql.checkData(3 , 0 , 6) tdSql.checkData(3 , 1 , 2.584962501) tdSql.checkData(3 , 2 ,6.66000) @@ -439,7 +439,7 @@ class TDTestCase: tdSql.query("select max(c5), count(c5) from stb1") tdSql.query("select max(c5), count(c5) from ct1") - + # bug fix for count tdSql.query("select count(c1) from ct4 ") tdSql.checkData(0,0,9) @@ -450,7 +450,7 @@ class TDTestCase: tdSql.query("select count(*) from stb1 ") tdSql.checkData(0,0,25) - # # bug fix for compute + # # bug fix for compute tdSql.query("select c1, log(c1 ,2) -0 ,log(c1-4 ,2)-0 from ct4 ") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) @@ -507,40 +507,40 @@ class TDTestCase: # base is an regular number ,int or double tdSql.query("select c1, log(c1, 2) from ct1") tdSql.checkData(0, 1,3.000000000) - tdSql.query("select c1, log(c1, 2.0) from ct1") + tdSql.query("select c1, log(c1, 2.0) from ct1") tdSql.checkData(0, 1, 3.000000000) - tdSql.query("select c1, log(1, 2.0) from ct1") + tdSql.query("select c1, log(1, 2.0) from ct1") tdSql.checkData(0, 1, 0.000000000) tdSql.checkRows(13) # # bug for compute in functions - # tdSql.query("select c1, abs(1/0) from ct1") + # tdSql.query("select c1, abs(1/0) from ct1") # tdSql.checkData(0, 0, 8) # tdSql.checkData(0, 1, 1) - tdSql.query("select c1, log(1, 2.0) from ct1") + tdSql.query("select c1, log(1, 2.0) from ct1") tdSql.checkData(0, 1, 0.000000000) tdSql.checkRows(13) # two cols start log(x,y) - tdSql.query("select c1,c2, log(c1,c2) from ct1") + tdSql.query("select c1,c2, log(c1,c2) from ct1") tdSql.checkData(0, 2, 0.182485070) tdSql.checkData(1, 2, 0.172791608) tdSql.checkData(4, 2, None) - tdSql.query("select c1,c2, log(c2,c1) from ct1") + tdSql.query("select c1,c2, log(c2,c1) from ct1") tdSql.checkData(0, 2, 5.479900349) tdSql.checkData(1, 2, 5.787318105) tdSql.checkData(4, 2, None) - tdSql.query("select c1, log(2.0 , c1) from ct1") + tdSql.query("select c1, log(2.0 , c1) from ct1") tdSql.checkData(0, 1, 0.333333333) tdSql.checkData(1, 1, 0.356207187) tdSql.checkData(4, 1, None) - tdSql.query("select c1, log(2.0 , ceil(abs(c1))) from ct1") + tdSql.query("select c1, log(2.0 , ceil(abs(c1))) from ct1") tdSql.checkData(0, 1, 0.333333333) tdSql.checkData(1, 1, 0.356207187) tdSql.checkData(4, 1, None) @@ -580,10 +580,10 @@ class TDTestCase: tdSql.checkData(0,3,8.000000000) tdSql.checkData(0,4,7.900000000) tdSql.checkData(0,5,3.000000000) - + def log_Arithmetic(self): pass - + def check_boundary_values(self): tdSql.execute("drop database if exists bound_test") @@ -612,13 +612,13 @@ class TDTestCase: self.check_result_auto_log( "select c1, c2, c3 , c4, c5 ,c6 from sub1_bound ", "select log(c1), log(c2) ,log(c3), log(c4), log(c5) ,log(c6) from sub1_bound") self.check_result_auto_log2( "select c1, c2, c3 , c4, c5 ,c6 from sub1_bound ", "select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) ,log(c6,2) from sub1_bound") self.check_result_auto_log__10( "select c1, c2, c3 , c4, c5 ,c6 from sub1_bound ", "select log(c1,-10), log(c2,-10) ,log(c3,-10), log(c4,-10), log(c5,-10) ,log(c6,-10) from sub1_bound") - + self.check_result_auto_log2( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select log(c1,2), log(c2,2) ,log(c3,2), log(c3,2), log(c2,2) ,log(c1,2) from sub1_bound") self.check_result_auto_log( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select log(c1), log(c2) ,log(c3), log(c3), log(c2) ,log(c1) from sub1_bound") self.check_result_auto_log2("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select log(abs(c1) ,2) from sub1_bound" ) - + # check basic elem for table per row tdSql.query("select log(abs(c1),2) ,log(abs(c2),2) , log(abs(c3),2) , log(abs(c4),2), log(abs(c5),2), log(abs(c6),2) from sub1_bound ") tdSql.checkData(0,0,math.log(2147483647,2)) @@ -683,45 +683,45 @@ class TDTestCase: self.check_result_auto_log2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select log(t1,2) ,log(c5,2) from stb1 where c1 > 0 order by tbname" ) self.check_result_auto_log2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select log(t1,2) , log(c5,2) from stb1 where c1 > 0 order by tbname" ) pass - + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() tdLog.printNoPrefix("==========step1:create table ==============") - + self.prepare_datas() - tdLog.printNoPrefix("==========step2:test errors ==============") + tdLog.printNoPrefix("==========step2:test errors ==============") self.test_errors() - - tdLog.printNoPrefix("==========step3:support types ============") + + tdLog.printNoPrefix("==========step3:support types ============") self.support_types() - tdLog.printNoPrefix("==========step4: log basic query ============") + tdLog.printNoPrefix("==========step4: log basic query ============") self.basic_log_function() - tdLog.printNoPrefix("==========step5: big number log query ============") + tdLog.printNoPrefix("==========step5: big number log query ============") self.test_big_number() - tdLog.printNoPrefix("==========step6: base number for log query ============") + tdLog.printNoPrefix("==========step6: base number for log query ============") self.log_base_test() - tdLog.printNoPrefix("==========step7: log boundary query ============") + tdLog.printNoPrefix("==========step7: log boundary query ============") self.check_boundary_values() - tdLog.printNoPrefix("==========step8: log filter query ============") + tdLog.printNoPrefix("==========step8: log filter query ============") self.abs_func_filter() tdLog.printNoPrefix("==========step9: check log result of stable query ============") - self.support_super_table_test() + self.support_super_table_test() def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/query_cols_tags_and_or.py b/tests/system-test/2-query/query_cols_tags_and_or.py index c9df6f61bb9c661e3411a2ca21ab550315f17297..e0fb986d79d8491bf2bd23e82ccde85914c76541 100644 --- a/tests/system-test/2-query/query_cols_tags_and_or.py +++ b/tests/system-test/2-query/query_cols_tags_and_or.py @@ -50,7 +50,7 @@ class TDTestCase: tb_name = tdCom.getLongName(8, "letters") tdSql.execute( f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) tags (t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 binary(100), t8 nchar(200), t9 bool, t10 tinyint unsigned, t11 smallint unsigned, t12 int unsigned, t13 bigint unsigned)") - for i in range(1, count+1): + for i in range(1, count+1): tdSql.execute( f'CREATE TABLE {tb_name}_sub_{i} using {tb_name} tags ({i}, {i}, {i}, {i}, {i}.{i}, {i}.{i}, "binary{i}", "nchar{i}", true, {i}, {i}, {i}, {i})') self.insertData(f'{tb_name}_sub_{i}') @@ -412,7 +412,7 @@ class TDTestCase: query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c1 > 2 and c1 >= 3 or c1 < 1 or c1 <= 0 or c1 =2 or c1 != 1 or c1 <> 1 and c1 is null or c1 between 2 and 3 and c1 not between 1 and 1 and c1 in (2, 3) and c1 not in (1, 2)' res = tdSql.query(query_sql) tdSql.checkRows(1) - + def queryUtinyintCol(self, tb_name, check_elm=None): select_elm = "*" if check_elm is None else check_elm # > @@ -497,7 +497,7 @@ class TDTestCase: query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c10 > 2 and c10 >= 3 or c10 < 1 or c10 <= 0 or c10 =2 or c10 != 1 or c10 <> 1 and c10 is null or c10 between 2 and 3 and c10 not between 1 and 1 and c10 in (2, 3) and c10 not in (1, 2)' res = tdSql.query(query_sql) tdSql.checkRows(10) - + def querySmallintCol(self, tb_name, check_elm=None): select_elm = "*" if check_elm is None else check_elm # > @@ -582,7 +582,7 @@ class TDTestCase: query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c2 > 0 and c2 >= 1 or c2 < 4 and c2 <= 3 and c2 != 1 and c2 <> 2 and c2 = 3 or c2 is not null and c2 between 2 and 3 and c2 not between 1 and 2 and c2 in (2,3) and c2 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - + def queryUsmallintCol(self, tb_name, check_elm=None): select_elm = "*" if check_elm is None else check_elm # > @@ -752,7 +752,7 @@ class TDTestCase: query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c3 > 0 and c3 >= 1 or c3 < 5 and c3 <= 4 and c3 != 2 and c3 <> 2 and c3 = 4 or c3 is not null and c3 between 2 and 4 and c3 not between 1 and 2 and c3 in (2,4) and c3 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - + def queryUintCol(self, tb_name, check_elm=None): select_elm = "*" if check_elm is None else check_elm # > @@ -1086,7 +1086,7 @@ class TDTestCase: query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c5 > 0 and c5 >= 1 or c5 < 5 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 4 or c5 is not null and c5 between 2 and 4 and c5 not between 1 and 2 and c5 in (2,4) and c5 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - + def queryDoubleCol(self, tb_name, check_elm=None): select_elm = "*" if check_elm is None else check_elm # > @@ -1711,19 +1711,19 @@ class TDTestCase: tdSql.checkRows(4) tdSql.checkEqual(self.queryLastC10(query_sql), 7) - ## condition_A or (condition_B and condition_C) or (condition_D and condition_E) and condition_F + ## condition_A or (condition_B and condition_C) or (condition_D and condition_E) and condition_F query_sql = f'select * from {tb_name} where c1 != 1 or (c2 <= 1 and c3 <4) or (c3 >= 4 or c7 is not Null) and c9 <> true' tdSql.query(query_sql) tdSql.checkRows(3) tdSql.checkEqual(self.queryLastC10(query_sql), 10) - ## (condition_A or (condition_B and condition_C) or (condition_D and condition_E)) and condition_F + ## (condition_A or (condition_B and condition_C) or (condition_D and condition_E)) and condition_F query_sql = f'select * from {tb_name} where (c1 != 1 or (c2 <= 2 and c3 >= 4) or (c3 >= 4 or c7 is not Null)) and c9 != false' tdSql.query(query_sql) tdSql.checkRows(9) tdSql.checkEqual(self.queryLastC10(query_sql), 9) - ## (condition_A or condition_B) or (condition_C or condition_D) and (condition_E or condition_F or condition_G) + ## (condition_A or condition_B) or (condition_C or condition_D) and (condition_E or condition_F or condition_G) query_sql = f'select * from {tb_name} where c1 != 1 or (c2 <= 3 and c3 > 4) and c3 <= 5 and (c7 is not Null and c9 != false)' tdSql.query(query_sql) tdSql.checkRows(2) @@ -1780,17 +1780,17 @@ class TDTestCase: tdSql.query(query_sql) tdSql.checkRows(55) - ## condition_A or (condition_B and condition_C) or (condition_D and condition_E) and condition_F + ## condition_A or (condition_B and condition_C) or (condition_D and condition_E) and condition_F query_sql = f'select * from {tb_name} where t1 != 1 or (t2 <= 1 and t3 <4) or (t3 >= 4 or t7 is not Null) and t9 <> true' tdSql.query(query_sql) tdSql.checkRows(55) - ## (condition_A or (condition_B and condition_C) or (condition_D and condition_E)) and condition_F + ## (condition_A or (condition_B and condition_C) or (condition_D and condition_E)) and condition_F query_sql = f'select * from {tb_name} where (t1 != 1 or (t2 <= 2 and t3 >= 4) or (t3 >= 4 or t7 is not Null)) and t9 != false' tdSql.query(query_sql) tdSql.checkRows(55) - ## (condition_A or condition_B) or (condition_C or condition_D) and (condition_E or condition_F or condition_G) + ## (condition_A or condition_B) or (condition_C or condition_D) and (condition_E or condition_F or condition_G) query_sql = f'select * from {tb_name} where t1 != 1 or (t2 <= 3 and t3 > 4) and t3 <= 5 and (t7 is not Null and t9 != false)' tdSql.query(query_sql) tdSql.checkRows(44) @@ -2033,7 +2033,7 @@ class TDTestCase: self.checkColType(tb_name, check_elm) else: self.checkColType(stb_name, check_elm) - + def checkStbTagTypeOperator(self): ''' Super table full tag type and operator @@ -2089,7 +2089,7 @@ class TDTestCase: tb_name = self.initStb() self.queryColPreCal(f'{tb_name}_sub_1') self.queryTagPreCal(tb_name) - + def checkMultiTb(self): ''' test "or" in multi ordinary table @@ -2110,7 +2110,7 @@ class TDTestCase: ''' tb_name = self.initStb() self.queryMultiTbWithTag(tb_name) - + def checkMultiStbJoin(self): ''' join test diff --git a/tools/taos-tools b/tools/taos-tools index 69b558ccbfe54a4407fe23eeae2e67c540f59e55..0b8a3373bb7548f8106d13e7d3b0a988d3c4d48a 160000 --- a/tools/taos-tools +++ b/tools/taos-tools @@ -1 +1 @@ -Subproject commit 69b558ccbfe54a4407fe23eeae2e67c540f59e55 +Subproject commit 0b8a3373bb7548f8106d13e7d3b0a988d3c4d48a diff --git a/tools/taosws-rs b/tools/taosws-rs index 267a96fb09fc2ba14acfa47f7d3678def64c29c5..c5fded266d3b10508e38bf3285bb7ecf798bc343 160000 --- a/tools/taosws-rs +++ b/tools/taosws-rs @@ -1 +1 @@ -Subproject commit 267a96fb09fc2ba14acfa47f7d3678def64c29c5 +Subproject commit c5fded266d3b10508e38bf3285bb7ecf798bc343