diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index 1a08f2dc82..ffe5c2c1e0 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -18,7 +18,6 @@ // extern dependencies typedef struct { int32_t fid; - bool hasDataToCommit; STFileSet *fset; } SFileSetCommitInfo; @@ -512,36 +511,25 @@ _exit: return code; } -static int32_t tsdbCommitInfoAdd(STsdb *tsdb, const SFileSetCommitInfo *info) { +static int32_t tsdbCommitInfoAdd(STsdb *tsdb, int32_t fid) { int32_t code = 0; int32_t lino = 0; SFileSetCommitInfo *tinfo; - vHashGet(tsdb->commitInfo->ht, info, (void **)&tinfo); - if (tinfo) { - if (info->hasDataToCommit && !tinfo->hasDataToCommit) { - tinfo->hasDataToCommit = true; - } - } else { - if ((tinfo = taosMemoryCalloc(1, sizeof(*tinfo))) == NULL) { - TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit); - } - tinfo->fid = info->fid; - tinfo->hasDataToCommit = info->hasDataToCommit; - if (info->fset) { - code = tsdbTFileSetInitCopy(tsdb, info->fset, &tinfo->fset); - TSDB_CHECK_CODE(code, lino, _exit); - } - - code = vHashPut(tsdb->commitInfo->ht, tinfo); - TSDB_CHECK_CODE(code, lino, _exit); - - if ((taosArrayPush(tsdb->commitInfo->arr, &tinfo)) == NULL) { - TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit); - } - taosArraySort(tsdb->commitInfo->arr, tFileSetCommitInfoPCompare); + if ((tinfo = taosMemoryMalloc(sizeof(*tinfo))) == NULL) { + TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit); } + tinfo->fid = fid; + tinfo->fset = NULL; + + code = vHashPut(tsdb->commitInfo->ht, tinfo); + TSDB_CHECK_CODE(code, lino, _exit); + + if ((taosArrayPush(tsdb->commitInfo->arr, &tinfo)) == NULL) { + TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit); + } + taosArraySort(tsdb->commitInfo->arr, tFileSetCommitInfoPCompare); _exit: if (code) { @@ -560,20 +548,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) { code = tsdbCommitInfoInit(tsdb); TSDB_CHECK_CODE(code, lino, _exit); - taosThreadMutexLock(&tsdb->mutex); - TARRAY2_FOREACH(tsdb->pFS->fSetArr, fset) { - SFileSetCommitInfo info = { - .fid = fset->fid, - .hasDataToCommit = false, - .fset = fset, - }; - if ((code = tsdbCommitInfoAdd(tsdb, &info))) { - taosThreadMutexUnlock(&tsdb->mutex); - TSDB_CHECK_CODE(code, lino, _exit); - } - } - taosThreadMutexUnlock(&tsdb->mutex); - + // scan time-series data iter = tRBTreeIterCreate(tsdb->imem->tbDataTree, 1); for (SRBTreeNode *node = tRBTreeIterNext(&iter); node; node = tRBTreeIterNext(&iter)) { STbData *pTbData = TCONTAINER_OF(node, STbData, rbtn); @@ -598,34 +573,77 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) { fid = tsdbKeyFid(TSDBROW_TS(row), tsdb->keepCfg.days, tsdb->keepCfg.precision); tsdbFidKeyRange(fid, tsdb->keepCfg.days, tsdb->keepCfg.precision, &minKey, &maxKey); - SFileSetCommitInfo info = { - .fid = fid, - .hasDataToCommit = true, - .fset = NULL, + SFileSetCommitInfo *info; + SFileSetCommitInfo tinfo = { + .fid = fid, }; - code = tsdbCommitInfoAdd(tsdb, &info); - TSDB_CHECK_CODE(code, lino, _exit); + vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info); + if (info == NULL) { + code = tsdbCommitInfoAdd(tsdb, fid); + TSDB_CHECK_CODE(code, lino, _exit); + } from.key.ts = maxKey + 1; } + } - // scan tomb data - for (SDelData *pDelData = pTbData->pHead; pDelData; pDelData = pDelData->pNext) { - for (int32_t i = taosArrayGetSize(tsdb->commitInfo->arr) - 1; i >= 0; i--) { - int64_t minKey, maxKey; - SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i); + taosThreadMutexLock(&tsdb->mutex); - tsdbFidKeyRange(info->fid, tsdb->keepCfg.days, tsdb->keepCfg.precision, &minKey, &maxKey); + // scan tomb data + if (tsdb->imem->nDel > 0) { + TARRAY2_FOREACH(tsdb->pFS->fSetArr, fset) { + if (tsdbTFileSetIsEmpty(fset)) { + continue; + } - if (pDelData->sKey > maxKey || pDelData->eKey < minKey) { - continue; - } else if (!info->hasDataToCommit) { - info->hasDataToCommit = true; + SFileSetCommitInfo *info; + SFileSetCommitInfo tinfo = { + .fid = fset->fid, + }; + + // check if the file set already on the commit list + vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info); + if (info != NULL) { + continue; + } + + int64_t minKey, maxKey; + bool hasDataToCommit = false; + tsdbFidKeyRange(fset->fid, tsdb->keepCfg.days, tsdb->keepCfg.precision, &minKey, &maxKey); + iter = tRBTreeIterCreate(tsdb->imem->tbDataTree, 1); + for (SRBTreeNode *node = tRBTreeIterNext(&iter); node; node = tRBTreeIterNext(&iter)) { + STbData *pTbData = TCONTAINER_OF(node, STbData, rbtn); + for (SDelData *pDelData = pTbData->pHead; pDelData; pDelData = pDelData->pNext) { + if (pDelData->sKey > maxKey || pDelData->eKey < minKey) { + continue; + } else { + hasDataToCommit = true; + if ((code = tsdbCommitInfoAdd(tsdb, fset->fid))) { + taosThreadMutexUnlock(&tsdb->mutex); + TSDB_CHECK_CODE(code, lino, _exit); + } + break; + } + } + + if (hasDataToCommit) { + break; } } } } + // begin tasks on file set + for (int i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) { + SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i); + tsdbBeginTaskOnFileSet(tsdb, info->fid, &fset); + if (fset) { + tsdbTFileSetInitCopy(tsdb, fset, &info->fset); + } + } + + taosThreadMutexUnlock(&tsdb->mutex); + _exit: if (code) { tsdbCommitInfoDestroy(tsdb); @@ -653,16 +671,6 @@ static int32_t tsdbOpenCommitter(STsdb *tsdb, SCommitInfo *info, SCommitter2 *co code = tsdbCommitInfoBuild(tsdb); TSDB_CHECK_CODE(code, lino, _exit); - STFileSet *fset; - taosThreadMutexLock(&tsdb->mutex); - for (int i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) { - SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i); - if (info->hasDataToCommit && info->fset) { - tsdbBeginTaskOnFileSet(tsdb, info->fid, &fset); - } - } - taosThreadMutexUnlock(&tsdb->mutex); - _exit: if (code) { TSDB_ERROR_LOG(TD_VID(tsdb->pVnode), lino, code); @@ -735,10 +743,8 @@ int32_t tsdbCommitBegin(STsdb *tsdb, SCommitInfo *info) { for (int32_t i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) { committer.ctx->info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i); - if (committer.ctx->info->hasDataToCommit) { - code = tsdbCommitFileSet(&committer); - TSDB_CHECK_CODE(code, lino, _exit); - } + code = tsdbCommitFileSet(&committer); + TSDB_CHECK_CODE(code, lino, _exit); } code = tsdbCloseCommitter(&committer, code); @@ -771,7 +777,7 @@ int32_t tsdbCommitCommit(STsdb *tsdb) { for (int32_t i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) { SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i); - if (info->hasDataToCommit && info->fset) { + if (info->fset) { tsdbFinishTaskOnFileSet(tsdb, info->fid); } } @@ -803,7 +809,7 @@ int32_t tsdbCommitAbort(STsdb *pTsdb) { taosThreadMutexLock(&pTsdb->mutex); for (int32_t i = 0; i < taosArrayGetSize(pTsdb->commitInfo->arr); i++) { SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(pTsdb->commitInfo->arr, i); - if (info->hasDataToCommit && info->fset) { + if (info->fset) { tsdbFinishTaskOnFileSet(pTsdb, info->fid); } } diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.c b/source/dnode/vnode/src/tsdb/tsdbFS2.c index 3087dc44d9..2345cc599b 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.c @@ -1181,7 +1181,7 @@ int32_t tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) { int16_t sttTrigger = tsdb->pVnode->config.sttTrigger; tsdbFSGetFSet(tsdb->pFS, fid, fset); - if (sttTrigger == 1 && fset) { + if (sttTrigger == 1 && (*fset)) { for (;;) { if ((*fset)->taskRunning) { (*fset)->numWaitTask++; diff --git a/source/libs/monitorfw/inc/taos_linked_list_i.h b/source/libs/monitorfw/inc/taos_linked_list_i.h index ed11a76427..015f8a57ad 100644 --- a/source/libs/monitorfw/inc/taos_linked_list_i.h +++ b/source/libs/monitorfw/inc/taos_linked_list_i.h @@ -47,7 +47,7 @@ int taos_linked_list_push(taos_linked_list_t *self, void *item); /** * @brief API PRIVATE Pop the first item off of the list */ -void *taos_linked_list_pop(taos_linked_list_t *self); +//void *taos_linked_list_pop(taos_linked_list_t *self); /** * @brief API PRIVATE Returns the item at the head of the list or NULL if not present diff --git a/source/libs/monitorfw/src/taos_collector.c b/source/libs/monitorfw/src/taos_collector.c index 17d324462c..414c02121d 100644 --- a/source/libs/monitorfw/src/taos_collector.c +++ b/source/libs/monitorfw/src/taos_collector.c @@ -33,6 +33,8 @@ taos_map_t *taos_collector_default_collect(taos_collector_t *self) { return self taos_collector_t *taos_collector_new(const char *name) { int r = 0; taos_collector_t *self = (taos_collector_t *)taos_malloc(sizeof(taos_collector_t)); + if (self == NULL) return NULL; + memset(self, 0, sizeof(taos_collector_t)); self->name = taos_strdup(name); self->metrics = taos_map_new(); if (self->metrics == NULL) { @@ -66,9 +68,11 @@ int taos_collector_destroy(taos_collector_t *self) { if (r) ret = r; self->metrics = NULL; - r = taos_string_builder_destroy(self->string_builder); - if (r) ret = r; - self->string_builder = NULL; + if(self->string_builder != NULL){ + r = taos_string_builder_destroy(self->string_builder); + if (r) ret = r; + self->string_builder = NULL; + } taos_free((char *)self->name); self->name = NULL; diff --git a/source/libs/monitorfw/src/taos_collector_registry.c b/source/libs/monitorfw/src/taos_collector_registry.c index c3ed0112c5..d4838ef301 100644 --- a/source/libs/monitorfw/src/taos_collector_registry.c +++ b/source/libs/monitorfw/src/taos_collector_registry.c @@ -59,6 +59,7 @@ taos_collector_registry_t *taos_collector_registry_new(const char *name) { r = pthread_rwlock_init(self->lock, NULL); if (r) { TAOS_LOG("failed to initialize rwlock"); + taos_free(self); return NULL; } return self; @@ -301,6 +302,9 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self, _OVER: tjsonDelete(pJson); + if(tmp_builder != NULL){ + taos_string_builder_destroy(tmp_builder); + } return NULL; } diff --git a/source/libs/monitorfw/src/taos_linked_list.c b/source/libs/monitorfw/src/taos_linked_list.c index 675400a6fa..2becb08a07 100644 --- a/source/libs/monitorfw/src/taos_linked_list.c +++ b/source/libs/monitorfw/src/taos_linked_list.c @@ -117,6 +117,7 @@ int taos_linked_list_push(taos_linked_list_t *self, void *item) { return 0; } +/* void *taos_linked_list_pop(taos_linked_list_t *self) { TAOS_ASSERT(self != NULL); if (self == NULL) return NULL; @@ -141,6 +142,7 @@ void *taos_linked_list_pop(taos_linked_list_t *self) { } return item; } +*/ int taos_linked_list_remove(taos_linked_list_t *self, void *item) { TAOS_ASSERT(self != NULL); diff --git a/source/libs/monitorfw/src/taos_map.c b/source/libs/monitorfw/src/taos_map.c index 8f0b83884e..ffb7d000fc 100644 --- a/source/libs/monitorfw/src/taos_map.c +++ b/source/libs/monitorfw/src/taos_map.c @@ -90,7 +90,7 @@ taos_map_t *taos_map_new() { return NULL; } - self->addrs = taos_malloc(sizeof(taos_linked_list_t) * self->max_size); + self->addrs = taos_malloc(sizeof(taos_linked_list_t*) * self->max_size); self->free_value_fn = destroy_map_node_value_no_op; for (int i = 0; i < self->max_size; i++) { @@ -273,7 +273,7 @@ int taos_map_ensure_space(taos_map_t *self) { if (r) return r; // Create a new array of addrs - taos_linked_list_t **new_addrs = taos_malloc(sizeof(taos_linked_list_t) * new_max); + taos_linked_list_t **new_addrs = taos_malloc(sizeof(taos_linked_list_t*) * new_max); // Initialize the new array for (int i = 0; i < new_max; i++) { diff --git a/source/libs/monitorfw/src/taos_metric.c b/source/libs/monitorfw/src/taos_metric.c index 4e9af35f34..5cecbc927f 100644 --- a/source/libs/monitorfw/src/taos_metric.c +++ b/source/libs/monitorfw/src/taos_metric.c @@ -33,6 +33,8 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name, size_t label_key_count, const char **label_keys) { int r = 0; taos_metric_t *self = (taos_metric_t *)taos_malloc(sizeof(taos_metric_t)); + if (self == NULL) return NULL; + memset(self, 0, sizeof(taos_metric_t)); self->type = metric_type; int len = strlen(name) + 1; self->name = taos_malloc(len); @@ -79,6 +81,7 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name, r = pthread_rwlock_init(self->rwlock, NULL); if (r) { TAOS_LOG(TAOS_PTHREAD_RWLOCK_INIT_ERROR); + taos_free(self); return NULL; } return self; @@ -91,9 +94,11 @@ int taos_metric_destroy(taos_metric_t *self) { int r = 0; int ret = 0; - r = taos_map_destroy(self->samples); - self->samples = NULL; - if (r) ret = r; + if(self->samples != NULL){ + r = taos_map_destroy(self->samples); + self->samples = NULL; + if (r) ret = r; + } r = taos_metric_formatter_destroy(self->formatter); self->formatter = NULL; @@ -152,8 +157,7 @@ taos_metric_sample_t *taos_metric_sample_from_labels(taos_metric_t *self, const return NULL; // Get l_value - r = taos_metric_formatter_load_l_value(self->formatter, self->name, NULL, self->label_key_count, self->label_keys, - label_values); + r = taos_metric_formatter_load_l_value(self->formatter, self->name, NULL, self->label_key_count, self->label_keys, label_values); if (r) { TAOS_METRIC_SAMPLE_FROM_LABELS_HANDLE_UNLOCK(); } @@ -170,10 +174,12 @@ taos_metric_sample_t *taos_metric_sample_from_labels(taos_metric_t *self, const sample = taos_metric_sample_new(self->type, l_value, 0.0); r = taos_map_set(self->samples, l_value, sample); if (r) { + taos_free((void *)l_value); TAOS_METRIC_SAMPLE_FROM_LABELS_HANDLE_UNLOCK(); } } - pthread_rwlock_unlock(self->rwlock); + r = pthread_rwlock_unlock(self->rwlock); + if (r) TAOS_LOG(TAOS_PTHREAD_RWLOCK_UNLOCK_ERROR); taos_free((void *)l_value); return sample; } diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp index c52a8599a0..6d2215264e 100644 --- a/source/libs/scheduler/test/schedulerTests.cpp +++ b/source/libs/scheduler/test/schedulerTests.cpp @@ -798,6 +798,7 @@ TEST(queryTest, normalCase) { schedulerFreeJob(&job, 0); + taosThreadJoin(thread1, NULL); } TEST(queryTest, readyFirstCase) { @@ -907,6 +908,8 @@ TEST(queryTest, readyFirstCase) { schedulerDestroy(); schedulerFreeJob(&job, 0); + + taosThreadJoin(thread1, NULL); } TEST(queryTest, flowCtrlCase) { @@ -1001,6 +1004,8 @@ TEST(queryTest, flowCtrlCase) { schedulerDestroy(); schedulerFreeJob(&job, 0); + + taosThreadJoin(thread1, NULL); } TEST(insertTest, normalCase) { @@ -1061,6 +1066,8 @@ TEST(insertTest, normalCase) { schedulerFreeJob(&insertJobRefId, 0); schedulerDestroy(); + + taosThreadJoin(thread1, NULL); } TEST(multiThread, forceFree) { diff --git a/tests/army/enterprise/alter/alterConfig.py b/tests/army/enterprise/alter/alterConfig.py new file mode 100644 index 0000000000..7413e5e5a6 --- /dev/null +++ b/tests/army/enterprise/alter/alterConfig.py @@ -0,0 +1,55 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time + +import taos +import frame +import frame.etool + +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame import * + + +class TDTestCase(TBase): + def alterSupportVnodes(self): + tdLog.info(f"test function of altering supportVnodes") + + tdSql.execute("alter dnode 1 'supportVnodes' '128'") + time.sleep(1) + tdSql.query('show dnodes') + tdSql.checkData(0, 3, "128") + + tdSql.execute("alter dnode 1 'supportVnodes' '64'") + time.sleep(1) + tdSql.query('show dnodes') + tdSql.checkData(0, 3, "64") + + # run + def run(self): + tdLog.debug(f"start to excute {__file__}") + + # TS-4721 + self.alterSupportVnodes() + + + tdLog.success(f"{__file__} successfully executed") + + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/army/enterprise/db-encrypt/basic.py b/tests/army/enterprise/db-encrypt/basic.py new file mode 100644 index 0000000000..8d30bbcfe2 --- /dev/null +++ b/tests/army/enterprise/db-encrypt/basic.py @@ -0,0 +1,63 @@ +import taos +import sys +import os +import subprocess +import glob +import shutil +import time + +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.srvCtl import * +from frame.caseBase import * +from frame import * +from frame.autogen import * +# from frame.server.dnodes import * +# from frame.server.cluster import * + + +class TDTestCase(TBase): + + def init(self, conn, logSql, replicaVar=1): + super(TDTestCase, self).init(conn, logSql, replicaVar=1, checkColName="c1") + self.valgrind = 0 + self.db = "test" + self.stb = "meters" + self.childtable_count = 10 + tdSql.init(conn.cursor(), logSql) + + def create_encrypt_db(self): + + tdSql.execute("create encrypt_key '1234567890'") + autoGen = AutoGen() + autoGen.create_db(self.db, 2, 1, "ENCRYPT_ALGORITHM 'sm4'") + tdSql.execute(f"use {self.db}") + autoGen.create_stable(self.stb, 2, 3, 8, 8) + autoGen.create_child(self.stb, "d", self.childtable_count) + autoGen.insert_data(1000) + + tdSql.query(f"select * from {self.db}.{self.stb}") + tdSql.checkRows(1000 * self.childtable_count) + + self.timestamp_step = 1000 + self.insert_rows = 1000 + + self.checkInsertCorrect() + + def create_encrypt_db_error(self): + tdSql.error("create encrypt_key '123'") + tdSql.error("create encrypt_key '12345678abcdefghi'") + tdSql.error("create database test ENCRYPT_ALGORITHM 'sm4'") + + def run(self): + self.create_encrypt_db_error() + self.create_encrypt_db() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index e989cb20c7..61687eeccd 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -11,6 +11,7 @@ # army-test # ,,y,army,./pytest.sh python3 ./test.py -f enterprise/multi-level/mlevel_basic.py -N 3 -L 3 -D 2 +,,y,army,./pytest.sh python3 ./test.py -f enterprise/db-encrypt/basic.py ,,n,army,python3 ./test.py -f enterprise/s3/s3Basic.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f community/cluster/snapshot.py -N 3 -L 3 -D 2 ,,y,army,./pytest.sh python3 ./test.py -f community/query/function/test_func_elapsed.py @@ -25,6 +26,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f community/cluster/splitVgroupByLearner.py -N 3 ,,n,army,python3 ./test.py -f community/cmdline/fullopt.py ,,n,army,python3 ./test.py -f community/query/show.py -N 3 +,,n,army,python3 ./test.py -f enterprise/alter/alterConfig.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f community/storage/oneStageComp.py -N 3 -L 3 -D 1 ,,y,army,./pytest.sh python3 ./test.py -f community/storage/compressBasic.py -N 3 diff --git a/tests/system-test/2-query/interp.py b/tests/system-test/2-query/interp.py index 81c5b66185..1cb95b59c5 100644 --- a/tests/system-test/2-query/interp.py +++ b/tests/system-test/2-query/interp.py @@ -15,6 +15,30 @@ class TDTestCase: #tdSql.init(conn.cursor()) tdSql.init(conn.cursor(), logSql) # output sql.txt file + def interp_on_empty_table(self): + dbname = "db" + tbname = "t" + + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table") + + tdSql.execute(f'''create table if not exists {dbname}.{tbname} (ts timestamp, k int)''') + + tdLog.printNoPrefix("==========step2:interp query on empty table") + + tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(prev)") + tdSql.checkRows(0) + + tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(next)") + tdSql.checkRows(0) + + tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(linear)") + tdSql.checkRows(0) + + 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) + def run(self): dbname = "db" tbname = "tb" @@ -5658,6 +5682,7 @@ class TDTestCase: tdSql.checkData(0, 0, '2023-08-06 23:59:00') tdSql.checkData(0, 1, None) + self.interp_on_empty_table() def stop(self):