提交 c27476bd 编写于 作者: C cpwu

Merge branch '3.0' into cpwu/3.0

......@@ -479,6 +479,8 @@ typedef struct SAggOperatorInfo {
uint64_t groupId;
SGroupResInfo groupResInfo;
SExprSupp scalarExprSup;
SNode *pCondition;
} SAggOperatorInfo;
typedef struct SProjectOperatorInfo {
......@@ -680,6 +682,8 @@ typedef struct SSortOperatorInfo {
int64_t startTs; // sort start time
uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included.
SNode* pCondition;
} SSortOperatorInfo;
typedef struct STagFilterOperatorInfo {
......@@ -758,7 +762,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo);
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, const char* pUser, SExecTaskInfo* pTaskInfo);
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo,
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SNode* pCondition, SExprInfo* pScalarExprInfo,
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo);
SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode *pNode, SExecTaskInfo* pTaskInfo);
......
......@@ -3012,11 +3012,19 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) {
}
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
while (1) {
doBuildResultDatablock(pOperator, pInfo, &pAggInfo->groupResInfo, pAggInfo->aggSup.pResultBuf);
if (pInfo->pRes->info.rows == 0 || !hasDataInGroupInfo(&pAggInfo->groupResInfo)) {
doFilter(pAggInfo->pCondition, pInfo->pRes);
if (!hasDataInGroupInfo(&pAggInfo->groupResInfo)) {
doSetOperatorCompleted(pOperator);
break;
}
if (pInfo->pRes->info.rows > 0) {
break;
}
}
size_t rows = blockDataGetNumOfRows(pInfo->pRes);
pOperator->resultInfo.totalRows += rows;
......@@ -3557,7 +3565,7 @@ int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr) {
}
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo,
SSDataBlock* pResultBlock, SNode* pCondition, SExprInfo* pScalarExprInfo,
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo) {
SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo));
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
......@@ -3581,6 +3589,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
}
pInfo->groupId = INT32_MIN;
pInfo->pCondition = pCondition;
pOperator->name = "TableAggregate";
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_HASH_AGG;
pOperator->blocking = true;
......@@ -4328,7 +4337,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
pScalarExprInfo, numOfScalarExpr, pTaskInfo);
} else {
pOptr =
createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pScalarExprInfo, numOfScalarExpr, pTaskInfo);
createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo);
}
} else if (QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL == type || QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type) {
SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode;
......
......@@ -46,7 +46,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
initResultSizeInfo(pOperator, 1024);
pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys);
;
pInfo->pCondition = pSortPhyNode->node.pConditions;
pInfo->pColMatchInfo = pColMatchColInfo;
pOperator->name = "SortOperator";
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT;
......@@ -205,14 +205,27 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
longjmp(pTaskInfo->env, code);
}
SSDataBlock* pBlock = getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity,
SSDataBlock* pBlock = NULL;
while (1) {
pBlock = getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity,
pInfo->pColMatchInfo, pInfo);
if (pBlock != NULL) {
doFilter(pInfo->pCondition, pBlock);
}
if (pBlock == NULL) {
doSetOperatorCompleted(pOperator);
break;
}
if (blockDataGetNumOfRows(pBlock) > 0) {
break;
}
}
if (pBlock != NULL) {
pOperator->resultInfo.totalRows += pBlock->info.rows;
} else {
doSetOperatorCompleted(pOperator);
}
return pBlock;
}
......
......@@ -1615,26 +1615,27 @@ static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
}
SExprNode* pPara0 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
SExprNode* p1 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 1);
SExprNode* pPara1 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 1);
uint8_t para1Type = p1->resType.type;
if (!IS_VAR_DATA_TYPE(pPara0->resType.type) || !IS_INTEGER_TYPE(para1Type)) {
uint8_t para0Type = pPara0->resType.type;
uint8_t para1Type = pPara1->resType.type;
if (!IS_VAR_DATA_TYPE(para0Type) || !IS_INTEGER_TYPE(para1Type)) {
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
}
if (((SValueNode*)p1)->datum.i < 1) {
if (((SValueNode*)pPara1)->datum.i == 0) {
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
}
if (3 == numOfParams) {
SExprNode* p2 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 2);
uint8_t para2Type = p2->resType.type;
SExprNode* pPara2 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 2);
uint8_t para2Type = pPara2->resType.type;
if (!IS_INTEGER_TYPE(para2Type)) {
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
}
int64_t v = ((SValueNode*)p1)->datum.i;
if (v < 0 || v > INT16_MAX) {
int64_t v = ((SValueNode*)pPara2)->datum.i;
if (v < 0) {
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
}
}
......
......@@ -376,8 +376,6 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
char* jsonKey = item->string;
if (!isValidateTag(jsonKey)) {
fprintf(stdout, "%s(%d) %s %08" PRId64 "\n", __FILE__, __LINE__, __func__, taosGetSelfPthreadId());
fflush(stdout);
retCode = buildSyntaxErrMsg(pMsgBuf, "json key not validate", jsonKey);
goto end;
}
......
......@@ -40,7 +40,7 @@ int32_t schSwitchJobStatus(SSchJob* pJob, int32_t status, void* param) {
SCH_RET(schProcessOnJobFailure(pJob, (param ? *(int32_t*)param : 0)));
break;
case JOB_TASK_STATUS_DROP:
SCH_ERR_JRET(schProcessOnJobDropped(pJob, *(int32_t*)param));
schProcessOnJobDropped(pJob, *(int32_t*)param);
if (taosRemoveRef(schMgmt.jobRef, pJob->refId)) {
SCH_JOB_ELOG("remove job from job list failed, refId:0x%" PRIx64, pJob->refId);
......
......@@ -144,11 +144,9 @@ void schedulerFreeJob(int64_t* jobId, int32_t errCode) {
return;
}
if (schJobDone(pJob)) {
return;
}
schSwitchJobStatus(pJob, JOB_TASK_STATUS_DROP, (void*)&errCode);
schReleaseJob(*jobId);
*jobId = 0;
}
......
......@@ -260,6 +260,14 @@ char *taosDirName(char *name) {
name[0] = 0;
}
return name;
#elif defined(_TD_DARWIN_64)
char *end = strrchr(name, '/');
if (end != NULL) {
*end = '\0';
} else {
name[0] = 0;
}
return name;
#else
return dirname(name);
#endif
......
......@@ -947,9 +947,9 @@ int32_t taosGetFqdn(char *fqdn) {
hostname[1023] = '\0';
if (gethostname(hostname, 1023) == -1) {
#ifdef WINDOWS
printf("failed to get hostname, reason:%s", strerror(WSAGetLastError()));
printf("failed to get hostname, reason:%s\n", strerror(WSAGetLastError()));
#else
printf("failed to get hostname, reason:%s", strerror(errno));
printf("failed to get hostname, reason:%s\n", strerror(errno));
#endif
assert(0);
return -1;
......@@ -968,7 +968,7 @@ int32_t taosGetFqdn(char *fqdn) {
#endif // __APPLE__
int32_t ret = getaddrinfo(hostname, NULL, &hints, &result);
if (!result) {
fprintf(stderr, "failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret));
fprintf(stderr, "failed to get fqdn, code:%d, reason:%s\n", ret, gai_strerror(ret));
return -1;
}
......
......@@ -759,9 +759,11 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
return 0;
#elif defined(_TD_DARWIN_64)
uuid_t uuid = {0};
char buf[37] = {0};
uuid_generate(uuid);
// it's caller's responsibility to make enough space for `uid`, that's 36-char + 1-null
uuid_unparse_lower(uuid, uid);
uuid_unparse_lower(uuid, buf);
memcpy(uid, buf, uidlen);
return 0;
#else
int len = 0;
......
......@@ -218,13 +218,13 @@ class TDTestCase:
tdLog.debug("assert 8th case %s"%rows)
assert rows[0][0] == 3, ' 8th case is failed'
# #query: selector Functions 9
# queryparam=new_bind_params(1)
# queryparam[0].int(2)
# rows=self.stmtExe(conn,"select bottom(bu,?) from log group by bu ; ",queryparam)
# tdLog.debug("assert 9th case %s"%rows)
# assert rows[0][0] == 4, ' 9 case is failed'
# assert rows[1][0] == 3, ' 9 case is failed'
#query: selector Functions 9
queryparam=new_bind_params(1)
queryparam[0].int(2)
rows=self.stmtExe(conn,"select bottom(bu,?) from log group by bu order by bu desc ; ",queryparam)
tdLog.debug("assert 9th case %s"%rows)
assert rows[1][0] == 4, ' 9 case is failed'
assert rows[2][0] == 3, ' 9 case is failed'
# #query: time-series specific Functions 10
......
......@@ -123,10 +123,10 @@ class TDTestCase:
elif unit.lower() == '1u':
for i in range(len(self.ts_str)):
tdSql.checkEqual(tdSql.queryResult[i][0],int(((date_time[i]/1000)-self.subtractor*1000000)))
# self.check_tbtype(tb_type)
# tdSql.checkRows(len(self.ts_str))
# for i in range(len(self.ts_str)):
# tdSql.checkEqual(tdSql.queryResult[i][0],int(((date_time[i]/1000000)-self.subtractor*1000000000)))
self.check_tbtype(tb_type)
tdSql.checkRows(len(self.ts_str))
for i in range(len(self.ts_str)):
tdSql.checkEqual(tdSql.queryResult[i][0],int(((date_time[i])-self.subtractor*1000000000)))
for unit in self.error_unit:
if tb_type.lower() == 'ntb':
tdSql.error(f'select timediff(ts,{self.subtractor},{unit}) from {self.ntbname}')
......
import taos
import sys
import datetime
import inspect
from util.log import *
from util.sql import *
from util.cases import *
import random
class TDTestCase:
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, "fnDebugFlag": 143}
def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor(), True)
self.tb_nums = 10
self.row_nums = 20
self.ts = 1434938400000
self.time_step = 1000
def insert_datas_and_check_abs(self ,tbnums , rownums , time_step ):
tdLog.info(" prepare datas for auto check abs function ")
tdSql.execute(" create database test ")
tdSql.execute(" use test ")
tdSql.execute(" create stable stb (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint,\
c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int)")
for tbnum in range(tbnums):
tbname = "sub_tb_%d"%tbnum
tdSql.execute(" create table %s using stb tags(%d) "%(tbname , tbnum))
ts = self.ts
for row in range(rownums):
ts = self.ts + time_step*row
c1 = random.randint(0,10000)
c2 = random.randint(0,100000)
c3 = random.randint(0,125)
c4 = random.randint(0,125)
c5 = random.random()/1.0
c6 = random.random()/1.0
c7 = "'true'"
c8 = "'binary_val'"
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"]
for tbname in tbnames:
tdSql.query("desc {}".format(tbname))
coltypes = tdSql.queryResult
colnames = []
for coltype in coltypes:
colname = coltype[0]
if coltype[1] in support_types:
colnames.append(colname)
cols = random.sample(colnames,3)
self.check_function("&",False,tbname,cols[0],cols[1],cols[2])
self.check_function("|",False,tbname,cols[0],cols[1],cols[2])
def prepare_datas(self):
tdSql.execute(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql.execute(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
for i in range(9):
tdSql.execute(
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
)
tdSql.execute(
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
)
tdSql.execute(
"insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
tdSql.execute(
"insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute(
"insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute(
"insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute(
"insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute(
"insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute(
"insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute(
f'''insert into t1 values
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
def prepare_tag_datas(self):
# prepare datas
tdSql.execute(
"create database if not exists testdb keep 3650 duration 1000")
tdSql.execute(" use testdb ")
tdSql.execute(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
'''
)
tdSql.execute(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for i in range(4):
tdSql.execute(
f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
for i in range(9):
tdSql.execute(
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
)
tdSql.execute(
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
)
tdSql.execute(
"insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
tdSql.execute(
"insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute(
"insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute(
"insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute(
"insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute(
"insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute(
"insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute(
f'''insert into t1 values
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
def check_result_auto(self, origin_query, abs_query):
abs_result = tdSql.getResult(abs_query)
origin_result = tdSql.getResult(origin_query)
auto_result = []
for row in origin_result:
row_check = []
for elem in row:
if elem == None:
elem = None
elif elem >= 0:
elem = elem
else:
elem = -elem
row_check.append(elem)
auto_result.append(row_check)
check_status = True
for row_index, row in enumerate(abs_result):
for col_index, elem in enumerate(row):
if auto_result[row_index][col_index] != elem:
check_status = False
if not check_status:
tdLog.notice(
"abs function value has not as expected , sql is \"%s\" " % abs_query)
sys.exit(1)
else:
tdLog.info(
"abs value check pass , it work as expected ,sql is \"%s\" " % abs_query)
def check_function(self, opera ,agg, tbname , *args):
if opera =="&":
pass
elif opera =="|":
pass
else:
pass
work_sql = " select "
for ind , arg in enumerate(args):
if ind ==len(args)-1:
work_sql += f"cast({arg} as bigint) "
else:
work_sql += f"cast({arg} as bigint){opera}"
if not agg:
work_sql+= f" from {tbname} order by ts"
else:
work_sql+= f" from {tbname} "
tdSql.query(work_sql)
work_result = tdSql.queryResult
origin_sql = " select "
for ind , arg in enumerate(args):
if ind ==len(args)-1:
origin_sql += f"cast({arg} as bigint) "
else:
origin_sql += f"cast({arg} as bigint),"
if not agg:
origin_sql+= f" from {tbname} order by ts"
else:
origin_sql+= f" from {tbname} "
tdSql.query(origin_sql)
origin_result = tdSql.queryResult
# compute and or with byte in binary data
compute_result = []
for row in origin_result:
if None in row:
compute_result.append(None)
else:
if opera == "&":
result = row[0]
for elem in row:
result = result&elem
elif opera == "|":
result = row[0]
for elem in row:
result = result|elem
compute_result.append(result)
tdSql.query(work_sql)
for ind , result in enumerate(compute_result):
tdSql.checkData(ind,0,result)
def test_errors(self):
tdSql.execute("use testdb")
error_sql_lists = [
"select c1&&c2 from t1",
"select c1&|c2 from t1",
"select c1&(c1=c2) from t1",
"select c1&* from t1",
"select 123&, from t1",
"select 123&\" from t1",
"select c1&- from t1;",
"select c1&&= from t1)",
"select c1&! from t1",
"select c1&@ from stb1",
"select c1&# from stb1",
"select c1&$ from stb1",
"select c1&% from stb1",
"select c1&() from stb1",
]
for error_sql in error_sql_lists:
tdSql.error(error_sql)
def basic_query(self):
# basic query
tdSql.query("select c1&c2|c3 from ct1")
tdSql.checkRows(13)
tdSql.query("select c1 ,c2&c3, c1&c2&c3 from t1")
tdSql.checkRows(12)
tdSql.query("select c1 ,c1&c1&c1|c1 from stb1")
tdSql.checkRows(25)
# used for empty table , ct3 is empty
tdSql.query("select abs(c1)&c2&c3 from ct3")
tdSql.checkRows(0)
tdSql.query("select abs(c2&c1&c3) from ct3")
tdSql.checkRows(0)
tdSql.query("select abs(c3)+c1&c3+c2 from ct3")
tdSql.checkRows(0)
tdSql.query("select abs(c1)&c2&c3 from ct4")
tdSql.checkRows(12)
tdSql.checkData(0,0,None)
tdSql.checkData(1,0,8)
tdSql.checkData(10,0,0)
tdSql.query("select abs(c2&c1&c3) from ct4")
tdSql.checkRows(12)
tdSql.checkData(0,0,None)
tdSql.checkData(1,0,8)
tdSql.checkData(10,0,0)
tdSql.query("select (abs(c3)+c1)&(c3+c2) from ct4")
tdSql.checkRows(12)
tdSql.checkData(0,0,None)
tdSql.checkData(1,0,640)
tdSql.checkData(10,0,0)
# used for regular table
tdSql.query("select abs(c1)&c3&c3 from t1")
tdSql.checkData(0, 0, None)
tdSql.checkData(1, 0, 1)
tdSql.checkData(3, 0, 1)
tdSql.checkData(5, 0, None)
tdSql.query("select abs(c1)&c2|ceil(c3)&c4|floor(c5) from t1")
tdSql.checkData(1, 0, 11)
tdSql.checkData(3, 0, 3)
tdSql.checkData(5, 0, None)
tdSql.query("select ts,c1, c2, c3&c4|c5 from t1")
tdSql.checkData(1, 3, 11)
tdSql.checkData(3, 3, 3)
tdSql.checkData(5, 3, None)
self.check_function("&",False,"stb1","c1","ceil(c2)","abs(c3)","c4+1")
self.check_function("|",False,"stb1","c1","ceil(c2)","abs(c3)","c4+1")
self.check_function("&",False,"stb1","c1+c2","ceil(c2)","abs(c3+c2)","c4+1")
self.check_function("&",False,"ct4","123","ceil(c2)","abs(c3+c2)","c4+1")
self.check_function("&",False,"ct4","123","ceil(t1)","abs(c3+c2)","c4+1")
self.check_function("&",False,"ct4","t1+c1","-ceil(t1)","abs(c3+c2)","c4+1")
self.check_function("&",False,"stb1","c1","floor(t1)","abs(c1+c2)","t1+1")
self.check_function("&",True,"stb1","max(c1)","min(floor(t1))","sum(abs(c1+c2))","last(t1)+1")
self.check_function("&",False,"stb1","abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))))","floor(t1)","abs(c1+c2)","t1+1")
# mix with common col
tdSql.query("select c1&abs(c1)&c2&c3 ,c1,c2, t1 from ct1")
tdSql.checkData(0, 0, 8)
tdSql.checkData(1, 0, 1)
tdSql.checkData(4, 0, 0)
tdSql.checkData(4, 3, 0)
tdSql.checkData(3, 2, 55555)
# mix with common functions
tdSql.query(" select c1&abs(c1)&c2&c3, abs(c1), c5, floor(c5) from ct4 ")
tdSql.checkData(0, 0, None)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
tdSql.checkData(0, 3, None)
tdSql.checkData(3, 0, 2)
tdSql.checkData(3, 1, 6)
tdSql.checkData(3, 2, 6.66000)
tdSql.checkData(3, 3, 6.00000)
tdSql.query("select c1&abs(c1)&c2&c3, abs(c1),c5, floor(c5) from stb1 order by ts ")
tdSql.checkData(3, 0, 2)
tdSql.checkData(3, 1, 6)
tdSql.checkData(3, 2, 6.66000)
tdSql.checkData(3, 3, 6.00000)
# mix with agg functions , not support
tdSql.error("select c1&abs(c1)&c2&c3, abs(c1),c5, count(c5) from stb1 ")
tdSql.error("select c1&abs(c1)&c2&c3, abs(c1),c5, count(c5) from ct1 ")
tdSql.error("select c1&abs(c1)&c2&c3, count(c5) from stb1 ")
tdSql.error("select c1&abs(c1)&c2&c3, count(c5) from ct1 ")
tdSql.error("select c1&abs(c1)&c2&c3, count(c5) from ct1 ")
tdSql.error("select c1&abs(c1)&c2&c3, count(c5) from stb1 ")
# agg functions mix with agg functions
tdSql.query("select sum(c1&abs(c1)&c2&c3) ,max(c5), count(c5) from stb1")
tdSql.query("select max(c1)&max(c2)|first(ts), count(c5) from ct1")
# bug fix for compute
tdSql.query("select c1&abs(c1)&c2&c3, abs(c1&abs(c1)&c2&c3) -0 ,ceil(c1&abs(c1)&c2&c3)-0 from ct4 ")
tdSql.checkData(0, 0, None)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
tdSql.checkData(1, 0, 8)
tdSql.checkData(1, 1, 8.000000000)
tdSql.checkData(1, 2, 8.000000000)
tdSql.query(" select c1&c2|c3, abs(c1&c2|c3) -0 ,ceil(c1&c2|c3-0.1)-0.1 from ct4")
tdSql.checkData(0, 0, None)
tdSql.checkData(0, 1, None)
tdSql.checkData(0, 2, None)
tdSql.checkData(1, 0, 888)
tdSql.checkData(1, 1, 888.000000000)
tdSql.checkData(1, 2, 894.900000000)
def check_boundary_values(self):
tdSql.execute("drop database if exists bound_test")
tdSql.execute("create database if not exists bound_test")
time.sleep(3)
tdSql.execute("use bound_test")
tdSql.execute(
"create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
)
tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )')
tdSql.execute(
f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
)
tdSql.execute(
f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
)
tdSql.execute(
f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
)
tdSql.execute(
f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
)
tdSql.error(
f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
)
self.check_function("&", False , "sub1_bound" ,"c1","c2","c3","c4","c5","c6" )
self.check_function("&", False ,"sub1_bound","abs(c1)","abs(c2)","abs(c3)","abs(c4)","abs(c5)","abs(c6)" )
self.check_function("&", False ,"stb_bound","123","abs(c2)","t1","abs(c4)","abs(c5)","abs(c6)" )
# check basic elem for table per row
tdSql.query(
"select abs(c1) ,abs(c2) , abs(c3) , abs(c4), abs(c5), abs(c6) from sub1_bound ")
tdSql.checkData(0, 0, 2147483647)
tdSql.checkData(0, 1, 9223372036854775807)
tdSql.checkData(0, 2, 32767)
tdSql.checkData(0, 3, 127)
tdSql.checkData(0, 4, 339999995214436424907732413799364296704.00000)
tdSql.checkData(0, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
tdSql.checkData(1, 0, 2147483647)
tdSql.checkData(1, 1, 9223372036854775807)
tdSql.checkData(1, 2, 32767)
tdSql.checkData(1, 3, 127)
tdSql.checkData(1, 4, 339999995214436424907732413799364296704.00000)
tdSql.checkData(1, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
tdSql.checkData(3, 0, 2147483646)
tdSql.checkData(3, 1, 9223372036854775806)
tdSql.checkData(3, 2, 32766)
tdSql.checkData(3, 3, 126)
tdSql.checkData(3, 4, 339999995214436424907732413799364296704.00000)
tdSql.checkData(3, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
# check + - * / in functions
self.check_function("&", False ,"stb_bound","abs(c1+1)","abs(c2)","t1","abs(c3*1)","abs(c5)/2","abs(c6)" )
tdSql.query(
"select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from sub1_bound ")
tdSql.checkData(0, 0, 2147483648.000000000)
tdSql.checkData(0, 1, 9223372036854775807)
tdSql.checkData(0, 2, 32767.000000000)
tdSql.checkData(0, 3, 63.500000000)
tdSql.checkData(
0, 4, 169999997607218212453866206899682148352.000000000)
tdSql.checkData(0, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
tdSql.checkData(1, 0, 2147483646.000000000)
tdSql.checkData(1, 1, 9223372036854775808.000000000)
tdSql.checkData(1, 2, 32767.000000000)
tdSql.checkData(1, 3, 63.500000000)
tdSql.checkData(
1, 4, 169999997607218212453866206899682148352.000000000)
def test_tag_compute_for_scalar_function(self):
tdSql.execute("use testdb")
self.check_function("&", False ,"ct4","123","abs(c1)","t1","abs(t2)","abs(t3)","abs(t4)","t5")
self.check_function("&", False ,"ct4","c1+2","abs(t2+2)","t3","abs(t4)","abs(t5)","abs(c1)","t5")
tdSql.query(" select sum(c1) from stb1 where t1+10 >1; ")
tdSql.query("select c1 ,t1 from stb1 where t1 =0 ")
tdSql.checkRows(13)
self.check_function("&", False ,"t1","c1+2","abs(c2)")
tdSql.query("select t1 from stb1 where t1 >0 ")
tdSql.checkRows(3)
tdSql.query("select t1 from stb1 where t1 =3 ")
tdSql.checkRows(1)
# tdSql.query("select sum(t1) from (select c1 ,t1 from stb1)")
# tdSql.checkData(0,0,61)
# tdSql.query("select distinct(c1) ,t1 from stb1")
# tdSql.checkRows(20)
tdSql.query("select max(c1) , t1&c2&t2 from stb1;")
tdSql.checkData(0,1,0)
# tag filter with abs function
tdSql.query("select t1 from stb1 where abs(t1)=1")
tdSql.checkRows(1)
tdSql.query("select t1 from stb1 where abs(c1+t1)=1")
tdSql.checkRows(1)
tdSql.checkData(0,0,0)
tdSql.query(
"select abs(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1")
def support_super_table_test(self):
tdSql.execute(" use testdb ")
self.check_function("|", False , "stb1" , "c1","c2","c3","c4" )
self.check_function("|", False , "stb1" , "c1","c2","abs(c3)","c4","ceil(t1)" )
self.check_function("&", False , "stb1" , "c1","c2","abs(c3)","floor(c4)","ceil(t1)" )
self.check_function("&", True , "stb1" , "max(c1)","max(c2)","sum(abs(c3))","max(floor(c4))","min(ceil(t1))" )
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql.prepare()
self.prepare_datas()
self.prepare_tag_datas()
self.test_errors()
self.basic_query()
self.check_boundary_values()
self.test_tag_compute_for_scalar_function()
self.support_super_table_test()
self.insert_datas_and_check_abs(self.tb_nums,self.row_nums,self.time_step)
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())
......@@ -420,11 +420,65 @@ class TDTestCase:
tdSql.query("select csum(abs(c1))+2 from t1 ")
tdSql.checkRows(4)
def csum_support_stable(self):
tdSql.query(" select csum(1) from stb1 ")
tdSql.checkRows(70)
tdSql.query("select csum(c1) from stb1 partition by tbname ")
tdSql.checkRows(40)
# tdSql.query("select csum(st1) from stb1 partition by tbname")
# tdSql.checkRows(70)
tdSql.query("select csum(st1+c1) from stb1 partition by tbname")
tdSql.checkRows(40)
tdSql.query("select csum(st1+c1) from stb1 partition by tbname")
tdSql.checkRows(40)
tdSql.query("select csum(st1+c1) from stb1 partition by tbname")
tdSql.checkRows(40)
# # bug need fix
# tdSql.query("select csum(st1+c1) from stb1 partition by tbname slimit 1 ")
# tdSql.checkRows(4)
# tdSql.error("select csum(st1+c1) from stb1 partition by tbname limit 1 ")
# bug need fix
tdSql.query("select csum(st1+c1) from stb1 partition by tbname")
tdSql.checkRows(40)
# bug need fix
# tdSql.query("select tbname , csum(c1) from stb1 partition by tbname")
# tdSql.checkRows(40)
# tdSql.query("select tbname , csum(st1) from stb1 partition by tbname")
# tdSql.checkRows(70)
# tdSql.query("select tbname , csum(st1) from stb1 partition by tbname slimit 1")
# tdSql.checkRows(7)
# partition by tags
# tdSql.query("select st1 , csum(c1) from stb1 partition by st1")
# tdSql.checkRows(40)
# tdSql.query("select csum(c1) from stb1 partition by st1")
# tdSql.checkRows(40)
# tdSql.query("select st1 , csum(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(4)
# tdSql.query("select csum(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(4)
# partition by col
# tdSql.query("select c1 , csum(c1) from stb1 partition by c1")
# tdSql.checkRows(41)
# tdSql.query("select csum(c1) from stb1 partition by c1")
# tdSql.checkRows(41)
# tdSql.query("select c1 , csum(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(4)
# tdSql.query("select csum(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(4)
def run(self):
import traceback
try:
# run in develop branch
self.csum_test_run()
self.csum_support_stable()
pass
except Exception as e:
traceback.print_exc()
......
......@@ -163,12 +163,12 @@ class TDTestCase:
"select elapsed(ts) from regular_table_1 group by tbname,ind order by desc; ",
"select elapsed(ts) from sub_table1_1 group by tbname,ind order by desc; ",
"select elapsed(ts) from sub_table1_1 group by tbname,ind order by desc; ",
# "select elapsed(ts,10s) from stable_empty group by ts order by ts;",
"select elapsed(ts,10s) from stable_1 group by ind order by ts;",
"select elapsed(ts,10s) from stable_2 group by tstag order by ts;",
"select elapsed(ts,10s) from stable_1 group by tbname,tstag,tscol order by ts;",
"select elapsed(ts,10s),ts from stable_1 group by tbname ,ind order by ts;",
"select ts,elapsed(ts,10s),tscol*100 from stable_1 group by tbname ,ind order by ts;",
# "select elapsed(ts,1s) from stable_empty group by ts order by ts;",
"select elapsed(ts,1s) from stable_1 group by ind order by ts;",
"select elapsed(ts,1s) from stable_2 group by tstag order by ts;",
"select elapsed(ts,1s) from stable_1 group by tbname,tstag,tscol order by ts;",
"select elapsed(ts,1s),ts from stable_1 group by tbname ,ind order by ts;",
"select ts,elapsed(ts,1s),tscol*100 from stable_1 group by tbname ,ind order by ts;",
"select elapsed(ts) from stable_1 group by tstag order by ts;",
"select elapsed(ts) from sub_empty_1 group by tbname,ind ,tscol order by ts desc;",
"select tbname, tscol,elapsed(ts) from sub_table1_1 group by tbname ,ind order by ts desc;",
......@@ -178,13 +178,13 @@ class TDTestCase:
"select elapsed(tscol) from sub_empty_1 order by ts desc;",
"select elapsed(tstag) from sub_empty_1 order by ts desc;",
"select elapsed(ind) from sub_table1_1 order by ts desc;",
"select elapsed(ind,10s) from sub_table1_1 order by ts desc;",
"select elapsed(tscol,10s) from sub_table1_1 order by ts desc;",
"select elapsed(tstag,10s) from sub_table1_1 order by ts desc;",
"select elapsed(q_int,10s) from sub_table1_1 order by ts desc;",
"select elapsed(loc,10s) from sub_table1_1 order by ts desc;",
"select elapsed(q_bigint,10s) from sub_table1_1 order by ts desc;",
"select elapsed(bin_chars,10s) from sub_table1_1 order by ts desc;"]
"select elapsed(ind,1s) from sub_table1_1 order by ts desc;",
"select elapsed(tscol,1s) from sub_table1_1 order by ts desc;",
"select elapsed(tstag,1s) from sub_table1_1 order by ts desc;",
"select elapsed(q_int,1s) from sub_table1_1 order by ts desc;",
"select elapsed(loc,1s) from sub_table1_1 order by ts desc;",
"select elapsed(q_bigint,1s) from sub_table1_1 order by ts desc;",
"select elapsed(bin_chars,1s) from sub_table1_1 order by ts desc;"]
for sql in sqls_list :
tdSql.error(sql)
......@@ -199,269 +199,269 @@ class TDTestCase:
ts_end_time = self.ts + (self.num-1-i)*10000
ts_col_end_time = self.ts + (self.num-1-i)*10
filter_sql = "select elapsed(ts,10s) from stable_1 where ts >= %d group by tbname " %(ts_start_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where ts >= %d group by tbname " %(ts_start_time)
tdSql.query(filter_sql)
tdSql.checkRows(3)
tdSql.checkData(0,0,float(self.num -i-1))
tdSql.checkData(1,0,float(self.num -i-1))
tdSql.checkData(2,0,float(self.num -i-1))
tdSql.checkData(0,0,float((self.num -i-1)*10))
tdSql.checkData(1,0,float((self.num -i-1)*10))
tdSql.checkData(2,0,float((self.num -i-1)*10))
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where ts >= %d " %(ts_start_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where ts >= %d " %(ts_start_time)
tdSql.query(filter_sql)
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-1))
tdSql.checkData(0,0,float((self.num -i-1)*10))
filter_sql = "select elapsed(ts,10s) from stable_1 where ts >= %d and tscol >= %d and tstag='2015-01-01 00:01:00'group by tbname " %(ts_start_time,ts_col_start_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where ts >= %d and tscol >= %d and tstag='2015-01-01 00:01:00'group by tbname " %(ts_start_time,ts_col_start_time)
tdSql.query(filter_sql)
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-1))
tdSql.checkData(0,0,float((self.num -i-1)*10))
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where ts >= %d and tscol >= %d " %(ts_start_time,ts_col_start_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where ts >= %d and tscol >= %d " %(ts_start_time,ts_col_start_time)
tdSql.query(filter_sql)
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-1))
tdSql.checkData(0,0,float((self.num -i-1)*10))
filter_sql = "select elapsed(ts,10s) from stable_1 where ts >= %d and tscol > %d and tstag='2015-01-01 00:01:00' group by tbname" %(ts_start_time,ts_col_start_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where ts >= %d and tscol > %d and tstag='2015-01-01 00:01:00' group by tbname" %(ts_start_time,ts_col_start_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where ts >= %d and tscol > %d " %(ts_start_time,ts_col_start_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where ts >= %d and tscol > %d " %(ts_start_time,ts_col_start_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from stable_1 where ts > %d and tscol > %d and tstag < '2015-01-01 00:01:00' group by tbname " %(ts_start_time,ts_col_start_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where ts > %d and tscol > %d and tstag < '2015-01-01 00:01:00' group by tbname " %(ts_start_time,ts_col_start_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where ts > %d and tscol > %d " %(ts_start_time,ts_col_start_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where ts > %d and tscol > %d " %(ts_start_time,ts_col_start_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from stable_1 where ts > %d and tscol <= %d and tstag < '2015-01-01 00:01:00' group by tbname" %(ts_start_time,ts_col_start_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where ts > %d and tscol <= %d and tstag < '2015-01-01 00:01:00' group by tbname" %(ts_start_time,ts_col_start_time)
tdSql.query(filter_sql)
tdSql.checkRows(0)
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where ts > %d and tscol <= %d " %(ts_start_time,ts_col_start_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where ts > %d and tscol <= %d " %(ts_start_time,ts_col_start_time)
tdSql.query(filter_sql)
tdSql.checkRows(0)
filter_sql = "select elapsed(ts,10s) from stable_1 where ts < %d and tscol <= %d and tstag < '2015-01-01 00:01:00' group by tbname" %(ts_end_time,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where ts < %d and tscol <= %d and tstag < '2015-01-01 00:01:00' group by tbname" %(ts_end_time,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where ts < %d and tscol <= %d " %(ts_end_time,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where ts < %d and tscol <= %d " %(ts_end_time,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from stable_1 where ts < %d and tscol <= %d group by tbname " %(ts_end_time,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where ts < %d and tscol <= %d group by tbname " %(ts_end_time,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(3)
tdSql.checkData(0,0,float(self.num - i - 2))
tdSql.checkData(1,0,float(self.num - i - 2))
tdSql.checkData(2,0,float(self.num - i - 2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
tdSql.checkData(1,0,float((self.num -i-2)*10))
tdSql.checkData(2,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where ts < %d and tscol <= %d " %(ts_end_time,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where ts < %d and tscol <= %d " %(ts_end_time,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num - i - 2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from stable_1 where ts = %d and tscol < %d group by tbname " %(ts_end_time,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where ts = %d and tscol < %d group by tbname " %(ts_end_time,ts_col_end_time)
tdSql.query(filter_sql)
tdSql.checkRows(0)
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where ts = %d and tscol < %d " %(ts_end_time,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where ts = %d and tscol < %d " %(ts_end_time,ts_col_end_time)
tdSql.query(filter_sql)
tdSql.checkRows(0)
filter_sql = "select elapsed(ts,10s) from stable_1 where q_tinyint != %d and tscol < %d group by tbname " %(i,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where q_tinyint != %d and tscol < %d group by tbname " %(i,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(3)
tdSql.checkData(0,0,float(self.num -i-2))
tdSql.checkData(1,0,float(self.num -i-2))
tdSql.checkData(2,0,float(self.num -i-2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
tdSql.checkData(1,0,float((self.num -i-2)*10))
tdSql.checkData(2,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where q_tinyint != %d and tscol < %d " %(i,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where q_tinyint != %d and tscol < %d " %(i,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from stable_1 where q_tinyint != %d and tscol <= %d group by tbname " %(i,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where q_tinyint != %d and tscol <= %d group by tbname " %(i,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num:
tdSql.checkRows(0)
else:
tdSql.checkRows(3)
tdSql.checkData(0,0,float(self.num - i - 1))
tdSql.checkData(1,0,float(self.num - i - 1))
tdSql.checkData(2,0,float(self.num - i - 1))
tdSql.checkData(0,0,float((self.num -i-1)*10))
tdSql.checkData(1,0,float((self.num -i-1)*10))
tdSql.checkData(2,0,float((self.num -i-1)*10))
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where q_tinyint != %d and tscol <= %d " %(i,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where q_tinyint != %d and tscol <= %d " %(i,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num - i - 1))
tdSql.checkData(0,0,float((self.num -i-1)*10))
filter_sql = "select elapsed(ts,10s) from stable_1 where q_tinyint <> %d and tscol < %d group by tbname " %(i,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where q_tinyint <> %d and tscol < %d group by tbname " %(i,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(3)
tdSql.checkData(0,0,float(self.num -i-2))
tdSql.checkData(1,0,float(self.num -i-2))
tdSql.checkData(2,0,float(self.num -i-2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
tdSql.checkData(1,0,float((self.num -i-2)*10))
tdSql.checkData(2,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where q_tinyint <> %d and tscol < %d " %(i,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where q_tinyint <> %d and tscol < %d " %(i,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num-1:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num -i-2))
tdSql.checkData(0,0,float((self.num -i-2)*10))
filter_sql = "select elapsed(ts,10s) from stable_1 where q_tinyint <> %d and tscol <= %d group by tbname " %(i,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from stable_1 where q_tinyint <> %d and tscol <= %d group by tbname " %(i,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num:
tdSql.checkRows(0)
else:
tdSql.checkRows(3)
tdSql.checkData(0,0,float(self.num - i - 1))
tdSql.checkData(1,0,float(self.num - i - 1))
tdSql.checkData(2,0,float(self.num - i - 1))
tdSql.checkData(0,0,float((self.num -i-1)*10))
tdSql.checkData(1,0,float((self.num -i-1)*10))
tdSql.checkData(2,0,float((self.num -i-1)*10))
filter_sql = "select elapsed(ts,10s) from sub_table1_1 where q_tinyint <> %d and tscol <= %d " %(i,ts_col_end_time)
filter_sql = "select elapsed(ts,1s) from sub_table1_1 where q_tinyint <> %d and tscol <= %d " %(i,ts_col_end_time)
tdSql.query(filter_sql)
if i == self.num:
tdSql.checkRows(0)
else:
tdSql.checkRows(1)
tdSql.checkData(0,0,float(self.num - i - 1))
tdSql.checkData(0,0,float((self.num -i-1)*10))
# filter between and
tdSql.query("select elapsed(ts,10s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and q_tinyint between 125 and 127 and tscol <= '2015-01-01 00:01:00.000' ")
tdSql.checkData(0,0,2)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and \
tdSql.query("select elapsed(ts,1s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and q_tinyint between 125 and 127 and tscol <= '2015-01-01 00:01:00.000' ")
tdSql.checkData(0,0,20)
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and \
q_tinyint between 125 and 127 and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,2)
tdSql.checkData(1,0,2)
tdSql.checkData(2,0,2)
tdSql.checkData(0,0,20)
tdSql.checkData(1,0,20)
tdSql.checkData(2,0,20)
# filter in and or
tdSql.query("select elapsed(ts,10s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and q_tinyint between 125 and 127 and tscol <= '2015-01-01 00:01:00.000' ")
tdSql.checkData(0,0,2)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and q_tinyint between 125 and 127 and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,2)
tdSql.checkData(1,0,2)
tdSql.checkData(2,0,2)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and q_tinyint in (125,126,127) and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,2)
tdSql.checkData(1,0,2)
tdSql.checkData(2,0,2)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars in ('bintest0','bintest1') and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,1)
tdSql.checkData(1,0,1)
tdSql.checkData(2,0,1)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars in ('bintest0','bintest1') and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,1)
tdSql.checkData(1,0,1)
tdSql.checkData(2,0,1)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars like 'bintest_' and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,6)
tdSql.checkData(1,0,6)
tdSql.checkData(2,0,6)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars like 'bintest_' and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,6)
tdSql.checkData(1,0,6)
tdSql.checkData(2,0,6)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars is not null and tscol <= '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.checkData(0,0,6)
tdSql.checkData(1,0,6)
tdSql.checkData(2,0,6)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars is null and tscol <= '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.query("select elapsed(ts,1s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and q_tinyint between 125 and 127 and tscol <= '2015-01-01 00:01:00.000' ")
tdSql.checkData(0,0,20)
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and q_tinyint between 125 and 127 and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,20)
tdSql.checkData(1,0,20)
tdSql.checkData(2,0,20)
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and q_tinyint in (125,126,127) and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,20)
tdSql.checkData(1,0,20)
tdSql.checkData(2,0,20)
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars in ('bintest0','bintest1') and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,10)
tdSql.checkData(1,0,10)
tdSql.checkData(2,0,10)
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars in ('bintest0','bintest1') and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,10)
tdSql.checkData(1,0,10)
tdSql.checkData(2,0,10)
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars like 'bintest_' and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,60)
tdSql.checkData(1,0,60)
tdSql.checkData(2,0,60)
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars like 'bintest_' and tscol <= '2015-01-01 00:01:00.000' group by tbname ")
tdSql.checkData(0,0,60)
tdSql.checkData(1,0,60)
tdSql.checkData(2,0,60)
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars is not null and tscol <= '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.checkData(0,0,60)
tdSql.checkData(1,0,60)
tdSql.checkData(2,0,60)
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars is null and tscol <= '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.checkRows(0)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars match '^b' and tscol <= '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars match '^b' and tscol <= '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.checkRows(3)
tdSql.checkData(0,0,6)
tdSql.checkData(1,0,6)
tdSql.checkData(2,0,6)
tdSql.checkData(0,0,60)
tdSql.checkData(1,0,60)
tdSql.checkData(2,0,60)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars nmatch '^a' and tscol <= '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars nmatch '^a' and tscol <= '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.checkRows(3)
tdSql.checkData(0,0,6)
tdSql.checkData(1,0,6)
tdSql.checkData(2,0,6)
tdSql.checkData(0,0,60)
tdSql.checkData(1,0,60)
tdSql.checkData(2,0,60)
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars ='bintest1' or bin_chars ='bintest2' and tscol <= '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and bin_chars ='bintest1' or bin_chars ='bintest2' and tscol <= '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.checkRows(3)
tdSql.query("select elapsed(ts,10s) from stable_1 where (ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000') or (ts between '2015-01-01 00:01:00.000' and '2015-01-01 00:02:00.000') group by tbname; ")
tdSql.query("select elapsed(ts,1s) from stable_1 where (ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000') or (ts between '2015-01-01 00:01:00.000' and '2015-01-01 00:02:00.000') group by tbname; ")
tdSql.checkRows(3)
tdSql.checkData(0,0,9)
tdSql.checkData(1,0,9)
tdSql.checkData(2,0,9)
tdSql.checkData(0,0,90)
tdSql.checkData(1,0,90)
tdSql.checkData(2,0,90)
def query_interval(self):
......@@ -473,9 +473,9 @@ class TDTestCase:
tdSql.query("select max(q_int)*10 from sub_empty_2 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev);")
tdSql.checkRows(0)
tdSql.query("select elapsed(ts,10s)*10 from stable_empty where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev) group by tbname;")
tdSql.query("select elapsed(ts,1s)*10 from stable_empty where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev) group by tbname;")
tdSql.checkRows(0)
tdSql.query("select elapsed(ts,10s)*10 from sub_empty_2 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev);")
tdSql.query("select elapsed(ts,1s)*10 from sub_empty_2 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev);")
tdSql.checkRows(0)
for i in range(self.num):
......@@ -487,254 +487,254 @@ class TDTestCase:
# only interval
interval_sql = "select elapsed(ts,10s) from stable_1 where ts <=%d interval(10s) group by tbname " %(ts_start_time)
interval_sql = "select elapsed(ts,1s) from stable_1 where ts <=%d interval(10s) group by tbname " %(ts_start_time)
tdSql.query(interval_sql)
tdSql.checkRows(3*(i+1))
interval_sql = "select elapsed(ts,10s) from sub_table1_1 where ts <=%d interval(10s) " %(ts_start_time)
interval_sql = "select elapsed(ts,1s) from sub_table1_1 where ts <=%d interval(10s) " %(ts_start_time)
tdSql.query(interval_sql)
tdSql.checkRows(i+1)
for x in range(i+1):
if x == i:
tdSql.checkData(x,1,0)
else :
tdSql.checkData(x,1,1)
tdSql.checkData(x,1,10)
# interval and fill , fill_type = ["NULL","value,100","prev","next","linear"]
# interval (10s) and time range is outer records
# interval (1s) and time range is outer records
tdSql.query("select elapsed(ts,10s)*10 from stable_empty where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev) group by tbname;")
tdSql.query("select elapsed(ts,1s)*10 from stable_empty where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev) group by tbname;")
tdSql.checkRows(0)
tdSql.query("select elapsed(ts,10s)*10 from sub_empty_2 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev);")
tdSql.query("select elapsed(ts,1s)*10 from sub_empty_2 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev);")
tdSql.checkRows(0)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev) group by tbname;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(prev) group by tbname;")
tdSql.checkRows(180)
tdSql.checkData(0,1,10)
tdSql.checkData(0,1,100)
tdSql.checkData(9,1,0)
tdSql.checkData(59,1,0)
tdSql.checkData(60,1,10)
tdSql.checkData(60,1,100)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(next) group by tbname;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(next) group by tbname;")
tdSql.checkRows(180)
tdSql.checkData(0,1,10)
tdSql.checkData(0,1,100)
tdSql.checkData(9,1,0)
tdSql.checkData(10,1,None)
tdSql.checkData(59,1,None)
tdSql.checkData(60,1,10)
tdSql.checkData(61,1,10)
tdSql.checkData(60,1,100)
tdSql.checkData(61,1,100)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(linear) group by tbname;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(linear) group by tbname;")
tdSql.checkRows(180)
tdSql.checkData(0,1,10)
tdSql.checkData(0,1,100)
tdSql.checkData(9,1,0)
tdSql.checkData(10,1,None)
tdSql.checkData(59,1,None)
tdSql.checkData(60,1,10)
tdSql.checkData(61,1,10)
tdSql.checkData(60,1,100)
tdSql.checkData(61,1,100)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(NULL) group by tbname;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(NULL) group by tbname;")
tdSql.checkRows(180)
tdSql.checkData(0,1,10)
tdSql.checkData(0,1,100)
tdSql.checkData(9,1,0)
tdSql.checkData(10,1,None)
tdSql.checkData(59,1,None)
tdSql.checkData(60,1,10)
tdSql.checkData(61,1,10)
tdSql.checkData(60,1,100)
tdSql.checkData(61,1,100)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(value ,2) group by tbname;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(10s) fill(value ,2) group by tbname;")
tdSql.checkRows(180)
tdSql.checkData(0,1,10)
tdSql.checkData(0,1,100)
tdSql.checkData(9,1,0)
tdSql.checkData(10,1,2)
tdSql.checkData(59,1,2)
tdSql.checkData(10,1,20)
tdSql.checkData(59,1,20)
tdSql.checkData(60,1,10)
tdSql.checkData(61,1,10)
tdSql.checkData(61,1,100)
# interval (20s) and time range is outer records
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(20s) fill(prev) group by tbname,ind ;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(20s) fill(prev) group by tbname,ind ;")
tdSql.checkRows(90)
tdSql.checkData(0,1,20)
tdSql.checkData(4,1,10)
tdSql.checkData(5,1,10)
tdSql.checkData(29,1,10)
tdSql.checkData(30,1,20)
tdSql.checkData(31,1,20)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(20s) fill(next) group by tbname,ind ;")
tdSql.checkData(0,1,200)
tdSql.checkData(4,1,100)
tdSql.checkData(5,1,100)
tdSql.checkData(29,1,100)
tdSql.checkData(30,1,200)
tdSql.checkData(31,1,200)
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(20s) fill(next) group by tbname,ind ;")
tdSql.checkRows(90)
tdSql.checkData(0,1,20)
tdSql.checkData(4,1,10)
tdSql.checkData(0,1,200)
tdSql.checkData(4,1,100)
tdSql.checkData(5,1,None)
tdSql.checkData(29,1,None)
tdSql.checkData(30,1,20)
tdSql.checkData(31,1,20)
tdSql.checkData(30,1,200)
tdSql.checkData(31,1,200)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(20s) fill(linear) group by tbname,ind ;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(20s) fill(linear) group by tbname,ind ;")
tdSql.checkRows(90)
tdSql.checkData(0,1,20)
tdSql.checkData(4,1,10)
tdSql.checkData(0,1,200)
tdSql.checkData(4,1,100)
tdSql.checkData(5,1,None)
tdSql.checkData(29,1,None)
tdSql.checkData(30,1,20)
tdSql.checkData(31,1,20)
tdSql.checkData(30,1,200)
tdSql.checkData(31,1,200)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(20s) fill(NULL) group by tbname,ind ;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(20s) fill(NULL) group by tbname,ind ;")
tdSql.checkRows(90)
tdSql.checkData(0,1,20)
tdSql.checkData(4,1,10)
tdSql.checkData(0,1,200)
tdSql.checkData(4,1,100)
tdSql.checkData(5,1,None)
tdSql.checkData(29,1,None)
tdSql.checkData(30,1,20)
tdSql.checkData(31,1,20)
tdSql.checkData(30,1,200)
tdSql.checkData(31,1,200)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(20s) fill(value ,2) group by tbname,ind ;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:10:00.000' interval(20s) fill(value ,2) group by tbname,ind ;")
tdSql.checkRows(90)
tdSql.checkData(0,1,20)
tdSql.checkData(4,1,10)
tdSql.checkData(5,1,2)
tdSql.checkData(29,1,2)
tdSql.checkData(30,1,20)
tdSql.checkData(31,1,20)
tdSql.checkData(0,1,200)
tdSql.checkData(4,1,100)
tdSql.checkData(5,1,20)
tdSql.checkData(29,1,20)
tdSql.checkData(30,1,200)
tdSql.checkData(31,1,200)
# interval (20s) and time range is in records
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(prev) group by tbname,ind ;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(prev) group by tbname,ind ;")
tdSql.checkRows(9)
tdSql.checkData(0,1,20)
tdSql.checkData(2,1,10)
tdSql.checkData(3,1,20)
tdSql.checkData(5,1,10)
tdSql.checkData(7,1,20)
tdSql.checkData(8,1,10)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(next) group by tbname,ind ;")
tdSql.checkData(0,1,200)
tdSql.checkData(2,1,100)
tdSql.checkData(3,1,200)
tdSql.checkData(5,1,100)
tdSql.checkData(7,1,200)
tdSql.checkData(8,1,100)
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(next) group by tbname,ind ;")
tdSql.checkRows(9)
tdSql.checkData(0,1,20)
tdSql.checkData(2,1,10)
tdSql.checkData(3,1,20)
tdSql.checkData(5,1,10)
tdSql.checkData(7,1,20)
tdSql.checkData(8,1,10)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(linear) group by tbname,ind ;")
tdSql.checkData(0,1,200)
tdSql.checkData(2,1,100)
tdSql.checkData(3,1,200)
tdSql.checkData(5,1,100)
tdSql.checkData(7,1,200)
tdSql.checkData(8,1,100)
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(linear) group by tbname,ind ;")
tdSql.checkRows(9)
tdSql.checkData(0,1,20)
tdSql.checkData(2,1,10)
tdSql.checkData(3,1,20)
tdSql.checkData(5,1,10)
tdSql.checkData(7,1,20)
tdSql.checkData(8,1,10)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(NULL) group by tbname,ind ;")
tdSql.checkData(0,1,200)
tdSql.checkData(2,1,100)
tdSql.checkData(3,1,200)
tdSql.checkData(5,1,100)
tdSql.checkData(7,1,200)
tdSql.checkData(8,1,100)
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(NULL) group by tbname,ind ;")
tdSql.checkRows(9)
tdSql.checkData(0,1,20)
tdSql.checkData(2,1,10)
tdSql.checkData(3,1,20)
tdSql.checkData(5,1,10)
tdSql.checkData(7,1,20)
tdSql.checkData(8,1,10)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(value ,2 ) group by tbname,ind ;")
tdSql.checkData(0,1,200)
tdSql.checkData(2,1,100)
tdSql.checkData(3,1,200)
tdSql.checkData(5,1,100)
tdSql.checkData(7,1,200)
tdSql.checkData(8,1,100)
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(value ,2 ) group by tbname,ind ;")
tdSql.checkRows(9)
tdSql.checkData(0,1,20)
tdSql.checkData(2,1,10)
tdSql.checkData(3,1,20)
tdSql.checkData(5,1,10)
tdSql.checkData(7,1,20)
tdSql.checkData(8,1,10)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) group by tbname,ind ;")
tdSql.checkData(0,1,200)
tdSql.checkData(2,1,100)
tdSql.checkData(3,1,200)
tdSql.checkData(5,1,100)
tdSql.checkData(7,1,200)
tdSql.checkData(8,1,100)
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2015-01-01 00:00:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) group by tbname,ind ;")
tdSql.checkRows(9)
tdSql.checkData(0,1,20)
tdSql.checkData(2,1,10)
tdSql.checkData(3,1,20)
tdSql.checkData(5,1,10)
tdSql.checkData(7,1,20)
tdSql.checkData(8,1,10)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2014-12-31 23:59:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(NULL) group by tbname,ind ;")
tdSql.checkData(0,1,200)
tdSql.checkData(2,1,100)
tdSql.checkData(3,1,200)
tdSql.checkData(5,1,100)
tdSql.checkData(7,1,200)
tdSql.checkData(8,1,100)
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2014-12-31 23:59:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) fill(NULL) group by tbname,ind ;")
tdSql.checkRows(18)
tdSql.checkData(0,1,None)
tdSql.checkData(2,1,None)
tdSql.checkData(3,1,20)
tdSql.checkData(5,1,10)
tdSql.checkData(3,1,200)
tdSql.checkData(5,1,100)
tdSql.checkData(7,1,None)
tdSql.checkData(8,1,None)
tdSql.checkData(9,1,20)
tdSql.checkData(9,1,200)
# interval sliding
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2014-12-31 23:59:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) sliding(20s) fill(NULL) group by tbname,ind ;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2014-12-31 23:59:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) sliding(20s) fill(NULL) group by tbname,ind ;")
tdSql.checkRows(18)
tdSql.checkData(0,1,None)
tdSql.checkData(2,1,None)
tdSql.checkData(3,1,20)
tdSql.checkData(5,1,10)
tdSql.checkData(3,1,200)
tdSql.checkData(5,1,100)
tdSql.checkData(7,1,None)
tdSql.checkData(8,1,None)
tdSql.checkData(9,1,20)
tdSql.checkData(9,1,200)
tdSql.query("select elapsed(ts,10s)*10 from stable_1 where ts >= '2014-12-31 23:59:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) sliding(10s) fill(NULL) group by tbname,ind ;")
tdSql.query("select elapsed(ts,1s)*10 from stable_1 where ts >= '2014-12-31 23:59:00.000' and ts <'2015-01-01 00:01:00.000' interval(20s) sliding(10s) fill(NULL) group by tbname,ind ;")
tdSql.checkRows(39)
tdSql.checkData(0,1,None)
tdSql.checkData(2,1,None)
tdSql.checkData(6,1,10)
tdSql.checkData(7,1,20)
tdSql.checkData(6,1,100)
tdSql.checkData(7,1,200)
tdSql.checkData(12,1,0)
tdSql.checkData(13,1,None)
tdSql.checkData(15,1,None)
tdSql.checkData(19,1,10)
tdSql.checkData(20,1,20)
tdSql.checkData(19,1,100)
tdSql.checkData(20,1,200)
tdSql.checkData(25,1,0)
def query_mix_common(self):
tdLog.info (" ======================================elapsed mixup with common col, it will not support =======================================")
tdSql.query("select elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and ind =1 group by tbname; ")
tdSql.query("select elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' and ind =1 group by tbname; ")
tdSql.checkRows(1)
tdSql.checkData(0,0,6)
tdSql.checkData(0,0,60)
tdSql.query("select elapsed(ts,10s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' ; ")
tdSql.query("select elapsed(ts,1s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' ; ")
tdSql.checkRows(1)
tdSql.checkData(0,0,6)
tdSql.checkData(0,0,60)
tdSql.error("select ts,elapsed(ts,10s) from sub_empty_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' ; ")
tdSql.error("select ts,elapsed(ts,10s) from stable_empty where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.error("select ts,elapsed(ts,1s) from sub_empty_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' ; ")
tdSql.error("select ts,elapsed(ts,1s) from stable_empty where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.error("select ts,elapsed(ts,10s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' ; ")
tdSql.error("select ts,elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.error("select ts,elapsed(ts,1s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' ; ")
tdSql.error("select ts,elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.error("select q_int,elapsed(ts,10s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' ; ")
tdSql.error("select q_int,elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.error("select q_int,elapsed(ts,1s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' ; ")
tdSql.error("select q_int,elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.error("select ts,q_int,elapsed(ts,10s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' ; ")
tdSql.error("select ts,q_int,elapsed(ts,10s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' group by tbname; ")
tdSql.error("select ts,q_int,elapsed(ts,1s) from sub_table1_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' ; ")
tdSql.error("select ts,q_int,elapsed(ts,1s) from stable_1 where ts between '2015-01-01 00:00:00.000' and '2015-01-01 00:01:00.000' group by tbname; ")
def query_mix_Aggregate(self):
tdLog.info (" ====================================== elapsed mixup with aggregate ==================================================")
tdSql.query("select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) from sub_table1_1 ; ")
tdSql.query("select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) from sub_table1_1 ; ")
data = tdSql.getResult("select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) from sub_table1_1 ; ")
data = tdSql.getResult("select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) from sub_table1_1 ; ")
querys = ["count(*)","avg(q_int)", "sum(q_double)","stddev(q_float)","LEASTSQUARES(q_int,0,1)", "elapsed(ts,10s)"]
querys = ["count(*)","avg(q_int)", "sum(q_double)","stddev(q_float)","LEASTSQUARES(q_int,0,1)", "elapsed(ts,1s)"]
for index , query in enumerate(querys):
sql = "select %s from sub_table1_1 " %(query)
tdSql.query(sql)
tdSql.checkData(0,0,data[0][index])
tdSql.query("select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) from stable_1 group by tbname; ")
tdSql.query("select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) from stable_1 group by tbname; ")
# Arithmetic with elapsed for common table
operators = ["+" ,"-" , "*" ,"/" ,"%"]
querys_oper = ["count(*)","avg(q_int)", "sum(q_double)","stddev(q_float)", "elapsed(ts,10s)"]
querys_oper = ["count(*)","avg(q_int)", "sum(q_double)","stddev(q_float)", "elapsed(ts,1s)"]
for operator in operators:
......@@ -785,7 +785,7 @@ class TDTestCase:
# Arithmetic with elapsed for super table
operators = ["+" ,"-" , "*" ,"/" ,"%"]
querys_oper = ["count(*)","avg(q_int)", "sum(q_double)","stddev(q_float)", "elapsed(ts,10s)"]
querys_oper = ["count(*)","avg(q_int)", "sum(q_double)","stddev(q_float)", "elapsed(ts,1s)"]
for operator in operators:
......@@ -847,25 +847,25 @@ class TDTestCase:
tdLog.info (" ====================================== elapsed mixup with select function =================================================")
querys = ["max(q_int)","min(q_int)" , "first(q_tinyint)", "first(*)","last(q_int)","last(*)","PERCENTILE(q_int,10)","APERCENTILE(q_int,10)","elapsed(ts,10s)"]
querys = ["max(q_int)","min(q_int)" , "first(q_tinyint)", "first(*)","last(q_int)","last(*)","PERCENTILE(q_int,10)","APERCENTILE(q_int,10)","elapsed(ts,1s)"]
querys_mix = ["max(q_int)","min(q_int)" , "first(q_tinyint)", "first(q_int)","last(q_int)","PERCENTILE(q_int,10)","APERCENTILE(q_int,10)","elapsed(ts,10s)"]
querys_mix = ["max(q_int)","min(q_int)" , "first(q_tinyint)", "first(q_int)","last(q_int)","PERCENTILE(q_int,10)","APERCENTILE(q_int,10)","elapsed(ts,1s)"]
tdSql.query("select max(q_int),min(q_int) , first(q_tinyint), first(q_int),last(q_int),PERCENTILE(q_int,10),APERCENTILE(q_int,10) ,elapsed(ts,10s) from sub_table1_1 ; ")
tdSql.query("select max(q_int),min(q_int) , first(q_tinyint), first(q_int),last(q_int),PERCENTILE(q_int,10),APERCENTILE(q_int,10) ,elapsed(ts,1s) from sub_table1_1 ; ")
data = tdSql.getResult("select max(q_int),min(q_int) , first(q_tinyint), first(q_int),last(q_int),PERCENTILE(q_int,10),APERCENTILE(q_int,10) ,elapsed(ts,10s) from sub_table1_1 ; ")
data = tdSql.getResult("select max(q_int),min(q_int) , first(q_tinyint), first(q_int),last(q_int),PERCENTILE(q_int,10),APERCENTILE(q_int,10) ,elapsed(ts,1s) from sub_table1_1 ; ")
for index , query in enumerate(querys_mix):
sql = "select %s from sub_table1_1 " %(query)
tdSql.query(sql)
tdSql.checkData(0,0,data[0][index])
tdSql.query("select max(q_int),min(q_int) , first(q_tinyint), first(q_int),last(q_int),APERCENTILE(q_int,10) ,elapsed(ts,10s) from stable_1 group by tbname ; ")
tdSql.query("select max(q_int),min(q_int) , first(q_tinyint), first(q_int),last(q_int),APERCENTILE(q_int,10) ,elapsed(ts,1s) from stable_1 group by tbname ; ")
data = tdSql.getResult("select max(q_int),min(q_int) , first(q_tinyint), first(q_int),last(q_int),APERCENTILE(q_int,10) ,elapsed(ts,10s) from stable_1 group by tbname ; ")
data = tdSql.getResult("select max(q_int),min(q_int) , first(q_tinyint), first(q_int),last(q_int),APERCENTILE(q_int,10) ,elapsed(ts,1s) from stable_1 group by tbname ; ")
querys_mix = ["max(q_int)","min(q_int)" , "first(q_tinyint)", "first(q_int)","last(q_int)","APERCENTILE(q_int,10)","elapsed(ts,10s)"]
querys_mix = ["max(q_int)","min(q_int)" , "first(q_tinyint)", "first(q_int)","last(q_int)","APERCENTILE(q_int,10)","elapsed(ts,1s)"]
for index , query in enumerate(querys_mix):
sql = "select %s from stable_1 group by tbname " %(query)
......@@ -992,8 +992,8 @@ class TDTestCase:
for index , query in enumerate(querys):
sql1 = "select elapsed(ts,10s),%s from sub_table1_1 " %(query)
sql2 = "select elapsed(ts,10s),%s from stable_1 group by tbname" %(query)
sql1 = "select elapsed(ts,1s),%s from sub_table1_1 " %(query)
sql2 = "select elapsed(ts,1s),%s from stable_1 group by tbname" %(query)
if query in ["diff(q_int)","DERIVATIVE(q_int,1s,1)","ceil(q_float)","floor(q_float)","round(q_float)"]:
tdSql.error(sql1)
tdSql.error(sql2)
......@@ -1003,15 +1003,15 @@ class TDTestCase:
# only support mixup with spread
sql = "select spread(ts)*10,spread(q_tinyint)-10,elapsed(ts,10s) from sub_table1_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" ;"
sql = "select spread(ts)*10,spread(q_tinyint)-10,elapsed(ts,1s) from sub_table1_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" ;"
tdSql.execute(sql)
data = tdSql.getResult(sql)
sql = "select spread(ts)*10,spread(q_tinyint)-10,elapsed(ts,10s) from stable_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" ;"
sql = "select spread(ts)*10,spread(q_tinyint)-10,elapsed(ts,1s) from stable_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" ;"
tdSql.execute(sql)
querys_mix = ["spread(ts)","spread(q_tinyint)-10","elapsed(ts,10s)"]
querys_mix = ["spread(ts)","spread(q_tinyint)-10","elapsed(ts,1s)"]
for index , query in enumerate(querys_mix):
sql = "select %s from sub_table1_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" ; " %(query)
......@@ -1053,50 +1053,50 @@ class TDTestCase:
tdLog.info (" ====================================== elapsed mixup with arithmetic =================================================")
tdSql.execute("select elapsed(ts,10s)+1 ,elapsed(ts,10s)-2,elapsed(ts,10s)*3,elapsed(ts,10s)/4,elapsed(ts,10s)%5 from sub_table1_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" ; ")
tdSql.execute("select elapsed(ts,10s)+1 ,elapsed(ts,10s)-2,elapsed(ts,10s)*3,elapsed(ts,10s)/4,elapsed(ts,10s)%5 from stable_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" ; ")
tdSql.execute("select elapsed(ts,1s)+1 ,elapsed(ts,1s)-2,elapsed(ts,1s)*3,elapsed(ts,1s)/4,elapsed(ts,1s)%5 from sub_table1_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" ; ")
tdSql.execute("select elapsed(ts,1s)+1 ,elapsed(ts,1s)-2,elapsed(ts,1s)*3,elapsed(ts,1s)/4,elapsed(ts,1s)%5 from stable_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" ; ")
# queries = ["elapsed(ts,10s)+1" ,"elapsed(ts,10s)-2","elapsed(ts,10s)*3","elapsed(ts,10s)/4","elapsed(ts,10s)%5" ]
# queries = ["elapsed(ts,1s)+1" ,"elapsed(ts,1s)-2","elapsed(ts,1s)*3","elapsed(ts,1s)/4","elapsed(ts,1s)%5" ]
# for index ,query in enumerate(queries):
# sql = "select %s from sub_table1_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev) ;" % (query)
# data = tdSql.getResult(sql)
# tdSql.query("select elapsed(ts,10s)+1 ,elapsed(ts,10s)-2,elapsed(ts,10s)*3,elapsed(ts,10s)/4,elapsed(ts,10s)%5 from sub_table1_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev) ; ")
# tdSql.query("select elapsed(ts,1s)+1 ,elapsed(ts,1s)-2,elapsed(ts,1s)*3,elapsed(ts,1s)/4,elapsed(ts,1s)%5 from sub_table1_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev) ; ")
# tdSql.checkData(0,index+1,data[0][1])
def query_with_join(self):
tdLog.info (" ====================================== elapsed mixup with join =================================================")
tdSql.error("select elapsed(ts,10s) from stable_empty TABLE1 , stable_empty TABLE2 where TABLE1.ts =TABLE2.ts; ")
tdSql.error("select elapsed(ts,10s) from stable_empty TABLE1 , stable_empty TABLE2 where TABLE1.ts =TABLE2.ts group by tbname; ")
tdSql.error("select elapsed(ts,1s) from stable_empty TABLE1 , stable_empty TABLE2 where TABLE1.ts =TABLE2.ts; ")
tdSql.error("select elapsed(ts,1s) from stable_empty TABLE1 , stable_empty TABLE2 where TABLE1.ts =TABLE2.ts group by tbname; ")
tdSql.execute("select elapsed(ts,10s) from sub_empty_1 TABLE1 , sub_empty_2 TABLE2 where TABLE1.ts =TABLE2.ts; ")
tdSql.error("select elapsed(ts,10s) from stable_1 TABLE1 , stable_2 TABLE2 where TABLE1.ts =TABLE2.ts and TABLE1.ind =TABLE2.ind; ")
tdSql.error("select elapsed(ts,10s) from stable_1 TABLE1 , stable_2 TABLE2 where TABLE1.ts =TABLE2.ts and TABLE1.ind =TABLE2.ind group by tbname,ind; ") # join not support group by
tdSql.execute("select elapsed(ts,1s) from sub_empty_1 TABLE1 , sub_empty_2 TABLE2 where TABLE1.ts =TABLE2.ts; ")
tdSql.error("select elapsed(ts,1s) from stable_1 TABLE1 , stable_2 TABLE2 where TABLE1.ts =TABLE2.ts and TABLE1.ind =TABLE2.ind; ")
tdSql.error("select elapsed(ts,1s) from stable_1 TABLE1 , stable_2 TABLE2 where TABLE1.ts =TABLE2.ts and TABLE1.ind =TABLE2.ind group by tbname,ind; ") # join not support group by
tdSql.error("select elapsed(ts,10s) from sub_empty_1 TABLE1 , stable_2 TABLE2 where TABLE1.ts =TABLE2.ts and TABLE1.ind =TABLE2.ind ; ")
tdSql.execute("select elapsed(ts,10s) from sub_empty_1 TABLE1 , sub_empty_2 TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.error("select elapsed(ts,1s) from sub_empty_1 TABLE1 , stable_2 TABLE2 where TABLE1.ts =TABLE2.ts and TABLE1.ind =TABLE2.ind ; ")
tdSql.execute("select elapsed(ts,1s) from sub_empty_1 TABLE1 , sub_empty_2 TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.query("select elapsed(ts,10s) from sub_table1_1 TABLE1 , sub_table1_2 TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.checkData(0,0,9)
tdSql.query("select elapsed(ts,1s) from sub_table1_1 TABLE1 , sub_table1_2 TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.checkData(0,0,90)
tdSql.query("select elapsed(ts,10s) from sub_empty_1 TABLE1 , sub_table1_2 TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.query("select elapsed(ts,1s) from sub_empty_1 TABLE1 , sub_table1_2 TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.checkRows(0)
tdSql.query("select elapsed(ts,10s) from sub_empty_1 TABLE1 , regular_empty TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.query("select elapsed(ts,1s) from sub_empty_1 TABLE1 , regular_empty TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.checkRows(0)
tdSql.query("select elapsed(ts,10s) from sub_empty_1 TABLE1 , regular_table_1 TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.query("select elapsed(ts,1s) from sub_empty_1 TABLE1 , regular_table_1 TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.checkRows(0)
tdSql.query("select elapsed(ts,10s) from sub_table1_3 TABLE1 , regular_table_1 TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.query("select elapsed(ts,1s) from sub_table1_3 TABLE1 , regular_table_1 TABLE2 where TABLE1.ts =TABLE2.ts ; ")
tdSql.checkRows(1)
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,90)
tdSql.query("select elapsed(ts,10s) from regular_table_1 ; ")
tdSql.query("select elapsed(ts,1s) from regular_table_1 ; ")
tdSql.checkRows(1)
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,90)
def query_with_union(self):
......@@ -1104,196 +1104,196 @@ class TDTestCase:
# union all with empty
tdSql.query("select elapsed(ts,10s) from regular_table_1 union all select elapsed(ts,10s) from regular_table_2;")
tdSql.query("select elapsed(ts,1s) from regular_table_1 union all select elapsed(ts,1s) from regular_table_2;")
tdSql.query("select elapsed(ts,10s) from regular_table_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev) union all \
select elapsed(ts,10s) from regular_table_2 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);")
tdSql.query("select elapsed(ts,1s) from regular_table_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev) union all \
select elapsed(ts,1s) from regular_table_2 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);")
tdSql.checkRows(1200)
tdSql.checkData(0,1,0.1)
tdSql.checkData(0,1,1)
tdSql.checkData(500,1,0)
tdSql.query("select elapsed(ts,10s) from sub_empty_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev) union all \
select elapsed(ts,10s) from regular_table_2 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);")
tdSql.query("select elapsed(ts,1s) from sub_empty_1 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev) union all \
select elapsed(ts,1s) from regular_table_2 where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);")
tdSql.checkRows(600)
tdSql.checkData(0,1,0.1)
tdSql.checkData(0,1,1)
tdSql.checkData(500,0,0)
tdSql.query('select elapsed(ts,10s) from sub_empty_1 union all select elapsed(ts,10s) from sub_empty_2;')
tdSql.query('select elapsed(ts,1s) from sub_empty_1 union all select elapsed(ts,1s) from sub_empty_2;')
tdSql.checkRows(0)
tdSql.query('select elapsed(ts,10s) from regular_table_1 union all select elapsed(ts,10s) from sub_empty_1;')
tdSql.query('select elapsed(ts,1s) from regular_table_1 union all select elapsed(ts,1s) from sub_empty_1;')
tdSql.checkRows(1)
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,90)
tdSql.query('select elapsed(ts,10s) from sub_empty_1 union all select elapsed(ts,10s) from regular_table_1;')
tdSql.query('select elapsed(ts,1s) from sub_empty_1 union all select elapsed(ts,1s) from regular_table_1;')
tdSql.checkRows(1)
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,90)
tdSql.query('select elapsed(ts,10s) from sub_empty_1 union all select elapsed(ts,10s) from sub_table1_1;')
tdSql.query('select elapsed(ts,1s) from sub_empty_1 union all select elapsed(ts,1s) from sub_table1_1;')
tdSql.checkRows(1)
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,90)
tdSql.query('select elapsed(ts,10s) from sub_table1_1 union all select elapsed(ts,10s) from sub_empty_1;')
tdSql.query('select elapsed(ts,1s) from sub_table1_1 union all select elapsed(ts,1s) from sub_empty_1;')
tdSql.checkRows(1)
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,90)
tdSql.query('select elapsed(ts,10s) from sub_empty_1 union all select elapsed(ts,10s) from regular_table_1;')
tdSql.query('select elapsed(ts,1s) from sub_empty_1 union all select elapsed(ts,1s) from regular_table_1;')
tdSql.checkRows(1)
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,90)
tdSql.error('select elapsed(ts,10s) from sub_empty_1 union all select elapsed(ts,10s) from stable_sub_empty group by tbname;')
tdSql.error('select elapsed(ts,1s) from sub_empty_1 union all select elapsed(ts,1s) from stable_sub_empty group by tbname;')
tdSql.error('select elapsed(ts,10s) from regular_table_1 union all select elapsed(ts,10s) from stable_sub_empty group by tbname;')
tdSql.error('select elapsed(ts,1s) from regular_table_1 union all select elapsed(ts,1s) from stable_sub_empty group by tbname;')
tdSql.query('select elapsed(ts,10s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(1s) fill(prev) union all select elapsed(ts,10s) from sub_empty_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(1s) fill(prev);')
tdSql.query('select elapsed(ts,1s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(1s) fill(prev) union all select elapsed(ts,1s) from sub_empty_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(1s) fill(prev);')
tdSql.checkRows(0)
tdSql.error('select elapsed(ts,10s) from sub_empty_1 union all select elapsed(ts,10s) from stable_empty group by tbname;')
tdSql.error('select elapsed(ts,1s) from sub_empty_1 union all select elapsed(ts,1s) from stable_empty group by tbname;')
tdSql.error('select elapsed(ts,10s) from sub_empty_1 interval(1s) union all select elapsed(ts,10s) from stable_empty interval(1s) group by tbname;')
tdSql.error('select elapsed(ts,1s) from sub_empty_1 interval(1s) union all select elapsed(ts,1s) from stable_empty interval(1s) group by tbname;')
# tdSql.error('select elapsed(ts,10s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(1s) fill(prev) union all select elapsed(ts,10s) from stable_empty where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(1s) fill(prev) group by tbname;')
# tdSql.error('select elapsed(ts,1s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(1s) fill(prev) union all select elapsed(ts,1s) from stable_empty where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(1s) fill(prev) group by tbname;')
tdSql.query("select elapsed(ts,10s) from stable_empty group by tbname union all select elapsed(ts,10s) from stable_empty group by tbname ;")
tdSql.query("select elapsed(ts,1s) from stable_empty group by tbname union all select elapsed(ts,1s) from stable_empty group by tbname ;")
tdSql.checkRows(0)
# case : TD-12229
tdSql.query("select elapsed(ts,10s) from stable_empty group by tbname union all select elapsed(ts,10s) from stable_1 group by tbname ;")
tdSql.query("select elapsed(ts,1s) from stable_empty group by tbname union all select elapsed(ts,1s) from stable_1 group by tbname ;")
tdSql.checkRows(3)
tdSql.query("select elapsed(ts,10s) from stable_1 group by tbname union all select elapsed(ts,10s) from stable_1 group by tbname ;")
tdSql.query("select elapsed(ts,1s) from stable_1 group by tbname union all select elapsed(ts,1s) from stable_1 group by tbname ;")
tdSql.checkRows(6)
tdSql.checkData(0,0,9)
tdSql.checkData(5,0,9)
tdSql.checkData(0,0,90)
tdSql.checkData(5,0,90)
tdSql.query("select elapsed(ts,10s) from stable_1 group by tbname union all select elapsed(ts,10s) from stable_2 group by tbname ;")
tdSql.query("select elapsed(ts,1s) from stable_1 group by tbname union all select elapsed(ts,1s) from stable_2 group by tbname ;")
tdSql.checkRows(6)
tdSql.checkData(0,0,9)
tdSql.checkData(5,0,9)
tdSql.checkData(0,0,90)
tdSql.checkData(5,0,90)
tdSql.query('select elapsed(ts,10s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname union all\
select elapsed(ts,10s) from stable_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname ;')
tdSql.query('select elapsed(ts,1s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname union all\
select elapsed(ts,1s) from stable_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname ;')
tdSql.checkRows(360)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(50,1,0)
#case : TD-12229
tdSql.query('select elapsed(ts,10s) from stable_empty group by tbname union all select elapsed(ts,10s) from stable_2 group by tbname ;')
tdSql.query('select elapsed(ts,1s) from stable_empty group by tbname union all select elapsed(ts,1s) from stable_2 group by tbname ;')
tdSql.checkRows(3)
tdSql.query('select elapsed(ts,10s) from stable_1 group by tbname union all select elapsed(ts,10s) from stable_empty group by tbname ;')
tdSql.query('select elapsed(ts,1s) from stable_1 group by tbname union all select elapsed(ts,1s) from stable_empty group by tbname ;')
tdSql.checkRows(3)
tdSql.query('select elapsed(ts,10s) from stable_empty where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname union all\
select elapsed(ts,10s) from stable_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname ;')
tdSql.query('select elapsed(ts,1s) from stable_empty where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname union all\
select elapsed(ts,1s) from stable_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname ;')
tdSql.checkRows(180)
tdSql.query('select elapsed(ts,10s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname union all\
select elapsed(ts,10s) from stable_empty where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname ;')
tdSql.query('select elapsed(ts,1s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname union all\
select elapsed(ts,1s) from stable_empty where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname ;')
tdSql.checkRows(180)
# union all with sub table and regular table
# sub_table with sub_table
tdSql.query('select elapsed(ts,10s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,10s) from sub_table2_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.query('select elapsed(ts,1s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,1s) from sub_table2_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.checkRows(120)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(12,1,0)
tdSql.query('select elapsed(ts,10s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,10s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.query('select elapsed(ts,1s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,1s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.checkRows(120)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(12,1,0)
tdSql.query('select elapsed(ts,10s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,10s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.query('select elapsed(ts,1s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,1s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.checkRows(120)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(12,1,0)
tdSql.query('select elapsed(ts,10s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,10s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.query('select elapsed(ts,1s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,1s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.checkRows(120)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(12,1,0)
tdSql.query('select elapsed(ts,10s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,10s) from regular_table_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.query('select elapsed(ts,1s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,1s) from regular_table_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.checkRows(120)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(12,1,0)
tdSql.query('select elapsed(ts,10s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,10s) from regular_table_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.query('select elapsed(ts,1s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,1s) from regular_table_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.checkRows(120)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(12,1,0)
tdSql.query('select elapsed(ts,10s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,10s) from regular_table_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.query('select elapsed(ts,1s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,1s) from regular_table_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.checkRows(60)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(12,1,0)
tdSql.query('select elapsed(ts,10s) from regular_table_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,10s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.query('select elapsed(ts,1s) from regular_table_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) union all\
select elapsed(ts,1s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.checkRows(60)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(12,1,0)
# stable with stable
tdSql.query('select elapsed(ts,10s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname union all\
select elapsed(ts,10s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname;')
tdSql.query('select elapsed(ts,1s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname union all\
select elapsed(ts,1s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname;')
tdSql.checkRows(360)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(12,1,0)
tdSql.query('select elapsed(ts,10s) from regular_table_2 interval(10s) union all select elapsed(ts,10s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev);')
tdSql.query('select elapsed(ts,1s) from regular_table_2 interval(10s) union all select elapsed(ts,1s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev);')
tdSql.checkRows(10)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(9,1,0)
tdSql.query('select elapsed(ts,10s) from regular_table_2 interval(10s) union all select elapsed(ts,10s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.query('select elapsed(ts,1s) from regular_table_2 interval(10s) union all select elapsed(ts,1s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) ;')
tdSql.checkRows(70)
tdSql.checkData(0,1,1)
tdSql.checkData(0,1,10)
tdSql.checkData(9,1,0)
tdSql.query('select elapsed(ts,10s) from regular_table_2 interval(10s) order by ts desc union all select elapsed(ts,10s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) order by ts asc;')
tdSql.query('select elapsed(ts,1s) from regular_table_2 interval(10s) order by ts desc union all select elapsed(ts,1s) from regular_table_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) order by ts asc;')
tdSql.checkRows(70)
tdSql.checkData(0,1,0)
tdSql.checkData(1,1,1)
tdSql.checkData(9,1,1)
tdSql.checkData(1,1,10)
tdSql.checkData(9,1,10)
tdSql.query('select elapsed(ts,10s) from stable_1 group by tbname, ind order by ts desc union all select elapsed(ts,10s) from stable_2 group by tbname, ind order by ts asc ;')
tdSql.query('select elapsed(ts,1s) from stable_1 group by tbname, ind order by ts desc union all select elapsed(ts,1s) from stable_2 group by tbname, ind order by ts asc ;')
tdSql.checkRows(6)
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,90)
tdSql.query('select elapsed(ts,10s) from stable_1 group by tbname, ind order by ts desc union all select elapsed(ts,10s) from stable_1 group by tbname, ind order by ts asc ;')
tdSql.query('select elapsed(ts,1s) from stable_1 group by tbname, ind order by ts desc union all select elapsed(ts,1s) from stable_1 group by tbname, ind order by ts asc ;')
tdSql.checkRows(6)
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,90)
tdSql.query('select elapsed(ts,10s) from stable_1 interval(10s) group by tbname,ind order by ts desc union all select elapsed(ts,10s) from stable_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname,ind order by ts asc ;')
tdSql.query('select elapsed(ts,1s) from stable_1 interval(10s) group by tbname,ind order by ts desc union all select elapsed(ts,1s) from stable_2 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname,ind order by ts asc ;')
tdSql.checkRows(210)
tdSql.checkData(0,1,0)
tdSql.checkData(1,1,1)
tdSql.checkData(1,1,10)
tdSql.checkData(9,1,1)
tdSql.query('select elapsed(ts,10s) from stable_2 interval(10s) group by tbname,ind order by ts desc union all select elapsed(ts,10s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname,ind order by ts asc ;')
tdSql.query('select elapsed(ts,1s) from stable_2 interval(10s) group by tbname,ind order by ts desc union all select elapsed(ts,1s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname,ind order by ts asc ;')
tdSql.checkRows(210)
tdSql.checkData(0,1,0)
tdSql.checkData(1,1,1)
tdSql.checkData(9,1,1)
tdSql.checkData(1,1,10)
tdSql.checkData(9,1,10)
tdSql.query('select elapsed(ts,10s) from stable_1 interval(10s) group by tbname,ind order by ts desc union all select elapsed(ts,10s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname,ind order by ts asc ;')
tdSql.query('select elapsed(ts,1s) from stable_1 interval(10s) group by tbname,ind order by ts desc union all select elapsed(ts,1s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(10s) fill(prev) group by tbname,ind order by ts asc ;')
tdSql.checkRows(210)
tdSql.checkData(0,1,0)
tdSql.checkData(1,1,1)
tdSql.checkData(9,1,1)
tdSql.checkData(1,1,10)
tdSql.checkData(9,1,10)
def query_nest(self):
......@@ -1305,12 +1305,12 @@ class TDTestCase:
# ts can't be used at outer query
tdSql.query("select elapsed(ts,10s) from (select ts from regular_table_1 );")
tdSql.query("select elapsed(ts,1s) from (select ts from regular_table_1 );")
# case : TD-12164
tdSql.error("select elapsed(ts,10s) from (select qint ts from regular_table_1 );")
tdSql.error("select elapsed(tbname ,10s) from (select qint tbname from regular_table_1 );")
tdSql.error("select elapsed(ts,1s) from (select qint ts from regular_table_1 );")
tdSql.error("select elapsed(tbname ,1s) from (select qint tbname from regular_table_1 );")
tdSql.error("select elapsed(tsc ,1s) from (select q_int tsc from regular_table_1) ;")
tdSql.error("select elapsed(tsv ,1s) from (select elapsed(ts,1s) tsv from regular_table_1);")
tdSql.error("select elapsed(ts ,1s) from (select elapsed(ts,1s) ts from regular_table_1);")
......@@ -1318,40 +1318,40 @@ class TDTestCase:
# tdSql.error("select elapsed(tsc ,1s) from (select tscol tsc from regular_table_1) ;")
# case TD-12276
# tdSql.error("select elapsed(ts,10s) from (select ts,tbname from regular_table_1 order by ts asc );")
# tdSql.error("select elapsed(ts,1s) from (select ts,tbname from regular_table_1 order by ts asc );")
# tdSql.error("select elapsed(ts,10s) from (select ts,tbname from regular_table_1 order by ts desc );")
# tdSql.error("select elapsed(ts,1s) from (select ts,tbname from regular_table_1 order by ts desc );")
# tdSql.error("select elapsed(ts,10s) from (select ts ,max(q_int),tbname from regular_table_1 order by ts ) interval(1s);")
# tdSql.error("select elapsed(ts,1s) from (select ts ,max(q_int),tbname from regular_table_1 order by ts ) interval(1s);")
# tdSql.error("select elapsed(ts,10s) from (select ts ,q_int,tbname from regular_table_1 order by ts ) interval(1s);")
# tdSql.error("select elapsed(ts,1s) from (select ts ,q_int,tbname from regular_table_1 order by ts ) interval(1s);")
# sub table
tdSql.query("select elapsed(ts,10s) from (select ts from sub_table1_1 );")
tdSql.query("select elapsed(ts,1s) from (select ts from sub_table1_1 );")
# tdSql.error("select elapsed(ts,10s) from (select ts ,max(q_int),tbname from sub_table1_1 order by ts ) interval(1s);")
# tdSql.error("select elapsed(ts,1s) from (select ts ,max(q_int),tbname from sub_table1_1 order by ts ) interval(1s);")
# tdSql.error("select elapsed(ts,10s) from (select ts ,q_int,tbname from sub_table1_1 order by ts ) interval(1s);")
# tdSql.error("select elapsed(ts,1s) from (select ts ,q_int,tbname from sub_table1_1 order by ts ) interval(1s);")
tdSql.query("select elapsed(ts,10s) from (select ts ,tbname,top(q_int,3) from sub_table1_1 ) interval(10s);")
tdSql.query("select elapsed(ts,1s) from (select ts ,tbname,top(q_int,3) from sub_table1_1 ) interval(10s);")
tdSql.query("select elapsed(ts,10s) from (select ts ,tbname,bottom(q_int,3) from sub_table1_1 ) interval(10s);")
tdSql.query("select elapsed(ts,1s) from (select ts ,tbname,bottom(q_int,3) from sub_table1_1 ) interval(10s);")
tdSql.query("select elapsed(ts,10s) from (select ts ,tbname from sub_table1_1 ) interval(10s);")
tdSql.query("select elapsed(ts,1s) from (select ts ,tbname from sub_table1_1 ) interval(10s);")
tdSql.query("select elapsed(ts,10s) from (select ts ,tbname from sub_table1_1 ) interval(10s);")
tdSql.query("select elapsed(ts,1s) from (select ts ,tbname from sub_table1_1 ) interval(10s);")
# tdSql.error("select elapsed(ts,10s) from (select ts ,count(*),tbname from sub_table1_1 order by ts ) interval(1s);")
# tdSql.error("select elapsed(ts,1s) from (select ts ,count(*),tbname from sub_table1_1 order by ts ) interval(1s);")
querys = ["count(*)","avg(q_int)", "sum(q_double)","stddev(q_float)","LEASTSQUARES(q_int,0,1)","elapsed(ts,10s)"]
querys = ["count(*)","avg(q_int)", "sum(q_double)","stddev(q_float)","LEASTSQUARES(q_int,0,1)","elapsed(ts,1s)"]
for query in querys:
sql1 = "select elapsed(ts,10s) from (select %s from regular_table_1 order by ts ) interval(1s); " % query
sql2 = "select elapsed(ts,10s) from (select ts , tbname ,%s from regular_table_1 order by ts ) interval(1s); " % query
sql3 = "select elapsed(ts,10s) from (select ts , tbname ,%s from stable_1 group by tbname, ind order by ts ) interval(1s); " % query
sql4 = "select elapsed(ts,10s) from (select %s from sub_table2_1 order by ts ) interval(1s); " % query
sql5 = "select elapsed(ts,10s) from (select ts , tbname ,%s from sub_table2_1 order by ts ) interval(1s); " % query
sql1 = "select elapsed(ts,1s) from (select %s from regular_table_1 order by ts ) interval(1s); " % query
sql2 = "select elapsed(ts,1s) from (select ts , tbname ,%s from regular_table_1 order by ts ) interval(1s); " % query
sql3 = "select elapsed(ts,1s) from (select ts , tbname ,%s from stable_1 group by tbname, ind order by ts ) interval(1s); " % query
sql4 = "select elapsed(ts,1s) from (select %s from sub_table2_1 order by ts ) interval(1s); " % query
sql5 = "select elapsed(ts,1s) from (select ts , tbname ,%s from sub_table2_1 order by ts ) interval(1s); " % query
tdSql.error(sql1)
tdSql.error(sql2)
......@@ -1370,22 +1370,22 @@ class TDTestCase:
# stable
tdSql.error("select elapsed(ts,10s) from (select ts from stable_1 ) group by tbname ;")
tdSql.error("select elapsed(ts,1s) from (select ts from stable_1 ) group by tbname ;")
tdSql.error("select elapsed(ts,10s) from (select ts ,max(q_int),tbname from stable_1 group by tbname order by ts ) interval(1s) group by tbname;")
tdSql.error("select elapsed(ts,1s) from (select ts ,max(q_int),tbname from stable_1 group by tbname order by ts ) interval(1s) group by tbname;")
tdSql.error("select elapsed(ts,10s) from (select ts ,q_int,tbname from stable_1 order by ts ) interval(1s) group by tbname;")
tdSql.error("select elapsed(ts,1s) from (select ts ,q_int,tbname from stable_1 order by ts ) interval(1s) group by tbname;")
# mixup with aggregate
querys = ["max(q_int)","min(q_int)" , "first(q_tinyint)", "first(*)","last(q_int)","last(*)","top(q_double,1)",
"bottom(q_float,1)","PERCENTILE(q_int,10)","APERCENTILE(q_int,10)" ,"elapsed(ts,10s)"]
"bottom(q_float,1)","PERCENTILE(q_int,10)","APERCENTILE(q_int,10)" ,"elapsed(ts,1s)"]
for index , query in enumerate(querys):
sql1 = "select elapsed(ts,10s) from (select %s from sub_table1_1) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(10s) fill(prev) ; " %(query)
sql2 = "select elapsed(ts,10s) from (select %s from stable_1 ) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(10s) fill(prev) group by tbname; " %(query)
sql3 = "select elapsed(ts,10s) from (select %s from stable_1 group by tbname) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(10s) fill(prev) group by tbname; " %(query)
sql1 = "select elapsed(ts,1s) from (select %s from sub_table1_1) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(10s) fill(prev) ; " %(query)
sql2 = "select elapsed(ts,1s) from (select %s from stable_1 ) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(10s) fill(prev) group by tbname; " %(query)
sql3 = "select elapsed(ts,1s) from (select %s from stable_1 group by tbname) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(10s) fill(prev) group by tbname; " %(query)
if query in ["interp(q_int)" ]:
# print(sql1 )
......@@ -1397,55 +1397,55 @@ class TDTestCase:
tdSql.error(sql2)
tdSql.error(sql3)
tdSql.query("select elapsed(ts,10s) from (select ts,tbname from regular_table_1 order by ts ) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);")
tdSql.query("select elapsed(ts,1s) from (select ts,tbname from regular_table_1 order by ts ) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);")
tdSql.query("select elapsed(ts,10s) from (select ts ,max(q_int),tbname from regular_table_1 order by ts ) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);")
tdSql.query("select elapsed(ts,1s) from (select ts ,max(q_int),tbname from regular_table_1 order by ts ) where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev);")
# ===============================================inner nest============================================
# sub table
tdSql.query("select data from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from sub_table1_1 ); ")
tdSql.checkData(0,0,9)
tdSql.query("select data from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from sub_table1_1 ); ")
tdSql.checkData(0,0,90)
# tdSql.query("select data from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from sub_table1_1 \
# tdSql.query("select data from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from sub_table1_1 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(600)
# tdSql.checkData(0,0,0.1)
# tdSql.checkData(0,0,1)
tdSql.query("select * from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 ); ")
tdSql.checkData(0,5,9)
tdSql.query("select * from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 ); ")
tdSql.checkData(0,5,90)
# tdSql.query("select * from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select * from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(600)
# tdSql.checkData(0,0,0.1)
# tdSql.checkData(0,0,1)
tdSql.query("select max(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 ); ")
tdSql.checkData(0,0,9)
tdSql.query("select max(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 ); ")
tdSql.checkData(0,0,90)
# tdSql.query("select max(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select max(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(1)
# tdSql.checkData(0,0,0.1)
# tdSql.checkData(0,0,1)
# tdSql.query("select max(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from sub_empty_2 \
# tdSql.query("select max(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from sub_empty_2 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(0)
# tdSql.query("select max(data),min(data),avg(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select max(data),min(data),avg(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(1)
# tdSql.query("select ceil(data),floor(data),round(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select ceil(data),floor(data),round(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(600)
# tdSql.query("select spread(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select spread(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(1)
# tdSql.query("select diff(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select diff(data) from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(599)
......@@ -1453,23 +1453,23 @@ class TDTestCase:
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(598)
# tdSql.query("select ceil(data)from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select ceil(data)from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(600)
# tdSql.query("select floor(data)from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select floor(data)from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(600)
# tdSql.query("select round(data)from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select round(data)from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(600)
# tdSql.query("select data*10+2 from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select data*10+2 from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(600)
# tdSql.query("select data*10+2 from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,10s) data from regular_table_3 \
# tdSql.query("select data*10+2 from (select count(*),avg(q_int) , sum(q_double),stddev(q_float),LEASTSQUARES(q_int,0,1), elapsed(ts,1s) data from regular_table_3 \
# where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" interval(1s) fill(prev)); ")
# tdSql.checkRows(600)
......@@ -1477,49 +1477,49 @@ class TDTestCase:
# case TD-12344
# session not support stable
tdSql.error('select elapsed(ts,10s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" session(ts ,10s) group by tbname,ind order by ts asc ')
tdSql.error('select elapsed(ts,1s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" session(ts ,1s) group by tbname,ind order by ts asc ')
tdSql.query('select elapsed(ts,10s) from sub_table1_1 session(ts,1w) ; ')
tdSql.query('select elapsed(ts,1s) from sub_table1_1 session(ts,1w) ; ')
tdSql.checkRows(1)
tdSql.checkData(0,0,9)
tdSql.query('select elapsed(ts,10s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" session(ts,1w) ; ')
tdSql.checkData(0,0,90)
tdSql.query('select elapsed(ts,1s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" session(ts,1w) ; ')
tdSql.checkRows(1)
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,90)
tdSql.query('select elapsed(ts,10s) from ( select * from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") session(ts,1w) ; ')
tdSql.query('select elapsed(ts,1s) from ( select * from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") session(ts,1w) ; ')
tdSql.error('select elapsed(ts,10s) from ( select ts ,q_int from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") session(ts,1w) ; ')
tdSql.error('select elapsed(ts,10s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(20s) fill (next) session(ts,1w) ; ')
# tdSql.error('select elapsed(ts,1s) from ( select ts ,q_int from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") session(ts,1w) ; ')
# tdSql.error('select elapsed(ts,1s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(20s) fill (next) session(ts,1w) ; ')
tdSql.query('select elapsed(ts,10s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" session(ts,1w) ; ')
tdSql.query('select elapsed(ts,1s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" session(ts,1w) ; ')
tdSql.checkRows(0)
# windows state
# not support stable
tdSql.error('select elapsed(ts,10s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" state_window(q_int) group by tbname,ind order by ts asc ')
tdSql.error('select elapsed(ts,1s) from stable_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" state_window(q_int) group by tbname,ind order by ts asc ')
tdSql.query('select elapsed(ts,10s) from sub_table1_1 state_window(q_int) ; ')
tdSql.query('select elapsed(ts,1s) from sub_table1_1 state_window(q_int) ; ')
tdSql.checkRows(10)
tdSql.checkData(0,0,0)
tdSql.query('select elapsed(ts,10s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" state_window(q_int) ; ')
tdSql.query('select elapsed(ts,1s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" state_window(q_int) ; ')
tdSql.checkRows(10)
tdSql.checkData(0,0,0)
# tdSql.error('select elapsed(ts,10s) from ( select * from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") state_window(q_int) ; ')
# tdSql.error('select elapsed(ts,1s) from ( select * from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") state_window(q_int) ; ')
# tdSql.error('select elapsed(ts,10s) from ( select ts ,q_int from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") state_window(q_int) ; ')
# tdSql.error('select elapsed(ts,1s) from ( select ts ,q_int from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000") state_window(q_int) ; ')
# tdSql.error('select elapsed(ts,10s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(20s) fill (next) state_window(q_int) ; ')
# tdSql.error('select elapsed(ts,1s) from sub_table1_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" interval(20s) fill (next) state_window(q_int) ; ')
# tdSql.query('select elapsed(ts,10s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" state_window(q_int); ')
# tdSql.query('select elapsed(ts,1s) from sub_empty_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" state_window(q_int); ')
# tdSql.checkRows(0)
def continuous_query(self):
tdSql.error('create table elapsed_t as select elapsed(ts) from sub_table1_1 interval(1m) sliding(30s);')
tdSql.error('create table elapsed_tb as select elapsed(ts) from stable_1 interval(1m) sliding(30s) group by tbname;')
tdSql.error('create table elapsed_tc as select elapsed(ts) from stable_1 interval(10s) sliding(5s) interval(1m) sliding(30s) group by tbname;')
tdSql.error('create table elapsed_tc as select elapsed(ts) from stable_1 interval(1s) sliding(5s) interval(1m) sliding(30s) group by tbname;')
def query_precision(self):
def generate_data(precision="ms"):
......@@ -1549,7 +1549,7 @@ class TDTestCase:
tdSql.execute(sql1)
tdSql.execute(sql2)
time_units = ["10s","10a","10u","10b"]
time_units = ["1s","1a","1u","1b"]
precision_list = ["ms","us","ns"]
for pres in precision_list:
......@@ -1558,13 +1558,13 @@ class TDTestCase:
for index,unit in enumerate(time_units):
if pres == "ms":
if unit in ["10u","10b"]:
if unit in ["1u","1b"]:
tdSql.error("select elapsed(ts,%s) from db_%s.st group by tbname "%(unit,pres))
pass
else:
tdSql.query("select elapsed(ts,%s) from db_%s.st group by tbname "%(unit,pres))
elif pres == "us" and unit in ["10b"]:
if unit in ["10b"]:
elif pres == "us" and unit in ["1b"]:
if unit in ["1b"]:
tdSql.error("select elapsed(ts,%s) from db_%s.st group by tbname "%(unit,pres))
pass
else:
......@@ -1572,7 +1572,7 @@ class TDTestCase:
else:
tdSql.query("select elapsed(ts,%s) from db_%s.st group by tbname "%(unit,pres))
basic_result = 9
basic_result = 90
tdSql.checkData(0,0,basic_result*pow(1000,index))
def run(self):
......@@ -1600,4 +1600,3 @@ class TDTestCase:
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
......@@ -355,9 +355,63 @@ class TDTestCase:
tdSql.execute(f"create table tt{i} using stb2 tags({i})")
pass
def diff_support_stable(self):
tdSql.query(" select diff(1) from stb1 ")
tdSql.checkRows(229)
tdSql.checkData(0,0,0)
tdSql.query("select diff(c1) from stb1 partition by tbname ")
tdSql.checkRows(199)
# tdSql.query("select diff(st1) from stb1 partition by tbname")
# tdSql.checkRows(229)
tdSql.query("select diff(st1+c1) from stb1 partition by tbname")
tdSql.checkRows(199)
tdSql.query("select diff(st1+c1) from stb1 partition by tbname")
tdSql.checkRows(199)
tdSql.query("select diff(st1+c1) from stb1 partition by tbname")
tdSql.checkRows(199)
# # bug need fix
# tdSql.query("select diff(st1+c1) from stb1 partition by tbname slimit 1 ")
# tdSql.checkRows(19)
# tdSql.error("select diff(st1+c1) from stb1 partition by tbname limit 1 ")
# bug need fix
tdSql.query("select diff(st1+c1) from stb1 partition by tbname")
tdSql.checkRows(199)
# bug need fix
# tdSql.query("select tbname , diff(c1) from stb1 partition by tbname")
# tdSql.checkRows(199)
# tdSql.query("select tbname , diff(st1) from stb1 partition by tbname")
# tdSql.checkRows(199)
# tdSql.query("select tbname , diff(st1) from stb1 partition by tbname slimit 1")
# tdSql.checkRows(19)
# partition by tags
# tdSql.query("select st1 , diff(c1) from stb1 partition by st1")
# tdSql.checkRows(199)
# tdSql.query("select diff(c1) from stb1 partition by st1")
# tdSql.checkRows(199)
# tdSql.query("select st1 , diff(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(19)
# tdSql.query("select diff(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(19)
# partition by col
# tdSql.query("select c1 , diff(c1) from stb1 partition by c1")
# tdSql.checkRows(199)
# tdSql.query("select diff(c1) from stb1 partition by c1")
# tdSql.checkRows(41)
# tdSql.query("select c1 , diff(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(19)
# tdSql.query("select diff(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(19)
def diff_test_run(self) :
tdLog.printNoPrefix("==========TD-10594==========")
tdLog.printNoPrefix("==========run test case for diff function==========")
tbnum = 10
nowtime = int(round(time.time() * 1000))
per_table_rows = 10
......@@ -422,6 +476,7 @@ class TDTestCase:
try:
# run in develop branch
self.diff_test_run()
self.diff_support_stable()
pass
except Exception as e:
traceback.print_exc()
......
......@@ -673,11 +673,65 @@ class TDTestCase:
tdSql.query("select mavg(abs(c1),1) from t1")
tdSql.checkRows(4)
def mavg_support_stable(self):
tdSql.query(" select mavg(1,3) from stb1 ")
tdSql.checkRows(68)
tdSql.checkData(0,0,1.000000000)
tdSql.query("select mavg(c1,3) from stb1 partition by tbname ")
tdSql.checkRows(38)
# tdSql.query("select mavg(st1,3) from stb1 partition by tbname")
# tdSql.checkRows(38)
tdSql.query("select mavg(st1+c1,3) from stb1 partition by tbname")
tdSql.checkRows(38)
tdSql.query("select mavg(st1+c1,3) from stb1 partition by tbname")
tdSql.checkRows(38)
tdSql.query("select mavg(st1+c1,3) from stb1 partition by tbname")
tdSql.checkRows(38)
# # bug need fix
# tdSql.query("select mavg(st1+c1,3) from stb1 partition by tbname slimit 1 ")
# tdSql.checkRows(2)
# tdSql.error("select mavg(st1+c1,3) from stb1 partition by tbname limit 1 ")
# bug need fix
tdSql.query("select mavg(st1+c1,3) from stb1 partition by tbname")
tdSql.checkRows(38)
# bug need fix
# tdSql.query("select tbname , mavg(c1,3) from stb1 partition by tbname")
# tdSql.checkRows(38)
# tdSql.query("select tbname , mavg(st1,3) from stb1 partition by tbname")
# tdSql.checkRows(38)
# tdSql.query("select tbname , mavg(st1,3) from stb1 partition by tbname slimit 1")
# tdSql.checkRows(2)
# partition by tags
# tdSql.query("select st1 , mavg(c1,3) from stb1 partition by st1")
# tdSql.checkRows(38)
# tdSql.query("select mavg(c1,3) from stb1 partition by st1")
# tdSql.checkRows(38)
# tdSql.query("select st1 , mavg(c1,3) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(2)
# tdSql.query("select mavg(c1,3) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(2)
# partition by col
# tdSql.query("select c1 , mavg(c1,3) from stb1 partition by c1")
# tdSql.checkRows(38)
# tdSql.query("select mavg(c1 ,3) from stb1 partition by c1")
# tdSql.checkRows(38)
# tdSql.query("select c1 , mavg(c1,3) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(2)
# tdSql.query("select diff(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(2)
def run(self):
import traceback
try:
# run in develop branch
self.mavg_test_run()
self.mavg_support_stable()
pass
except Exception as e:
traceback.print_exc()
......
......@@ -478,6 +478,9 @@ class TDTestCase:
self.test_case3()
# tdLog.debug(" LIMIT test_case3 ............ [OK]")
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
return
#
......
......@@ -798,6 +798,36 @@ class TDTestCase:
tdSql.query("select sample(c1,100)+2 from ct1")
tdSql.query("select abs(sample(c1,100)) from ct1")
# support stable and tbname
tdSql.query("select tbname ,sample(c1,2) from stb1 partition by tbname order by tbname")
tdSql.checkRows(4)
tdSql.checkData(0,0,'ct1')
tdSql.checkData(3,0,'ct4')
# # bug need fix
# tdSql.query(" select tbname ,c1 ,t1, sample(c1,2) from stb1 partition by tbname order by tbname ")
# tdSql.checkRows(4)
# tdSql.checkData(0,0,'ct1')
# tdSql.checkData(3,0,'ct4')
# tdSql.checkData(0,2,1)
# tdSql.checkData(3,2,4)
tdSql.query(" select tbname ,c1 ,t1, sample(c1,2) from stb1 partition by t1 order by t1 ")
tdSql.checkRows(4)
tdSql.checkData(0,0,'ct1')
tdSql.checkData(3,0,'ct4')
tdSql.checkData(0,2,1)
tdSql.checkData(3,2,4)
# bug need fix
# tdSql.query(" select tbname ,c1 ,t1, sample(c1,2) from stb1 partition by c1 order by c1 ")
# tdSql.checkRows(21)
# bug need fix
# tdSql.query(" select sample(c1,2) from stb1 partition by c1 ")
# tdSql.checkRows(21)
def sample_test_run(self) :
tdLog.printNoPrefix("==========support sample function==========")
tbnum = 10
......
......@@ -18,6 +18,7 @@ class TDTestCase:
def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor())
self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record
def prepare_datas(self):
tdSql.execute(
......@@ -344,6 +345,8 @@ class TDTestCase:
tdSql.error("select stateduration(c1,'GT',1,1b) from ct1")
tdSql.error("select stateduration(c1,'GT',1,1u) from ct1")
tdSql.error("select stateduration(c1,'GT',1,1000s) from t1")
tdSql.error("select stateduration(c1,'GT',1,10m) from t1")
tdSql.error("select stateduration(c1,'GT',1,10d) from t1")
tdSql.query("select stateduration(c1,'GT',1,1s) from t1")
tdSql.checkData(10,0,63072035)
tdSql.query("select stateduration(c1,'GT',1,1m) from t1")
......@@ -355,6 +358,58 @@ class TDTestCase:
tdSql.query("select stateduration(c1,'GT',1,1w) from t1")
tdSql.checkData(10,0,int(63072035/60/7/24/60))
def query_precision(self):
def generate_data(precision="ms"):
tdSql.execute("create database if not exists db_%s precision '%s';" %(precision, precision))
tdSql.execute("use db_%s;" %precision)
tdSql.execute("create stable db_%s.st (ts timestamp , id int) tags(ind int);"%precision)
tdSql.execute("create table db_%s.tb1 using st tags(1);"%precision)
tdSql.execute("create table db_%s.tb2 using st tags(2);"%precision)
if precision == "ms":
start_ts = self.ts
step = 10000
elif precision == "us":
start_ts = self.ts*1000
step = 10000000
elif precision == "ns":
start_ts = self.ts*1000000
step = 10000000000
else:
pass
for i in range(10):
sql1 = "insert into db_%s.tb1 values (%d,%d)"%(precision ,start_ts+i*step,i)
sql2 = "insert into db_%s.tb1 values (%d,%d)"%(precision, start_ts+i*step,i)
tdSql.execute(sql1)
tdSql.execute(sql2)
time_units = ["1s","1a","1u","1b"]
precision_list = ["ms","us","ns"]
for pres in precision_list:
generate_data(pres)
for index,unit in enumerate(time_units):
if pres == "ms":
if unit in ["1u","1b"]:
tdSql.error("select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres))
pass
else:
tdSql.query("select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres))
elif pres == "us" and unit in ["1b"]:
if unit in ["1b"]:
tdSql.error("select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres))
pass
else:
tdSql.query("select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres))
else:
tdSql.query("select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres))
basic_result = 70
tdSql.checkData(9,0,basic_result*pow(1000,index))
def check_boundary_values(self):
......@@ -420,6 +475,8 @@ class TDTestCase:
tdLog.printNoPrefix("==========step6: statecount unit time test ============")
self.check_unit_time()
self.query_precision()
def stop(self):
......
......@@ -337,7 +337,7 @@ class TDTestCase:
tdSql.checkData(2,0,5)
# nest query
# tdSql.query("select tail(c1,2) from (select c1 from ct1)")
# tdSql.query("select tail(c1,2) from (select _rowts , c1 from ct1)")
tdSql.query("select c1 from (select tail(c1,2) c1 from ct4) order by 1 nulls first")
tdSql.checkRows(2)
tdSql.checkData(0, 0, None)
......@@ -363,9 +363,58 @@ class TDTestCase:
tdSql.error("select tail(c1,2) from ct1 group by tbname")
# super table
tdSql.error("select tbname , tail(c1,2) from stb1 group by tbname")
tdSql.query("select tail(c1,2) from stb1 partition by tbname")
tdSql.checkRows(4)
# bug need fix
# tdSql.query("select tbname , tail(c1,2) from stb1 partition by tbname")
# tdSql.checkRows(4)
# tdSql.query("select tbname , tail(c1,2) from stb1 partition by tbname order by tbname")
# tdSql.checkRows(4)
# tdSql.query(" select tbname , count(c1) from stb1 partition by tbname order by tbname ")
# tdSql.checkRows(2)
# tdSql.query(" select tbname , max(c1) ,c1 from stb1 partition by tbname order by tbname ")
# tdSql.checkRows(2)
# tdSql.query(" select tbname ,first(c1) from stb1 partition by tbname order by tbname ")
# tdSql.checkRows(2)
tdSql.query("select tail(c1,2) from stb1 partition by tbname")
tdSql.checkRows(4)
# # bug need fix
# tdSql.query(" select tbname , tail(c1,2) from stb1 where t1 = 0 partition by tbname ")
# tdSql.checkRows(2)
# tdSql.query(" select tbname , tail(c1,2) from stb1 where t1 = 0 partition by tbname order by tbname ")
# tdSql.checkRows(2)
# tdSql.query(" select tbname , tail(c1,2) from stb1 where c1 = 0 partition by tbname order by tbname ")
# tdSql.checkRows(3)
# tdSql.query(" select tbname , tail(c1,2) from stb1 where c1 = 0 partition by tbname ")
# tdSql.checkRows(3)
# tdSql.query(" select tbname , tail(c1,2) from stb1 where c1 = 0 partition by tbname ")
# tdSql.checkRows(3)
tdSql.query(" select tail(t1,2) from stb1 ")
tdSql.checkRows(2)
tdSql.query(" select tail(t1+c1,2) from stb1 ")
tdSql.checkRows(2)
tdSql.query(" select tail(t1+c1,2) from stb1 partition by tbname ")
tdSql.checkRows(4)
tdSql.query(" select tail(t1,2) from stb1 partition by tbname ")
tdSql.checkRows(4)
# nest query
tdSql.query(" select tail(c1,2) from (select _rowts , t1 ,c1 , tbname from stb1 ) ")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.checkData(1,0,9)
tdSql.query("select tail(t1,2) from (select _rowts , t1 , tbname from stb1 )")
tdSql.checkRows(2)
tdSql.checkData(0,0,4)
tdSql.checkData(1,0,1)
def check_boundary_values(self):
......
......@@ -21,7 +21,6 @@ class TDTestCase:
self.db_param_precision = ['ms','us','ns']
self.time_unit = ['1w','1d','1h','1m','1s','1a','1u','1b']
self.error_unit = ['2w','2d','2h','2m','2s','2a','2u','1c','#1']
self.error_unit = ['2w','2d','2h','2m','2s','2a','2u','1c','#1']
self.ntbname = 'ntb'
self.stbname = 'stb'
self.ctbname = 'ctb'
......
......@@ -387,8 +387,58 @@ class TDTestCase:
# super table
# super table
tdSql.error("select tbname , tail(c1,2) from stb1 group by tbname")
tdSql.query("select tail(c1,2) from stb1 partition by tbname")
tdSql.checkRows(4)
# bug need fix
# tdSql.query("select tbname , tail(c1,2) from stb1 partition by tbname")
# tdSql.checkRows(4)
# tdSql.query("select tbname , tail(c1,2) from stb1 partition by tbname order by tbname")
# tdSql.checkRows(4)
# tdSql.query(" select tbname , count(c1) from stb1 partition by tbname order by tbname ")
# tdSql.checkRows(2)
# tdSql.query(" select tbname , max(c1) ,c1 from stb1 partition by tbname order by tbname ")
# tdSql.checkRows(2)
# tdSql.query(" select tbname ,first(c1) from stb1 partition by tbname order by tbname ")
# tdSql.checkRows(2)
tdSql.query("select tail(c1,2) from stb1 partition by tbname")
tdSql.checkRows(4)
# # bug need fix
# tdSql.query(" select tbname , unique(c1) from stb1 where t1 = 0 partition by tbname ")
# tdSql.checkRows(2)
# tdSql.query(" select tbname , unique(c1) from stb1 where t1 = 0 partition by tbname order by tbname ")
# tdSql.checkRows(2)
# tdSql.query(" select tbname , unique(c1) from stb1 where c1 = 0 partition by tbname order by tbname ")
# tdSql.checkRows(3)
# tdSql.query(" select tbname , unique(c1) from stb1 where c1 = 0 partition by tbname ")
# tdSql.checkRows(3)
tdSql.query(" select unique(t1) from stb1 ")
tdSql.checkRows(2)
tdSql.query(" select unique(t1+c1) from stb1 ")
tdSql.checkRows(13)
tdSql.query(" select unique(t1+c1) from stb1 partition by tbname ")
tdSql.checkRows(13)
tdSql.query(" select unique(t1) from stb1 partition by tbname ")
tdSql.checkRows(2)
# nest query
tdSql.query(" select unique(c1) from (select _rowts , t1 ,c1 , tbname from stb1 ) ")
tdSql.checkRows(11)
tdSql.checkData(0,0,6)
tdSql.checkData(10,0,3)
tdSql.query("select unique(t1) from (select _rowts , t1 , tbname from stb1 )")
tdSql.checkRows(2)
tdSql.checkData(0,0,4)
tdSql.checkData(1,0,1)
def check_boundary_values(self):
......
......@@ -29,6 +29,7 @@ python3 ./test.py -f 1-insert/block_wise.py
python3 ./test.py -f 1-insert/create_retentions.py
#python3 ./test.py -f 1-insert/table_param_ttl.py
python3 ./test.py -f 2-query/between.py
python3 ./test.py -f 2-query/distinct.py
python3 ./test.py -f 2-query/varchar.py
......@@ -95,7 +96,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py
# python3 ./test.py -f 2-query/nestedQuery_str.py
python3 ./test.py -f 2-query/avg.py
#python3 ./test.py -f 2-query/elapsed.py
python3 ./test.py -f 2-query/elapsed.py
python3 ./test.py -f 2-query/csum.py
python3 ./test.py -f 2-query/mavg.py
python3 ./test.py -f 2-query/diff.py
......@@ -117,9 +118,10 @@ python3 ./test.py -f 2-query/distribute_agg_avg.py
python3 ./test.py -f 2-query/distribute_agg_stddev.py
python3 ./test.py -f 2-query/twa.py
python3 ./test.py -f 2-query/irate.py
python3 ./test.py -f 2-query/and_or_for_byte.py
python3 ./test.py -f 2-query/function_null.py
#python3 ./test.py -f 2-query/queryQnode.py
python3 ./test.py -f 2-query/queryQnode.py
#python3 ./test.py -f 6-cluster/5dnode1mnode.py
#python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3
......@@ -172,3 +174,177 @@ python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py
#------------querPolicy 2-----------
python3 ./test.py -f 2-query/between.py -Q 2
python3 ./test.py -f 2-query/distinct.py -Q 2
python3 ./test.py -f 2-query/varchar.py -Q 2
python3 ./test.py -f 2-query/ltrim.py -Q 2
python3 ./test.py -f 2-query/rtrim.py -Q 2
python3 ./test.py -f 2-query/length.py -Q 2
python3 ./test.py -f 2-query/char_length.py -Q 2
python3 ./test.py -f 2-query/upper.py -Q 2
python3 ./test.py -f 2-query/lower.py -Q 2
python3 ./test.py -f 2-query/join.py -Q 2
python3 ./test.py -f 2-query/join2.py -Q 2
python3 ./test.py -f 2-query/cast.py -Q 2
python3 ./test.py -f 2-query/substr.py -Q 2
python3 ./test.py -f 2-query/union.py -Q 2
python3 ./test.py -f 2-query/union1.py -Q 2
python3 ./test.py -f 2-query/concat.py -Q 2
python3 ./test.py -f 2-query/concat2.py -Q 2
python3 ./test.py -f 2-query/concat_ws.py -Q 2
python3 ./test.py -f 2-query/concat_ws2.py -Q 2
python3 ./test.py -f 2-query/check_tsdb.py -Q 2
python3 ./test.py -f 2-query/spread.py -Q 2
python3 ./test.py -f 2-query/hyperloglog.py -Q 2
python3 ./test.py -f 2-query/explain.py -Q 2
python3 ./test.py -f 2-query/leastsquares.py -Q 2
python3 ./test.py -f 2-query/timezone.py -Q 2
python3 ./test.py -f 2-query/Now.py -Q 2
python3 ./test.py -f 2-query/Today.py -Q 2
python3 ./test.py -f 2-query/max.py -Q 2
python3 ./test.py -f 2-query/min.py -Q 2
python3 ./test.py -f 2-query/count.py -Q 2
python3 ./test.py -f 2-query/last.py -Q 2
python3 ./test.py -f 2-query/first.py -Q 2
python3 ./test.py -f 2-query/To_iso8601.py -Q 2
python3 ./test.py -f 2-query/To_unixtimestamp.py -Q 2
python3 ./test.py -f 2-query/timetruncate.py -Q 2
python3 ./test.py -f 2-query/diff.py -Q 2
python3 ./test.py -f 2-query/Timediff.py -Q 2
python3 ./test.py -f 2-query/json_tag.py -Q 2
python3 ./test.py -f 2-query/top.py -Q 2
python3 ./test.py -f 2-query/bottom.py -Q 2
python3 ./test.py -f 2-query/percentile.py -Q 2
python3 ./test.py -f 2-query/apercentile.py -Q 2
python3 ./test.py -f 2-query/abs.py -Q 2
python3 ./test.py -f 2-query/ceil.py -Q 2
python3 ./test.py -f 2-query/floor.py -Q 2
python3 ./test.py -f 2-query/round.py -Q 2
python3 ./test.py -f 2-query/log.py -Q 2
python3 ./test.py -f 2-query/pow.py -Q 2
python3 ./test.py -f 2-query/sqrt.py -Q 2
python3 ./test.py -f 2-query/sin.py -Q 2
python3 ./test.py -f 2-query/cos.py -Q 2
python3 ./test.py -f 2-query/tan.py -Q 2
python3 ./test.py -f 2-query/arcsin.py -Q 2
python3 ./test.py -f 2-query/arccos.py -Q 2
python3 ./test.py -f 2-query/arctan.py -Q 2
python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 2
# python3 ./test.py -f 2-query/nestedQuery.py -Q 2
# python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2
python3 ./test.py -f 2-query/avg.py -Q 2
# python3 ./test.py -f 2-query/elapsed.py -Q 2
python3 ./test.py -f 2-query/csum.py -Q 2
python3 ./test.py -f 2-query/mavg.py -Q 2
python3 ./test.py -f 2-query/diff.py -Q 2
python3 ./test.py -f 2-query/sample.py -Q 2
python3 ./test.py -f 2-query/function_diff.py -Q 2
python3 ./test.py -f 2-query/unique.py -Q 2
python3 ./test.py -f 2-query/stateduration.py -Q 2
python3 ./test.py -f 2-query/function_stateduration.py -Q 2
python3 ./test.py -f 2-query/statecount.py -Q 2
python3 ./test.py -f 2-query/tail.py -Q 2
python3 ./test.py -f 2-query/ttl_comment.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_count.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_max.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_min.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_sum.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_spread.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_apercentile.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_avg.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_stddev.py -Q 2
python3 ./test.py -f 2-query/twa.py -Q 2
python3 ./test.py -f 2-query/irate.py -Q 2
python3 ./test.py -f 2-query/function_null.py -Q 2
#------------querPolicy 3-----------
python3 ./test.py -f 2-query/between.py -Q 3
python3 ./test.py -f 2-query/distinct.py -Q 3
python3 ./test.py -f 2-query/varchar.py -Q 3
python3 ./test.py -f 2-query/ltrim.py -Q 3
python3 ./test.py -f 2-query/rtrim.py -Q 3
python3 ./test.py -f 2-query/length.py -Q 3
python3 ./test.py -f 2-query/char_length.py -Q 3
python3 ./test.py -f 2-query/upper.py -Q 3
python3 ./test.py -f 2-query/lower.py -Q 3
python3 ./test.py -f 2-query/join.py -Q 3
python3 ./test.py -f 2-query/join2.py -Q 3
python3 ./test.py -f 2-query/cast.py -Q 3
python3 ./test.py -f 2-query/substr.py -Q 3
python3 ./test.py -f 2-query/union.py -Q 3
python3 ./test.py -f 2-query/union1.py -Q 3
python3 ./test.py -f 2-query/concat.py -Q 3
python3 ./test.py -f 2-query/concat2.py -Q 3
python3 ./test.py -f 2-query/concat_ws.py -Q 3
python3 ./test.py -f 2-query/concat_ws2.py -Q 3
python3 ./test.py -f 2-query/check_tsdb.py -Q 3
python3 ./test.py -f 2-query/spread.py -Q 3
python3 ./test.py -f 2-query/hyperloglog.py -Q 3
python3 ./test.py -f 2-query/explain.py -Q 3
python3 ./test.py -f 2-query/leastsquares.py -Q 3
python3 ./test.py -f 2-query/timezone.py -Q 3
python3 ./test.py -f 2-query/Now.py -Q 3
python3 ./test.py -f 2-query/Today.py -Q 3
python3 ./test.py -f 2-query/max.py -Q 3
python3 ./test.py -f 2-query/min.py -Q 3
python3 ./test.py -f 2-query/count.py -Q 3
python3 ./test.py -f 2-query/last.py -Q 3
python3 ./test.py -f 2-query/first.py -Q 3
python3 ./test.py -f 2-query/To_iso8601.py -Q 3
python3 ./test.py -f 2-query/To_unixtimestamp.py -Q 3
python3 ./test.py -f 2-query/timetruncate.py -Q 3
python3 ./test.py -f 2-query/diff.py -Q 3
python3 ./test.py -f 2-query/Timediff.py -Q 3
python3 ./test.py -f 2-query/json_tag.py -Q 3
python3 ./test.py -f 2-query/top.py -Q 3
python3 ./test.py -f 2-query/bottom.py -Q 3
python3 ./test.py -f 2-query/percentile.py -Q 3
python3 ./test.py -f 2-query/apercentile.py -Q 3
python3 ./test.py -f 2-query/abs.py -Q 3
python3 ./test.py -f 2-query/ceil.py -Q 3
python3 ./test.py -f 2-query/floor.py -Q 3
python3 ./test.py -f 2-query/round.py -Q 3
python3 ./test.py -f 2-query/log.py -Q 3
python3 ./test.py -f 2-query/pow.py -Q 3
python3 ./test.py -f 2-query/sqrt.py -Q 3
python3 ./test.py -f 2-query/sin.py -Q 3
python3 ./test.py -f 2-query/cos.py -Q 3
python3 ./test.py -f 2-query/tan.py -Q 3
python3 ./test.py -f 2-query/arcsin.py -Q 3
python3 ./test.py -f 2-query/arccos.py -Q 3
python3 ./test.py -f 2-query/arctan.py -Q 3
python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3
# python3 ./test.py -f 2-query/nestedQuery.py -Q 3
# python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3
# python3 ./test.py -f 2-query/avg.py -Q 3
# python3 ./test.py -f 2-query/elapsed.py -Q 3
python3 ./test.py -f 2-query/csum.py -Q 3
python3 ./test.py -f 2-query/mavg.py -Q 3
python3 ./test.py -f 2-query/diff.py -Q 3
python3 ./test.py -f 2-query/sample.py -Q 3
python3 ./test.py -f 2-query/function_diff.py -Q 3
python3 ./test.py -f 2-query/unique.py -Q 3
python3 ./test.py -f 2-query/stateduration.py -Q 3
python3 ./test.py -f 2-query/function_stateduration.py -Q 3
python3 ./test.py -f 2-query/statecount.py -Q 3
python3 ./test.py -f 2-query/tail.py -Q 3
python3 ./test.py -f 2-query/ttl_comment.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_count.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_max.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_min.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_sum.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_spread.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_apercentile.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_avg.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_stddev.py -Q 3
python3 ./test.py -f 2-query/twa.py -Q 3
python3 ./test.py -f 2-query/irate.py -Q 3
python3 ./test.py -f 2-query/function_null.py -Q 3
......@@ -44,27 +44,27 @@ static int32_t shellParseSingleOpt(int32_t key, char *arg);
void shellPrintHelp() {
char indent[] = " ";
printf("Usage: taos [OPTION...] \n\n");
printf("%s%s%s%s\n", indent, "-a,", indent, SHELL_AUTH);
printf("%s%s%s%s\n", indent, "-A,", indent, SHELL_GEN_AUTH);
printf("%s%s%s%s\n", indent, "-c,", indent, SHELL_CFG_DIR);
printf("%s%s%s%s\n", indent, "-C,", indent, SHELL_DMP_CFG);
printf("%s%s%s%s\n", indent, "-d,", indent, SHELL_DB);
printf("%s%s%s%s\n", indent, "-f,", indent, SHELL_FILE);
printf("%s%s%s%s\n", indent, "-h,", indent, SHELL_HOST);
printf("%s%s%s%s\n", indent, "-k,", indent, SHELL_CHECK);
printf("%s%s%s%s\n", indent, "-l,", indent, SHELL_PKG_LEN);
printf("%s%s%s%s\n", indent, "-n,", indent, SHELL_NET_ROLE);
printf("%s%s%s%s\n", indent, "-N,", indent, SHELL_PKT_NUM);
printf("%s%s%s%s\n", indent, "-p,", indent, SHELL_PASSWORD);
printf("%s%s%s%s\n", indent, "-P,", indent, SHELL_PORT);
printf("%s%s%s%s\n", indent, "-r,", indent, SHELL_RAW_TIME);
printf("%s%s%s%s\n", indent, "-s,", indent, SHELL_CMD);
printf("%s%s%s%s\n", indent, "-t,", indent, SHELL_STARTUP);
printf("%s%s%s%s\n", indent, "-u,", indent, SHELL_USER);
printf("%s%s%s%s\n", indent, "-w,", indent, SHELL_WIDTH);
printf("%s%s%s%s\n", indent, "-V,", indent, SHELL_VERSION);
printf("\n\nReport bugs to %s.\n", SHELL_EMAIL);
printf("Usage: taos [OPTION...] \r\n\r\n");
printf("%s%s%s%s\r\n", indent, "-a,", indent, SHELL_AUTH);
printf("%s%s%s%s\r\n", indent, "-A,", indent, SHELL_GEN_AUTH);
printf("%s%s%s%s\r\n", indent, "-c,", indent, SHELL_CFG_DIR);
printf("%s%s%s%s\r\n", indent, "-C,", indent, SHELL_DMP_CFG);
printf("%s%s%s%s\r\n", indent, "-d,", indent, SHELL_DB);
printf("%s%s%s%s\r\n", indent, "-f,", indent, SHELL_FILE);
printf("%s%s%s%s\r\n", indent, "-h,", indent, SHELL_HOST);
printf("%s%s%s%s\r\n", indent, "-k,", indent, SHELL_CHECK);
printf("%s%s%s%s\r\n", indent, "-l,", indent, SHELL_PKG_LEN);
printf("%s%s%s%s\r\n", indent, "-n,", indent, SHELL_NET_ROLE);
printf("%s%s%s%s\r\n", indent, "-N,", indent, SHELL_PKT_NUM);
printf("%s%s%s%s\r\n", indent, "-p,", indent, SHELL_PASSWORD);
printf("%s%s%s%s\r\n", indent, "-P,", indent, SHELL_PORT);
printf("%s%s%s%s\r\n", indent, "-r,", indent, SHELL_RAW_TIME);
printf("%s%s%s%s\r\n", indent, "-s,", indent, SHELL_CMD);
printf("%s%s%s%s\r\n", indent, "-t,", indent, SHELL_STARTUP);
printf("%s%s%s%s\r\n", indent, "-u,", indent, SHELL_USER);
printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH);
printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION);
printf("\r\n\r\nReport bugs to %s.\r\n", SHELL_EMAIL);
}
#ifdef LINUX
......@@ -196,23 +196,23 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) {
char *key = argv[i];
int32_t keyLen = strlen(key);
if (keyLen != 2) {
fprintf(stderr, "invalid option %s\n", key);
fprintf(stderr, "invalid option %s\r\n", key);
return -1;
}
if (key[0] != '-') {
fprintf(stderr, "invalid option %s\n", key);
fprintf(stderr, "invalid option %s\r\n", key);
return -1;
}
if (key[1] == 'h' || key[1] == 'P' || key[1] == 'u' || key[1] == 'a' || key[1] == 'c' || key[1] == 's' ||
key[1] == 'f' || key[1] == 'd' || key[1] == 'w' || key[1] == 'n' || key[1] == 'l' || key[1] == 'N') {
if (i + 1 >= argc) {
fprintf(stderr, "option %s requires an argument\n", key);
fprintf(stderr, "option %s requires an argument\r\n", key);
return -1;
}
char *val = argv[i + 1];
if (val[0] == '-') {
fprintf(stderr, "option %s requires an argument\n", key);
fprintf(stderr, "option %s requires an argument\r\n", key);
return -1;
}
shellParseSingleOpt(key[1], val);
......@@ -221,7 +221,7 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) {
key[1] == 't' || key[1] == 'V' || key[1] == '?' || key[1] == 1) {
shellParseSingleOpt(key[1], NULL);
} else {
fprintf(stderr, "invalid option %s\n", key);
fprintf(stderr, "invalid option %s\r\n", key);
return -1;
}
}
......@@ -241,7 +241,7 @@ static void shellInitArgs(int argc, char *argv[]) {
}
taosSetConsoleEcho(true);
if (EOF == getchar()) {
fprintf(stderr, "getchar() return EOF\n");
fprintf(stderr, "getchar() return EOF\r\n");
}
} else {
tstrncpy(shell.args.password, (char *)(argv[i] + 2), sizeof(shell.args.password));
......@@ -263,22 +263,22 @@ static void shellInitArgs(int argc, char *argv[]) {
static int32_t shellCheckArgs() {
SShellArgs *pArgs = &shell.args;
if (pArgs->host != NULL && (strlen(pArgs->host) <= 0 || strlen(pArgs->host) > TSDB_FQDN_LEN)) {
printf("Invalid host:%s\n", pArgs->host);
printf("Invalid host:%s\r\n", pArgs->host);
return -1;
}
if (pArgs->user != NULL && (strlen(pArgs->user) <= 0 || strlen(pArgs->user) > TSDB_USER_LEN)) {
printf("Invalid user:%s\n", pArgs->user);
printf("Invalid user:%s\r\n", pArgs->user);
return -1;
}
if (pArgs->auth != NULL && (strlen(pArgs->auth) <= 0 || strlen(pArgs->auth) > TSDB_PASSWORD_LEN)) {
printf("Invalid auth:%s\n", pArgs->auth);
printf("Invalid auth:%s\r\n", pArgs->auth);
return -1;
}
if (pArgs->database != NULL && (strlen(pArgs->database) <= 0 || strlen(pArgs->database) > TSDB_DB_NAME_LEN)) {
printf("Invalid database:%s\n", pArgs->database);
printf("Invalid database:%s\r\n", pArgs->database);
return -1;
}
......@@ -291,7 +291,7 @@ static int32_t shellCheckArgs() {
if (pArgs->cfgdir != NULL) {
if (strlen(pArgs->cfgdir) <= 0 || strlen(pArgs->cfgdir) >= PATH_MAX) {
printf("Invalid cfgdir:%s\n", pArgs->cfgdir);
printf("Invalid cfgdir:%s\r\n", pArgs->cfgdir);
return -1;
} else {
if (taosExpandDir(pArgs->cfgdir, configDir, PATH_MAX) != 0) {
......@@ -301,37 +301,37 @@ static int32_t shellCheckArgs() {
}
if (pArgs->commands != NULL && (strlen(pArgs->commands) <= 0)) {
printf("Invalid commands:%s\n", pArgs->commands);
printf("Invalid commands:%s\r\n", pArgs->commands);
return -1;
}
if (pArgs->netrole != NULL && !(strcmp(pArgs->netrole, "client") == 0 || strcmp(pArgs->netrole, "server") == 0)) {
printf("Invalid netrole:%s\n", pArgs->netrole);
printf("Invalid netrole:%s\r\n", pArgs->netrole);
return -1;
}
if (pArgs->password != NULL && (strlen(pArgs->password) <= 0)) {
printf("Invalid password\n");
printf("Invalid password\r\n");
return -1;
}
if (pArgs->port < 0 || pArgs->port > 65535) {
printf("Invalid port\n");
printf("Invalid port\r\n");
return -1;
}
if (pArgs->pktLen < SHELL_MIN_PKG_LEN || pArgs->pktLen > SHELL_MAX_PKG_LEN) {
printf("Invalid pktLen:%d, range:[%d, %d]\n", pArgs->pktLen, SHELL_MIN_PKG_LEN, SHELL_MAX_PKG_LEN);
printf("Invalid pktLen:%d, range:[%d, %d]\r\n", pArgs->pktLen, SHELL_MIN_PKG_LEN, SHELL_MAX_PKG_LEN);
return -1;
}
if (pArgs->pktNum < SHELL_MIN_PKG_NUM || pArgs->pktNum > SHELL_MAX_PKG_NUM) {
printf("Invalid pktNum:%d, range:[%d, %d]\n", pArgs->pktNum, SHELL_MIN_PKG_NUM, SHELL_MAX_PKG_NUM);
printf("Invalid pktNum:%d, range:[%d, %d]\r\n", pArgs->pktNum, SHELL_MIN_PKG_NUM, SHELL_MAX_PKG_NUM);
return -1;
}
if (pArgs->displayWidth <= 0 || pArgs->displayWidth > 10 * 1024) {
printf("Invalid displayWidth:%d, range:[1, 10 * 1024]\n", pArgs->displayWidth);
printf("Invalid displayWidth:%d, range:[1, 10 * 1024]\r\n", pArgs->displayWidth);
return -1;
}
......@@ -341,8 +341,8 @@ static int32_t shellCheckArgs() {
int32_t shellParseArgs(int32_t argc, char *argv[]) {
shellInitArgs(argc, argv);
shell.info.clientVersion =
"Welcome to the TDengine shell from %s, Client Version:%s\n"
"Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.\n\n";
"Welcome to the TDengine shell from %s, Client Version:%s\r\n"
"Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.\r\n\r\n";
shell.info.promptHeader = TAOS_CONSOLE_PROMPT_HEADER;
shell.info.promptContinue = TAOS_CONSOLE_PROMPT_CONTINUE;
shell.info.promptSize = 6;
......
......@@ -314,7 +314,7 @@ void shellGetScreenSize(int32_t *ws_col, int32_t *ws_row) {
#else
struct winsize w;
if (ioctl(0, TIOCGWINSZ, &w) < 0 || w.ws_col == 0 || w.ws_row == 0) {
// fprintf(stderr, "No stream device, and use default value(col 120, row 30)\n");
// fprintf(stderr, "No stream device, and use default value(col 120, row 30)\r\n");
if (ws_col != NULL) *ws_col = 120;
if (ws_row != NULL) *ws_row = 30;
} else {
......@@ -473,7 +473,7 @@ int32_t shellReadCommand(char *command) {
shellPositionCursorHome(&cmd);
break;
case 3:
printf("\n");
printf("\r\n");
shellResetCommand(&cmd, "");
#ifdef WINDOWS
raise(SIGINT);
......@@ -483,7 +483,7 @@ int32_t shellReadCommand(char *command) {
break;
case 4: // EOF or Ctrl+D
taosResetTerminalMode();
printf("\n");
printf("\r\n");
return -1;
case 5: // ctrl E
shellPositionCursorEnd(&cmd);
......@@ -495,7 +495,7 @@ int32_t shellReadCommand(char *command) {
case '\r':
#ifdef WINDOWS
#else
printf("\n");
printf("\r\n");
#endif
if (shellIsReadyGo(&cmd)) {
sprintf(command, "%s%s", cmd.buffer, cmd.command);
......
......@@ -180,7 +180,7 @@ void shellRunSingleCommandImp(char *command) {
}
if (shellRegexMatch(command, "^\\s*use\\s+[a-zA-Z0-9_]+\\s*;\\s*$", REG_EXTENDED | REG_ICASE)) {
fprintf(stdout, "Database changed.\n\n");
fprintf(stdout, "Database changed.\r\n\r\n");
fflush(stdout);
taos_free_result(pSql);
......@@ -197,19 +197,19 @@ void shellRunSingleCommandImp(char *command) {
et = taosGetTimestampUs();
if (error_no == 0) {
printf("Query OK, %d rows affected (%.6fs)\n", numOfRows, (et - st) / 1E6);
printf("Query OK, %d rows affected (%.6fs)\r\n", numOfRows, (et - st) / 1E6);
} else {
printf("Query interrupted (%s), %d rows affected (%.6fs)\n", taos_errstr(pSql), numOfRows, (et - st) / 1E6);
printf("Query interrupted (%s), %d rows affected (%.6fs)\r\n", taos_errstr(pSql), numOfRows, (et - st) / 1E6);
}
taos_free_result(pSql);
} else {
int32_t num_rows_affacted = taos_affected_rows(pSql);
taos_free_result(pSql);
et = taosGetTimestampUs();
printf("Query OK, %d of %d rows affected (%.6fs)\n", num_rows_affacted, num_rows_affacted, (et - st) / 1E6);
printf("Query OK, %d of %d rows affected (%.6fs)\r\n", num_rows_affacted, num_rows_affacted, (et - st) / 1E6);
}
printf("\n");
printf("\r\n");
}
char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
......@@ -344,7 +344,7 @@ int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres) {
TdFilePtr pFile = taosOpenFile(fullname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
if (pFile == NULL) {
fprintf(stderr, "failed to open file: %s\n", fullname);
fprintf(stderr, "failed to open file: %s\r\n", fullname);
return -1;
}
......@@ -358,7 +358,7 @@ int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres) {
}
taosFprintfFile(pFile, "%s", fields[col].name);
}
taosFprintfFile(pFile, "\n");
taosFprintfFile(pFile, "\r\n");
int32_t numOfRows = 0;
do {
......@@ -369,7 +369,7 @@ int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres) {
}
shellDumpFieldToFile(pFile, (const char *)row[i], fields + i, length[i], precision);
}
taosFprintfFile(pFile, "\n");
taosFprintfFile(pFile, "\r\n");
numOfRows++;
row = taos_fetch_row(tres);
......@@ -559,7 +559,7 @@ int32_t shellVerticalPrintResult(TAOS_RES *tres, const char *sql) {
int32_t showMore = 1;
do {
if (numOfRows < resShowMaxNum) {
printf("*************************** %d.row ***************************\n", numOfRows + 1);
printf("*************************** %d.row ***************************\r\n", numOfRows + 1);
int32_t *length = taos_fetch_lengths(tres);
......@@ -570,16 +570,17 @@ int32_t shellVerticalPrintResult(TAOS_RES *tres, const char *sql) {
printf("%*.s%s: ", padding, " ", field->name);
shellPrintField((const char *)row[i], field, 0, length[i], precision);
putchar('\r');
putchar('\n');
}
} else if (showMore) {
printf("\n");
printf(" Notice: The result shows only the first %d rows.\n", SHELL_DEFAULT_RES_SHOW_NUM);
printf(" You can use the `LIMIT` clause to get fewer result to show.\n");
printf(" Or use '>>' to redirect the whole set of the result to a specified file.\n");
printf("\n");
printf(" You can use Ctrl+C to stop the underway fetching.\n");
printf("\n");
printf("\r\n");
printf(" Notice: The result shows only the first %d rows.\r\n", SHELL_DEFAULT_RES_SHOW_NUM);
printf(" You can use the `LIMIT` clause to get fewer result to show.\r\n");
printf(" Or use '>>' to redirect the whole set of the result to a specified file.\r\n");
printf("\r\n");
printf(" You can use Ctrl+C to stop the underway fetching.\r\n");
printf("\r\n");
showMore = 0;
}
......@@ -667,10 +668,12 @@ void shellPrintHeader(TAOS_FIELD *fields, int32_t *width, int32_t num_fields) {
rowWidth += width[col] + 3;
}
putchar('\r');
putchar('\n');
for (int32_t i = 0; i < rowWidth; i++) {
putchar('=');
}
putchar('\r');
putchar('\n');
}
......@@ -709,15 +712,16 @@ int32_t shellHorizontalPrintResult(TAOS_RES *tres, const char *sql) {
putchar(' ');
putchar('|');
}
putchar('\r');
putchar('\n');
} else if (showMore) {
printf("\n");
printf(" Notice: The result shows only the first %d rows.\n", SHELL_DEFAULT_RES_SHOW_NUM);
printf(" You can use the `LIMIT` clause to get fewer result to show.\n");
printf(" Or use '>>' to redirect the whole set of the result to a specified file.\n");
printf("\n");
printf(" You can use Ctrl+C to stop the underway fetching.\n");
printf("\n");
printf("\r\n");
printf(" Notice: The result shows only the first %d rows.\r\n", SHELL_DEFAULT_RES_SHOW_NUM);
printf(" You can use the `LIMIT` clause to get fewer result to show.\r\n");
printf(" Or use '>>' to redirect the whole set of the result to a specified file.\r\n");
printf("\r\n");
printf(" You can use Ctrl+C to stop the underway fetching.\r\n");
printf("\r\n");
showMore = 0;
}
......@@ -794,7 +798,7 @@ void shellCleanupHistory() {
void shellPrintError(TAOS_RES *tres, int64_t st) {
int64_t et = taosGetTimestampUs();
fprintf(stderr, "\nDB error: %s (%.6fs)\n", taos_errstr(tres), (et - st) / 1E6);
fprintf(stderr, "\r\nDB error: %s (%.6fs)\r\n", taos_errstr(tres), (et - st) / 1E6);
taos_free_result(tres);
}
......@@ -816,7 +820,7 @@ void shellSourceFile(const char *file) {
TdFilePtr pFile = taosOpenFile(fullname, TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) {
fprintf(stderr, "failed to open file %s\n", fullname);
fprintf(stderr, "failed to open file %s\r\n", fullname);
taosMemoryFree(cmd);
return;
}
......@@ -837,7 +841,7 @@ void shellSourceFile(const char *file) {
}
memcpy(cmd + cmd_len, line, read_len);
printf("%s%s\n", shell.info.promptHeader, cmd);
printf("%s%s\r\n", shell.info.promptHeader, cmd);
shellRunCommand(cmd);
memset(cmd, 0, TSDB_MAX_ALLOWED_SQL_LEN);
cmd_len = 0;
......@@ -851,7 +855,7 @@ void shellSourceFile(const char *file) {
void shellGetGrantInfo() {
char sinfo[1024] = {0};
tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo));
strtok(sinfo, "\n");
strtok(sinfo, "\r\n");
char sql[] = "show grants";
......@@ -860,25 +864,25 @@ void shellGetGrantInfo() {
int32_t code = taos_errno(tres);
if (code != TSDB_CODE_SUCCESS) {
if (code != TSDB_CODE_OPS_NOT_SUPPORT && code != TSDB_CODE_MND_NO_RIGHTS) {
fprintf(stderr, "Failed to check Server Edition, Reason:0x%04x:%s\n\n", code, taos_errstr(tres));
fprintf(stderr, "Failed to check Server Edition, Reason:0x%04x:%s\r\n\r\n", code, taos_errstr(tres));
}
return;
}
int32_t num_fields = taos_field_count(tres);
if (num_fields == 0) {
fprintf(stderr, "\nInvalid grant information.\n");
fprintf(stderr, "\r\nInvalid grant information.\r\n");
exit(0);
} else {
if (tres == NULL) {
fprintf(stderr, "\nGrant information is null.\n");
fprintf(stderr, "\r\nGrant information is null.\r\n");
exit(0);
}
TAOS_FIELD *fields = taos_fetch_fields(tres);
TAOS_ROW row = taos_fetch_row(tres);
if (row == NULL) {
fprintf(stderr, "\nFailed to get grant information from server. Abort.\n");
fprintf(stderr, "\r\nFailed to get grant information from server. Abort.\r\n");
exit(0);
}
......@@ -891,17 +895,17 @@ void shellGetGrantInfo() {
memcpy(expired, row[2], fields[2].bytes);
if (strcmp(serverVersion, "community") == 0) {
fprintf(stdout, "Server is Community Edition.\n");
fprintf(stdout, "Server is Community Edition.\r\n");
} else if (strcmp(expiretime, "unlimited") == 0) {
fprintf(stdout, "Server is Enterprise %s Edition, %s and will never expire.\n", serverVersion, sinfo);
fprintf(stdout, "Server is Enterprise %s Edition, %s and will never expire.\r\n", serverVersion, sinfo);
} else {
fprintf(stdout, "Server is Enterprise %s Edition, %s and will expire at %s.\n", serverVersion, sinfo, expiretime);
fprintf(stdout, "Server is Enterprise %s Edition, %s and will expire at %s.\r\n", serverVersion, sinfo, expiretime);
}
taos_free_result(tres);
}
fprintf(stdout, "\n");
fprintf(stdout, "\r\n");
}
void shellQueryInterruptHandler(int32_t signum, void *sigInfo, void *context) { tsem_post(&shell.cancelSem); }
......@@ -921,7 +925,7 @@ void *shellCancelHandler(void *arg) {
}
taosResetTerminalMode();
printf("\nReceive SIGTERM or other signal, quit shell.\n");
printf("\r\nReceive SIGTERM or other signal, quit shell.\r\n");
shellWriteHistory();
shellExit();
}
......@@ -936,7 +940,7 @@ void *shellThreadLoop(void *arg) {
char *command = taosMemoryMalloc(SHELL_MAX_COMMAND_SIZE);
if (command == NULL) {
printf("failed to malloc command\n");
printf("failed to malloc command\r\n");
return NULL;
}
......@@ -979,7 +983,7 @@ int32_t shellExecute() {
if (pArgs->commands != NULL || pArgs->file[0] != 0) {
if (pArgs->commands != NULL) {
printf("%s%s\n", shell.info.promptHeader, pArgs->commands);
printf("%s%s\r\n", shell.info.promptHeader, pArgs->commands);
char *cmd = strdup(pArgs->commands);
shellRunCommand(cmd);
taosMemoryFree(cmd);
......@@ -996,7 +1000,7 @@ int32_t shellExecute() {
}
if (tsem_init(&shell.cancelSem, 0, 0) != 0) {
printf("failed to create cancel semphore\n");
printf("failed to create cancel semphore\r\n");
return -1;
}
......
......@@ -34,7 +34,7 @@ static void shellWorkAsClient() {
clientRpc = rpcOpen(&rpcInit);
if (clientRpc == NULL) {
printf("failed to init net test client since %s\n", terrstr());
printf("failed to init net test client since %s\r\n", terrstr());
goto _OVER;
}
......@@ -49,7 +49,7 @@ static void shellWorkAsClient() {
pArgs->port = tsServerPort;
}
printf("network test client is initialized, the server is %s:%u\n", fqdn, pArgs->port);
printf("network test client is initialized, the server is %s:%u\r\n", fqdn, pArgs->port);
tstrncpy(epSet.eps[0].fqdn, fqdn, TSDB_FQDN_LEN);
epSet.eps[0].port = (uint16_t)pArgs->port;
......@@ -62,13 +62,13 @@ static void shellWorkAsClient() {
rpcMsg.pCont = rpcMallocCont(pArgs->pktLen);
rpcMsg.contLen = pArgs->pktLen;
printf("request is sent, size:%d\n", rpcMsg.contLen);
printf("request is sent, size:%d\r\n", rpcMsg.contLen);
rpcSendRecv(clientRpc, &epSet, &rpcMsg, &rpcRsp);
if (rpcRsp.code == 0 && rpcRsp.contLen == rpcMsg.contLen) {
printf("response is received, size:%d\n", rpcMsg.contLen);
printf("response is received, size:%d\r\n", rpcMsg.contLen);
if (rpcRsp.code == 0) totalSucc++;
} else {
printf("response not received since %s\n", tstrerror(rpcRsp.code));
printf("response not received since %s\r\n", tstrerror(rpcRsp.code));
}
rpcFreeCont(rpcRsp.pCont);
......@@ -78,7 +78,7 @@ static void shellWorkAsClient() {
uint64_t endTime = taosGetTimestampUs();
uint64_t elT = endTime - startTime;
printf("\ntotal succ:%5d/%d\tcost:%8.2lf ms\tspeed:%8.2lf MB/s\n", totalSucc, pArgs->pktNum, elT / 1000.0,
printf("\r\ntotal succ:%5d/%d\tcost:%8.2lf ms\tspeed:%8.2lf MB/s\r\n", totalSucc, pArgs->pktNum, elT / 1000.0,
pArgs->pktLen / (elT / 1000000.0) / 1024.0 / 1024.0 * totalSucc);
_OVER:
......@@ -91,7 +91,7 @@ _OVER:
}
static void shellProcessMsg(void *p, SRpcMsg *pRpc, SEpSet *pEpSet) {
printf("request is received, size:%d\n", pRpc->contLen);
printf("request is received, size:%d\r\n", pRpc->contLen);
fflush(stdout);
SRpcMsg rsp = {.info = pRpc->info, .code = 0};
rsp.pCont = rpcMallocCont(pRpc->contLen);
......@@ -124,9 +124,9 @@ static void shellWorkAsServer() {
void *serverRpc = rpcOpen(&rpcInit);
if (serverRpc == NULL) {
printf("failed to init net test server since %s\n", terrstr());
printf("failed to init net test server since %s\r\n", terrstr());
} else {
printf("network test server is initialized, port:%u\n", pArgs->port);
printf("network test server is initialized, port:%u\r\n", pArgs->port);
taosSetSignal(SIGTERM, shellNettestHandler);
while (1) taosMsleep(10);
}
......
......@@ -40,7 +40,7 @@ bool shellRegexMatch(const char *s, const char *reg, int32_t cflags) {
return false;
} else {
regerror(reti, &regex, msgbuf, sizeof(msgbuf));
fprintf(stderr, "Regex match failed: %s\n", msgbuf);
fprintf(stderr, "Regex match failed: %s\r\n", msgbuf);
regfree(&regex);
shellExit();
}
......@@ -68,19 +68,19 @@ int32_t shellCheckIntSize() {
return 0;
}
void shellPrintVersion() { printf("version: %s\n", version); }
void shellPrintVersion() { printf("version: %s\r\n", version); }
void shellGenerateAuth() {
char secretEncrypt[TSDB_PASSWORD_LEN + 1] = {0};
taosEncryptPass_c((uint8_t *)shell.args.password, strlen(shell.args.password), secretEncrypt);
printf("%s\n", secretEncrypt);
printf("%s\r\n", secretEncrypt);
fflush(stdout);
}
void shellDumpConfig() {
SConfig *pCfg = taosGetCfg();
if (pCfg == NULL) {
printf("TDengine read global config failed!\n");
printf("TDengine read global config failed!\r\n");
} else {
cfgDumpCfg(pCfg, 1, true);
}
......@@ -95,23 +95,23 @@ void shellCheckServerStatus() {
code = taos_check_server_status(shell.args.host, shell.args.port, details, 1024);
switch (code) {
case TSDB_SRV_STATUS_UNAVAILABLE:
printf("0: unavailable\n");
printf("0: unavailable\r\n");
break;
case TSDB_SRV_STATUS_NETWORK_OK:
printf("1: network ok\n");
printf("1: network ok\r\n");
break;
case TSDB_SRV_STATUS_SERVICE_OK:
printf("2: service ok\n");
printf("2: service ok\r\n");
break;
case TSDB_SRV_STATUS_SERVICE_DEGRADED:
printf("3: service degraded\n");
printf("3: service degraded\r\n");
break;
case TSDB_SRV_STATUS_EXTING:
printf("4: exiting\n");
printf("4: exiting\r\n");
break;
}
if (strlen(details) != 0) {
printf("%s\n\n", details);
printf("%s\r\n\r\n", details);
}
fflush(stdout);
if (code == TSDB_SRV_STATUS_NETWORK_OK && shell.args.is_startup) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册