Merge branch '3.0' of https://github.com/taosdata/TDengine into 3.0
This commit is contained in:
commit
26fb2ee2b8
|
@ -496,6 +496,11 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
pInst->onlineDnodes = pInst->totalDnodes ? 0 : -1;
|
pInst->onlineDnodes = pInst->totalDnodes ? 0 : -1;
|
||||||
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), pInst->onlineDnodes, pInst->totalDnodes);
|
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), pInst->onlineDnodes, pInst->totalDnodes);
|
||||||
|
taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
|
taosMemoryFree(pMsg->pEpSet);
|
||||||
|
tFreeClientHbBatchRsp(&pRsp);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspNum) {
|
if (rspNum) {
|
||||||
|
|
|
@ -822,7 +822,7 @@ _OVER:
|
||||||
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
|
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
|
||||||
"role:%s, redirect numOfEps:%d inUse:%d, type:%s",
|
"role:%s, redirect numOfEps:%d inUse:%d, type:%s",
|
||||||
pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, state.restored,
|
pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, state.restored,
|
||||||
syncStr(state.restored), epSet.numOfEps, epSet.inUse, TMSG_INFO(pMsg->msgType));
|
syncStr(state.state), epSet.numOfEps, epSet.inUse, TMSG_INFO(pMsg->msgType));
|
||||||
|
|
||||||
if (epSet.numOfEps <= 0) return -1;
|
if (epSet.numOfEps <= 0) return -1;
|
||||||
|
|
||||||
|
|
|
@ -923,13 +923,14 @@ int32_t handleStep2Async(SStreamTask* pStreamTask, void* param) {
|
||||||
STaskId hId = pStreamTask->hTaskInfo.id;
|
STaskId hId = pStreamTask->hTaskInfo.id;
|
||||||
SStreamTask* pTask = streamMetaAcquireTask(pStreamTask->pMeta, hId.streamId, hId.taskId);
|
SStreamTask* pTask = streamMetaAcquireTask(pStreamTask->pMeta, hId.streamId, hId.taskId);
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
// todo handle error
|
tqWarn("s-task:0x%x failed to acquired it to exec step 2, scan wal quit", (int32_t) hId.taskId);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
doStartFillhistoryStep2(pTask, pStreamTask, pTq);
|
doStartFillhistoryStep2(pTask, pStreamTask, pTq);
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
return 0;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function should be executed by only one thread, so we set an sentinel to protect this function
|
// this function should be executed by only one thread, so we set an sentinel to protect this function
|
||||||
|
|
|
@ -2136,6 +2136,9 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle*
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
||||||
|
if (numOfTables == 1 && pTableListInfo->idInfo.tableType == TSDB_CHILD_TABLE) {
|
||||||
|
pTableListInfo->oneTableForEachGroup = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (groupSort && groupByTbname) {
|
if (groupSort && groupByTbname) {
|
||||||
taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn);
|
taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn);
|
||||||
|
|
|
@ -894,6 +894,7 @@ static SSDataBlock* doGroupedTableScan(SOperatorInfo* pOperator) {
|
||||||
pTableScanInfo->countState = TABLE_COUNT_STATE_PROCESSED;
|
pTableScanInfo->countState = TABLE_COUNT_STATE_PROCESSED;
|
||||||
STableKeyInfo* pStart =
|
STableKeyInfo* pStart =
|
||||||
(STableKeyInfo*)tableListGetInfo(pTableScanInfo->base.pTableListInfo, pTableScanInfo->tableStartIndex);
|
(STableKeyInfo*)tableListGetInfo(pTableScanInfo->base.pTableListInfo, pTableScanInfo->tableStartIndex);
|
||||||
|
if (NULL == pStart) return NULL;
|
||||||
return getBlockForEmptyTable(pOperator, pStart);
|
return getBlockForEmptyTable(pOperator, pStart);
|
||||||
}
|
}
|
||||||
} else { // group by tag + no sort
|
} else { // group by tag + no sort
|
||||||
|
|
|
@ -2017,9 +2017,17 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
if (IS_STR_DATA_TYPE(para2Type)) {
|
if (IS_STR_DATA_TYPE(para2Type)) {
|
||||||
para2Bytes -= VARSTR_HEADER_SIZE;
|
para2Bytes -= VARSTR_HEADER_SIZE;
|
||||||
}
|
}
|
||||||
if (para2Bytes <= 0 || para2Bytes > 4096) { // cast dst var type length limits to 4096 bytes
|
if (para2Bytes <= 0 ||
|
||||||
|
para2Bytes > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) { // cast dst var type length limits to 4096 bytes
|
||||||
|
if (TSDB_DATA_TYPE_NCHAR == para2Type) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"CAST function converted length should be in range (0, 4096] bytes");
|
"CAST function converted length should be in range (0, %d] NCHARS",
|
||||||
|
(TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE);
|
||||||
|
} else {
|
||||||
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
|
"CAST function converted length should be in range (0, %d] bytes",
|
||||||
|
TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add database precision as param
|
// add database precision as param
|
||||||
|
|
|
@ -415,6 +415,13 @@ type_name(A) ::= DECIMAL.
|
||||||
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
||||||
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
||||||
|
|
||||||
|
%type type_name_default_len { SDataType }
|
||||||
|
%destructor type_name_default_len { }
|
||||||
|
type_name_default_len(A) ::= BINARY. { A = createVarLenDataType(TSDB_DATA_TYPE_BINARY, NULL); }
|
||||||
|
type_name_default_len(A) ::= NCHAR. { A = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, NULL); }
|
||||||
|
type_name_default_len(A) ::= VARCHAR. { A = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, NULL); }
|
||||||
|
type_name_default_len(A) ::= VARBINARY. { A = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, NULL); }
|
||||||
|
|
||||||
%type tags_def_opt { SNodeList* }
|
%type tags_def_opt { SNodeList* }
|
||||||
%destructor tags_def_opt { nodesDestroyList($$); }
|
%destructor tags_def_opt { nodesDestroyList($$); }
|
||||||
tags_def_opt(A) ::= . { A = NULL; }
|
tags_def_opt(A) ::= . { A = NULL; }
|
||||||
|
@ -1111,6 +1118,9 @@ function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D).
|
||||||
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||||
function_expression(A) ::=
|
function_expression(A) ::=
|
||||||
CAST(B) NK_LP expr_or_subquery(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
CAST(B) NK_LP expr_or_subquery(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||||
|
function_expression(A) ::=
|
||||||
|
CAST(B) NK_LP expr_or_subquery(C) AS type_name_default_len(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||||
|
|
||||||
function_expression(A) ::= literal_func(B). { A = B; }
|
function_expression(A) ::= literal_func(B). { A = B; }
|
||||||
|
|
||||||
literal_func(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); }
|
literal_func(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
|
|
|
@ -1601,7 +1601,10 @@ SDataType createDataType(uint8_t type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
||||||
SDataType dt = {.type = type, .precision = 0, .scale = 0, .bytes = taosStr2Int32(pLen->z, NULL, 10)};
|
int32_t len = TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE;
|
||||||
|
if (type == TSDB_DATA_TYPE_NCHAR) len /= TSDB_NCHAR_SIZE;
|
||||||
|
if(pLen) len = taosStr2Int32(pLen->z, NULL, 10);
|
||||||
|
SDataType dt = {.type = type, .precision = 0, .scale = 0, .bytes = len};
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1572,11 +1572,13 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
|
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
char* pUcs4 = taosMemoryCalloc(1, pSchema->bytes - VARSTR_HEADER_SIZE);
|
int64_t realLen = pToken->n << 2;
|
||||||
|
if (realLen > pSchema->bytes - VARSTR_HEADER_SIZE) realLen = pSchema->bytes - VARSTR_HEADER_SIZE;
|
||||||
|
char* pUcs4 = taosMemoryMalloc(realLen);
|
||||||
if (NULL == pUcs4) {
|
if (NULL == pUcs4) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
if (!taosMbsToUcs4(pToken->z, pToken->n, (TdUcs4*)pUcs4, pSchema->bytes - VARSTR_HEADER_SIZE, &len)) {
|
if (!taosMbsToUcs4(pToken->z, pToken->n, (TdUcs4*)pUcs4, realLen, &len)) {
|
||||||
taosMemoryFree(pUcs4);
|
taosMemoryFree(pUcs4);
|
||||||
if (errno == E2BIG) {
|
if (errno == E2BIG) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
|
return generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
|
||||||
|
|
|
@ -2105,7 +2105,6 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu
|
||||||
}
|
}
|
||||||
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias && !pFunc->node.asParam) {
|
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias && !pFunc->node.asParam) {
|
||||||
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
|
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
|
||||||
strcpy(pFunc->node.aliasName, pFunc->node.userAlias);
|
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2697,6 +2696,29 @@ static EDealRes rewriteExprToGroupKeyFunc(STranslateContext* pCxt, SNode** pNode
|
||||||
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isTbnameFuction(SNode* pNode) {
|
||||||
|
return QUERY_NODE_FUNCTION == nodeType(pNode) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pNode)->funcType;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool hasTbnameFunction(SNodeList* pPartitionByList) {
|
||||||
|
SNode* pPartKey = NULL;
|
||||||
|
FOREACH(pPartKey, pPartitionByList) {
|
||||||
|
if (isTbnameFuction(pPartKey)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool fromSubtable(SNode* table) {
|
||||||
|
if (NULL == table) return false;
|
||||||
|
if (table->type == QUERY_NODE_REAL_TABLE && ((SRealTableNode*)table)->pMeta &&
|
||||||
|
((SRealTableNode*)table)->pMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
STranslateContext* pCxt = (STranslateContext*)pContext;
|
STranslateContext* pCxt = (STranslateContext*)pContext;
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
||||||
|
@ -2708,15 +2730,25 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
SNode* pGroupNode = NULL;
|
SNode* pGroupNode = NULL;
|
||||||
FOREACH(pGroupNode, getGroupByList(pCxt)) {
|
FOREACH(pGroupNode, getGroupByList(pCxt)) {
|
||||||
if (nodesEqualNode(getGroupByNode(pGroupNode), *pNode)) {
|
SNode* pActualNode = getGroupByNode(pGroupNode);
|
||||||
|
if (nodesEqualNode(pActualNode, *pNode)) {
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
|
if (isTbnameFuction(pActualNode) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
|
||||||
|
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||||
|
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SNode* pPartKey = NULL;
|
SNode* pPartKey = NULL;
|
||||||
|
bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList);
|
||||||
FOREACH(pPartKey, pSelect->pPartitionByList) {
|
FOREACH(pPartKey, pSelect->pPartitionByList) {
|
||||||
if (nodesEqualNode(pPartKey, *pNode)) {
|
if (nodesEqualNode(pPartKey, *pNode)) {
|
||||||
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
}
|
}
|
||||||
|
if ((partionByTbname) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
|
||||||
|
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||||
|
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (NULL != pSelect->pWindow && QUERY_NODE_STATE_WINDOW == nodeType(pSelect->pWindow)) {
|
if (NULL != pSelect->pWindow && QUERY_NODE_STATE_WINDOW == nodeType(pSelect->pWindow)) {
|
||||||
if (nodesEqualNode(((SStateWindowNode*)pSelect->pWindow)->pExpr, *pNode)) {
|
if (nodesEqualNode(((SStateWindowNode*)pSelect->pWindow)->pExpr, *pNode)) {
|
||||||
|
@ -2780,11 +2812,19 @@ static EDealRes doCheckAggColCoexist(SNode** pNode, void* pContext) {
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
SNode* pPartKey = NULL;
|
SNode* pPartKey = NULL;
|
||||||
|
bool partionByTbname = false;
|
||||||
|
if (fromSubtable(((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pFromTable) ||
|
||||||
|
hasTbnameFunction(((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList)) {
|
||||||
|
partionByTbname = true;
|
||||||
|
}
|
||||||
FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) {
|
FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) {
|
||||||
if (nodesEqualNode(pPartKey, *pNode)) {
|
if (nodesEqualNode(pPartKey, *pNode)) {
|
||||||
return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode);
|
return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (partionByTbname && QUERY_NODE_COLUMN == nodeType(*pNode) && ((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||||
|
return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode);
|
||||||
|
}
|
||||||
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
pCxt->existCol = true;
|
pCxt->existCol = true;
|
||||||
}
|
}
|
||||||
|
@ -3955,22 +3995,12 @@ static int32_t checkStateExpr(STranslateContext* pCxt, SNode* pNode) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasPartitionByTbname(SNodeList* pPartitionByList) {
|
|
||||||
SNode* pPartKey = NULL;
|
|
||||||
FOREACH(pPartKey, pPartitionByList) {
|
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(pPartKey) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pPartKey)->funcType) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t checkStateWindowForStream(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t checkStateWindowForStream(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (!pCxt->createStream) {
|
if (!pCxt->createStream) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
if (TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
if (TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
||||||
!hasPartitionByTbname(pSelect->pPartitionByList)) {
|
!hasTbnameFunction(pSelect->pPartitionByList)) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query");
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query");
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -7560,12 +7590,12 @@ static int32_t translateKillTransaction(STranslateContext* pCxt, SKillStmt* pStm
|
||||||
static bool crossTableWithoutAggOper(SSelectStmt* pSelect) {
|
static bool crossTableWithoutAggOper(SSelectStmt* pSelect) {
|
||||||
return NULL == pSelect->pWindow && !pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc &&
|
return NULL == pSelect->pWindow && !pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc &&
|
||||||
!pSelect->hasInterpFunc && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
!pSelect->hasInterpFunc && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
||||||
!hasPartitionByTbname(pSelect->pPartitionByList);
|
!hasTbnameFunction(pSelect->pPartitionByList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool crossTableWithUdaf(SSelectStmt* pSelect) {
|
static bool crossTableWithUdaf(SSelectStmt* pSelect) {
|
||||||
return pSelect->hasUdaf && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
return pSelect->hasUdaf && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
||||||
!hasPartitionByTbname(pSelect->pPartitionByList);
|
!hasTbnameFunction(pSelect->pPartitionByList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) {
|
static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) {
|
||||||
|
@ -7823,7 +7853,7 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
||||||
if ( (SRealTableNode*)pSelect->pFromTable && ((SRealTableNode*)pSelect->pFromTable)->pMeta
|
if ( (SRealTableNode*)pSelect->pFromTable && ((SRealTableNode*)pSelect->pFromTable)->pMeta
|
||||||
&& TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType
|
&& TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType
|
||||||
&& !hasPartitionByTbname(pSelect->pPartitionByList)
|
&& !hasTbnameFunction(pSelect->pPartitionByList)
|
||||||
&& pSelect->pWindow != NULL && pSelect->pWindow->type == QUERY_NODE_EVENT_WINDOW) {
|
&& pSelect->pWindow != NULL && pSelect->pWindow->type == QUERY_NODE_EVENT_WINDOW) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
"Event window for stream on super table must patitioned by table name");
|
"Event window for stream on super table must patitioned by table name");
|
||||||
|
@ -7851,7 +7881,7 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
|
||||||
if (pSelect->pWindow != NULL && pSelect->pWindow->type == QUERY_NODE_COUNT_WINDOW) {
|
if (pSelect->pWindow != NULL && pSelect->pWindow->type == QUERY_NODE_COUNT_WINDOW) {
|
||||||
if ( (SRealTableNode*)pSelect->pFromTable && ((SRealTableNode*)pSelect->pFromTable)->pMeta
|
if ( (SRealTableNode*)pSelect->pFromTable && ((SRealTableNode*)pSelect->pFromTable)->pMeta
|
||||||
&& TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType
|
&& TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType
|
||||||
&& !hasPartitionByTbname(pSelect->pPartitionByList) ) {
|
&& !hasTbnameFunction(pSelect->pPartitionByList) ) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
"Count window for stream on super table must patitioned by table name");
|
"Count window for stream on super table must patitioned by table name");
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -494,6 +494,9 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
} else if (pSelect->pPartitionByList) {
|
} else if (pSelect->pPartitionByList) {
|
||||||
isCountByTag = !keysHasCol(pSelect->pPartitionByList);
|
isCountByTag = !keysHasCol(pSelect->pPartitionByList);
|
||||||
}
|
}
|
||||||
|
if (pScan->tableType == TSDB_CHILD_TABLE) {
|
||||||
|
isCountByTag = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pScan->isCountByTag = isCountByTag;
|
pScan->isCountByTag = isCountByTag;
|
||||||
|
|
||||||
|
|
|
@ -276,16 +276,18 @@ int32_t syncForceBecomeFollower(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
||||||
|
|
||||||
int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
||||||
int32_t ret = -1;
|
int32_t ret = -1;
|
||||||
|
int32_t errcode = TSDB_CODE_MND_ARB_TOKEN_MISMATCH;
|
||||||
|
void* pHead = NULL;
|
||||||
|
int32_t contLen = 0;
|
||||||
|
|
||||||
SVArbSetAssignedLeaderReq req = {0};
|
SVArbSetAssignedLeaderReq req = {0};
|
||||||
if (tDeserializeSVArbSetAssignedLeaderReq((char*)pRpcMsg->pCont + sizeof(SMsgHead), pRpcMsg->contLen, &req) != 0) {
|
if (tDeserializeSVArbSetAssignedLeaderReq((char*)pRpcMsg->pCont + sizeof(SMsgHead), pRpcMsg->contLen, &req) != 0) {
|
||||||
sError("vgId:%d, failed to deserialize SVArbSetAssignedLeaderReq", ths->vgId);
|
sError("vgId:%d, failed to deserialize SVArbSetAssignedLeaderReq", ths->vgId);
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
errcode = terrno;
|
||||||
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t errcode = TSDB_CODE_MND_ARB_TOKEN_MISMATCH;
|
|
||||||
|
|
||||||
if (ths->arbTerm > req.arbTerm) {
|
if (ths->arbTerm > req.arbTerm) {
|
||||||
sInfo("vgId:%d, skip to set assigned leader, msg with lower term, local:%" PRId64 "msg:%" PRId64, ths->vgId,
|
sInfo("vgId:%d, skip to set assigned leader, msg with lower term, local:%" PRId64 "msg:%" PRId64, ths->vgId,
|
||||||
ths->arbTerm, req.arbTerm);
|
ths->arbTerm, req.arbTerm);
|
||||||
|
@ -294,11 +296,18 @@ int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
||||||
|
|
||||||
ths->arbTerm = TMAX(req.arbTerm, ths->arbTerm);
|
ths->arbTerm = TMAX(req.arbTerm, ths->arbTerm);
|
||||||
|
|
||||||
if (strncmp(req.memberToken, ths->arbToken, TSDB_ARB_TOKEN_SIZE) == 0) {
|
if (strncmp(req.memberToken, ths->arbToken, TSDB_ARB_TOKEN_SIZE) != 0) {
|
||||||
|
sInfo("vgId:%d, skip to set assigned leader, token mismatch, local:%s, msg:%s", ths->vgId, ths->arbToken,
|
||||||
|
req.memberToken);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (ths->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) {
|
if (ths->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) {
|
||||||
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
raftStoreNextTerm(ths);
|
raftStoreNextTerm(ths);
|
||||||
if (terrno != TSDB_CODE_SUCCESS) {
|
if (terrno != TSDB_CODE_SUCCESS) {
|
||||||
sError("vgId:%d, failed to set next term since:%s", ths->vgId, terrstr());
|
sError("vgId:%d, failed to set next term since:%s", ths->vgId, terrstr());
|
||||||
|
errcode = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
syncNodeBecomeAssignedLeader(ths);
|
syncNodeBecomeAssignedLeader(ths);
|
||||||
|
@ -307,37 +316,38 @@ int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
||||||
sError("vgId:%d, assigned leader failed to append noop entry since %s", ths->vgId, terrstr());
|
sError("vgId:%d, assigned leader failed to append noop entry since %s", ths->vgId, terrstr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
errcode = TSDB_CODE_SUCCESS;
|
|
||||||
} else {
|
|
||||||
sInfo("vgId:%d, skip to set assigned leader, token mismatch, local:%s, msg:%s", ths->vgId, ths->arbToken,
|
|
||||||
req.memberToken);
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
SVArbSetAssignedLeaderRsp rsp = {0};
|
SVArbSetAssignedLeaderRsp rsp = {0};
|
||||||
rsp.arbToken = req.arbToken;
|
rsp.arbToken = req.arbToken;
|
||||||
rsp.memberToken = req.memberToken;
|
rsp.memberToken = req.memberToken;
|
||||||
rsp.vgId = ths->vgId;
|
rsp.vgId = ths->vgId;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSVArbSetAssignedLeaderRsp(NULL, 0, &rsp);
|
contLen = tSerializeSVArbSetAssignedLeaderRsp(NULL, 0, &rsp);
|
||||||
if (contLen <= 0) {
|
if (contLen <= 0) {
|
||||||
sError("vgId:%d, failed to serialize SVArbSetAssignedLeaderRsp", ths->vgId);
|
sError("vgId:%d, failed to serialize SVArbSetAssignedLeaderRsp", ths->vgId);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
errcode = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
void* pHead = rpcMallocCont(contLen);
|
pHead = rpcMallocCont(contLen);
|
||||||
if (!pHead) {
|
if (!pHead) {
|
||||||
sError("vgId:%d, failed to malloc memory for SVArbSetAssignedLeaderRsp", ths->vgId);
|
sError("vgId:%d, failed to malloc memory for SVArbSetAssignedLeaderRsp", ths->vgId);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
errcode = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (tSerializeSVArbSetAssignedLeaderRsp(pHead, contLen, &rsp) <= 0) {
|
if (tSerializeSVArbSetAssignedLeaderRsp(pHead, contLen, &rsp) <= 0) {
|
||||||
sError("vgId:%d, failed to serialize SVArbSetAssignedLeaderRsp", ths->vgId);
|
sError("vgId:%d, failed to serialize SVArbSetAssignedLeaderRsp", ths->vgId);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
errcode = terrno;
|
||||||
rpcFreeCont(pHead);
|
rpcFreeCont(pHead);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errcode = TSDB_CODE_SUCCESS;
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
_OVER:;
|
||||||
SRpcMsg rspMsg = {
|
SRpcMsg rspMsg = {
|
||||||
.code = errcode,
|
.code = errcode,
|
||||||
.pCont = pHead,
|
.pCont = pHead,
|
||||||
|
@ -347,9 +357,6 @@ int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
||||||
|
|
||||||
tmsgSendRsp(&rspMsg);
|
tmsgSendRsp(&rspMsg);
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
_OVER:
|
|
||||||
tFreeSVArbSetAssignedLeaderReq(&req);
|
tFreeSVArbSetAssignedLeaderReq(&req);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,6 +242,7 @@ void taosCloseLog() {
|
||||||
taosMemoryFreeClear(tsLogObj.logHandle->buffer);
|
taosMemoryFreeClear(tsLogObj.logHandle->buffer);
|
||||||
taosThreadMutexDestroy(&tsLogObj.logMutex);
|
taosThreadMutexDestroy(&tsLogObj.logMutex);
|
||||||
taosMemoryFreeClear(tsLogObj.logHandle);
|
taosMemoryFreeClear(tsLogObj.logHandle);
|
||||||
|
tsLogObj.logHandle = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,8 +286,11 @@ static void taosKeepOldLog(char *oldName) {
|
||||||
taosRemoveOldFiles(tsLogDir, tsLogKeepDays);
|
taosRemoveOldFiles(tsLogDir, tsLogKeepDays);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
typedef struct {
|
||||||
static void *taosThreadToOpenNewFile(void *param) {
|
TdFilePtr pOldFile;
|
||||||
|
char keepName[LOG_FILE_NAME_LEN + 20];
|
||||||
|
} OldFileKeeper;
|
||||||
|
static OldFileKeeper *taosOpenNewFile() {
|
||||||
char keepName[LOG_FILE_NAME_LEN + 20];
|
char keepName[LOG_FILE_NAME_LEN + 20];
|
||||||
sprintf(keepName, "%s.%d", tsLogObj.logName, tsLogObj.flag);
|
sprintf(keepName, "%s.%d", tsLogObj.logName, tsLogObj.flag);
|
||||||
|
|
||||||
|
@ -312,13 +316,26 @@ static void *taosThreadToOpenNewFile(void *param) {
|
||||||
tsLogObj.logHandle->pFile = pFile;
|
tsLogObj.logHandle->pFile = pFile;
|
||||||
tsLogObj.lines = 0;
|
tsLogObj.lines = 0;
|
||||||
tsLogObj.openInProgress = 0;
|
tsLogObj.openInProgress = 0;
|
||||||
taosSsleep(20);
|
OldFileKeeper* oldFileKeeper = taosMemoryMalloc(sizeof(OldFileKeeper));
|
||||||
taosCloseLogByFd(pOldFile);
|
if (oldFileKeeper == NULL) {
|
||||||
|
uError("create old log keep info faild! mem is not enough.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
oldFileKeeper->pOldFile = pOldFile;
|
||||||
|
memcpy(oldFileKeeper->keepName, keepName, LOG_FILE_NAME_LEN + 20);
|
||||||
|
|
||||||
uInfo(" new log file:%d is opened", tsLogObj.flag);
|
uInfo(" new log file:%d is opened", tsLogObj.flag);
|
||||||
uInfo("==================================");
|
uInfo("==================================");
|
||||||
taosKeepOldLog(keepName);
|
return oldFileKeeper;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *taosThreadToCloseOldFile(void* param) {
|
||||||
|
if(!param) return NULL;
|
||||||
|
OldFileKeeper* oldFileKeeper = (OldFileKeeper*)param;
|
||||||
|
taosSsleep(20);
|
||||||
|
taosCloseLogByFd(oldFileKeeper->pOldFile);
|
||||||
|
taosKeepOldLog(oldFileKeeper->keepName);
|
||||||
|
taosMemoryFree(oldFileKeeper);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +351,8 @@ static int32_t taosOpenNewLogFile() {
|
||||||
taosThreadAttrInit(&attr);
|
taosThreadAttrInit(&attr);
|
||||||
taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED);
|
taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
|
||||||
taosThreadCreate(&thread, &attr, taosThreadToOpenNewFile, NULL);
|
OldFileKeeper* oldFileKeeper = taosOpenNewFile();
|
||||||
|
taosThreadCreate(&thread, &attr, taosThreadToCloseOldFile, oldFileKeeper);
|
||||||
taosThreadAttrDestroy(&attr);
|
taosThreadAttrDestroy(&attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,10 +365,11 @@ void taosResetLog() {
|
||||||
// force create a new log file
|
// force create a new log file
|
||||||
tsLogObj.lines = tsNumOfLogLines + 10;
|
tsLogObj.lines = tsNumOfLogLines + 10;
|
||||||
|
|
||||||
|
if (tsLogObj.logHandle) {
|
||||||
taosOpenNewLogFile();
|
taosOpenNewLogFile();
|
||||||
|
|
||||||
uInfo("==================================");
|
uInfo("==================================");
|
||||||
uInfo(" reset log file ");
|
uInfo(" reset log file ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool taosCheckFileIsOpen(char *logFileName) {
|
static bool taosCheckFileIsOpen(char *logFileName) {
|
||||||
|
|
|
@ -66,10 +66,10 @@ class TDTestCase:
|
||||||
tdSql.query('select * from (select tbname, avg(f) from st partition by tbname) a partition by a.tbname order by a.tbname');
|
tdSql.query('select * from (select tbname, avg(f) from st partition by tbname) a partition by a.tbname order by a.tbname');
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkCols(2)
|
tdSql.checkCols(2)
|
||||||
tdSql.checkData(0, 0, 'ct1');
|
tdSql.checkData(0, 0, 'ct1')
|
||||||
tdSql.checkData(0, 1, 6.0);
|
tdSql.checkData(0, 1, 6.0)
|
||||||
tdSql.checkData(1, 0, 'ct2');
|
tdSql.checkData(1, 0, 'ct2')
|
||||||
tdSql.checkData(1, 1, 12.0);
|
tdSql.checkData(1, 1, 12.0)
|
||||||
|
|
||||||
tdSql.error('select tbname from (select * from st)')
|
tdSql.error('select tbname from (select * from st)')
|
||||||
tdSql.error('select st.tbname from (select st.tbname from st)')
|
tdSql.error('select st.tbname from (select st.tbname from st)')
|
||||||
|
|
|
@ -870,7 +870,7 @@ sql_error select stddev(c2), tbname from select_tags_mt0;
|
||||||
sql_error select twa(c2), tbname from select_tags_mt0;
|
sql_error select twa(c2), tbname from select_tags_mt0;
|
||||||
sql_error select interp(c2), tbname from select_tags_mt0 where ts=100001;
|
sql_error select interp(c2), tbname from select_tags_mt0 where ts=100001;
|
||||||
|
|
||||||
sql_error select t1,t2,tbname from select_tags_mt0 group by tbname;
|
|
||||||
sql select count(tbname) from select_tags_mt0 interval(1d);
|
sql select count(tbname) from select_tags_mt0 interval(1d);
|
||||||
sql select count(tbname) from select_tags_mt0 group by t1;
|
sql select count(tbname) from select_tags_mt0 group by t1;
|
||||||
sql select count(tbname),SUM(T1) from select_tags_mt0 interval(1d);
|
sql select count(tbname),SUM(T1) from select_tags_mt0 interval(1d);
|
||||||
|
@ -888,16 +888,16 @@ sql_error select tbname, t1 from select_tags_mt0 interval(1y);
|
||||||
print ==================================>TD-4231
|
print ==================================>TD-4231
|
||||||
sql select t1,tbname from select_tags_mt0 where c1<0
|
sql select t1,tbname from select_tags_mt0 where c1<0
|
||||||
sql select t1,tbname from select_tags_mt0 where c1<0 and tbname in ('select_tags_tb12')
|
sql select t1,tbname from select_tags_mt0 where c1<0 and tbname in ('select_tags_tb12')
|
||||||
|
|
||||||
sql select tbname from select_tags_mt0 where tbname in ('select_tags_tb12');
|
sql select tbname from select_tags_mt0 where tbname in ('select_tags_tb12');
|
||||||
|
|
||||||
sql_error select first(c1), last(c2), t1 from select_tags_mt0 group by tbname;
|
sql select first(ts), tbname from select_tags_mt0 group by tbname;
|
||||||
sql_error select first(c1), last(c2), tbname, t2 from select_tags_mt0 group by tbname;
|
sql select count(c1) from select_tags_mt0 where c1=99 group by tbname;
|
||||||
sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group by tbname;
|
sql select count(*),tbname from select_tags_mt0 group by tbname
|
||||||
#valid sql: select first(c1), t2 from select_tags_mt0 group by tbname;
|
|
||||||
|
|
||||||
#sql select first(ts), tbname from select_tags_mt0 group by tbname;
|
print ==================================> tag supported in group
|
||||||
#sql select count(c1) from select_tags_mt0 where c1=99 group by tbname;
|
sql select t1,t2,tbname from select_tags_mt0 group by tbname;
|
||||||
#sql select count(*),tbname from select_tags_mt0 group by tbname
|
sql select first(c1), last(c2), t1 from select_tags_mt0 group by tbname;
|
||||||
|
sql select first(c1), last(c2), tbname, t2 from select_tags_mt0 group by tbname;
|
||||||
|
sql select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group by tbname;
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
|
@ -3,13 +3,22 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
sql create database test;
|
sql create database test KEEP 36500;
|
||||||
sql use test;
|
sql use test;
|
||||||
sql create table st(ts timestamp, f int) tags(t int);
|
sql create table st(ts timestamp, f int) tags(t int);
|
||||||
sql insert into ct1 using st tags(1) values(now, 0)(now+1s, 1)(now+2s, 10)(now+3s, 11)
|
|
||||||
sql insert into ct2 using st tags(2) values(now+2s, 2)(now+3s, 3)
|
$ms = 1712135244502
|
||||||
sql insert into ct3 using st tags(3) values(now+4s, 4)(now+5s, 5)
|
$ms1 = $ms + 1000
|
||||||
sql insert into ct4 using st tags(4) values(now+6s, 6)(now+7s, 7)
|
$ms2 = $ms + 2000
|
||||||
|
$ms3 = $ms + 3000
|
||||||
|
$ms4 = $ms + 4000
|
||||||
|
$ms5 = $ms + 5000
|
||||||
|
$ms6 = $ms + 6000
|
||||||
|
$ms7 = $ms + 7000
|
||||||
|
sql insert into ct1 using st tags(1) values($ms , 0)($ms1 , 1)($ms2 , 10)($ms3 , 11)
|
||||||
|
sql insert into ct2 using st tags(2) values($ms2 , 2)($ms3 , 3)
|
||||||
|
sql insert into ct3 using st tags(3) values($ms4 , 4)($ms5 , 5)
|
||||||
|
sql insert into ct4 using st tags(4) values($ms6 , 6)($ms7 , 7)
|
||||||
|
|
||||||
sql select count(*), spread(ts) from st where tbname='ct1'
|
sql select count(*), spread(ts) from st where tbname='ct1'
|
||||||
print $data00, $data01
|
print $data00, $data01
|
||||||
|
|
|
@ -80,6 +80,10 @@ class TDTestCase:
|
||||||
for i in range(len(data_t1_c1)):
|
for i in range(len(data_t1_c1)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c1[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c1[i]) )
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(c1 as binary) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c1)):
|
||||||
|
tdSql.checkData( i, 0, str(data_t1_c1[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step6: cast int to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step6: cast int to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query(f"select cast(c1 as nchar(32)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(c1 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
|
@ -131,6 +135,13 @@ class TDTestCase:
|
||||||
for i in range(len(data_t1_c2)):
|
for i in range(len(data_t1_c2)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c2[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c2[i]) )
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(c2 as binary) as b from {self.dbname}.ct4")
|
||||||
|
for i in range(len(data_ct4_c2)):
|
||||||
|
tdSql.checkData( i, 0, str(data_ct4_c2[i]) )
|
||||||
|
tdSql.query(f"select cast(c2 as binary) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c2)):
|
||||||
|
tdSql.checkData( i, 0, str(data_t1_c2[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step10: cast bigint to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step10: cast bigint to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query(f"select cast(c2 as nchar(32)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(c2 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
|
@ -185,6 +196,13 @@ class TDTestCase:
|
||||||
for i in range(len(data_t1_c3)):
|
for i in range(len(data_t1_c3)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c3[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c3[i]) )
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(c3 as binary) as b from {self.dbname}.ct4")
|
||||||
|
for i in range(len(data_ct4_c3)):
|
||||||
|
tdSql.checkData( i, 0, str(data_ct4_c3[i]) )
|
||||||
|
tdSql.query(f"select cast(c3 as binary) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c3)):
|
||||||
|
tdSql.checkData( i, 0, str(data_t1_c3[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step14: cast smallint to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step14: cast smallint to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query(f"select cast(c3 as nchar(32)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(c3 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
|
@ -236,6 +254,13 @@ class TDTestCase:
|
||||||
for i in range(len(data_t1_c4)):
|
for i in range(len(data_t1_c4)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c4[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c4[i]) )
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(c4 as binary) as b from {self.dbname}.ct4")
|
||||||
|
for i in range(len(data_ct4_c4)):
|
||||||
|
tdSql.checkData( i, 0, str(data_ct4_c4[i]) )
|
||||||
|
tdSql.query(f"select cast(c4 as binary) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c4)):
|
||||||
|
tdSql.checkData( i, 0, str(data_t1_c4[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step18: cast tinyint to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step18: cast tinyint to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query(f"select cast(c4 as nchar(32)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(c4 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
|
@ -282,6 +307,12 @@ class TDTestCase:
|
||||||
for i in range(len(data_ct4_c5)):
|
for i in range(len(data_ct4_c5)):
|
||||||
tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
||||||
tdSql.query(f"select cast(c5 as binary(32)) as b from {self.dbname}.t1")
|
tdSql.query(f"select cast(c5 as binary(32)) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c5)):
|
||||||
|
tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
tdSql.query(f"select cast(c5 as binary) as b from {self.dbname}.ct4")
|
||||||
|
for i in range(len(data_ct4_c5)):
|
||||||
|
tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
||||||
|
tdSql.query(f"select cast(c5 as binary) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c5)):
|
for i in range(len(data_t1_c5)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
|
||||||
|
@ -290,6 +321,12 @@ class TDTestCase:
|
||||||
for i in range(len(data_ct4_c5)):
|
for i in range(len(data_ct4_c5)):
|
||||||
tdSql.checkData( i, 0, None ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, None ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
||||||
tdSql.query(f"select cast(c5 as nchar(32)) as b from {self.dbname}.t1")
|
tdSql.query(f"select cast(c5 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c5)):
|
||||||
|
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
tdSql.query(f"select cast(c5 as nchar) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c5)):
|
||||||
|
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
tdSql.query(f"select cast(c5 as varchar) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c5)):
|
for i in range(len(data_t1_c5)):
|
||||||
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
|
||||||
|
@ -580,6 +617,10 @@ class TDTestCase:
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as binary(2)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as binary(2)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as binary) as b from {self.dbname}.ct4")
|
||||||
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as binary) as b from {self.dbname}.ct4")
|
||||||
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as nchar(16)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as nchar(16)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as nchar(2)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as nchar(2)) as b from {self.dbname}.ct4")
|
||||||
|
|
|
@ -103,6 +103,10 @@ class TDTestCase:
|
||||||
tdSql.checkRows(row)
|
tdSql.checkRows(row)
|
||||||
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by tbname')
|
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by tbname')
|
||||||
tdSql.checkRows(row)
|
tdSql.checkRows(row)
|
||||||
|
tdSql.query(f'select t0, {function_name}(c1),sum(c1) from {self.stbname} partition by tbname')
|
||||||
|
tdSql.checkRows(row)
|
||||||
|
tdSql.query(f'select cast(t0 as binary(12)), {function_name}(c1),sum(c1) from {self.stbname} partition by tbname')
|
||||||
|
tdSql.checkRows(row)
|
||||||
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by c1')
|
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by c1')
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by t0')
|
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by t0')
|
||||||
|
|
|
@ -470,7 +470,9 @@ class TDTestCase:
|
||||||
tdSql.checkRows(40)
|
tdSql.checkRows(40)
|
||||||
|
|
||||||
# bug need fix
|
# bug need fix
|
||||||
tdSql.query("select tbname , csum(c1), csum(c12) from db.stb1 partition by tbname")
|
tdSql.query("select tbname , st1, csum(c1), csum(c12) from db.stb1 partition by tbname")
|
||||||
|
tdSql.checkRows(40)
|
||||||
|
tdSql.query("select tbname , cast(st1 as binary(24)), csum(c1), csum(c12) from db.stb1 partition by tbname")
|
||||||
tdSql.checkRows(40)
|
tdSql.checkRows(40)
|
||||||
tdSql.query("select tbname , csum(st1) from db.stb1 partition by tbname")
|
tdSql.query("select tbname , csum(st1) from db.stb1 partition by tbname")
|
||||||
tdSql.checkRows(70)
|
tdSql.checkRows(70)
|
||||||
|
|
|
@ -91,15 +91,71 @@ class TDTestCase:
|
||||||
tdSql.query(f"select t2, t3, c1, count(*) from {self.dbname}.{self.stable} {keyword} by t2, t3, c1 ")
|
tdSql.query(f"select t2, t3, c1, count(*) from {self.dbname}.{self.stable} {keyword} by t2, t3, c1 ")
|
||||||
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
|
||||||
|
def test_groupby_sub_table(self):
|
||||||
|
for i in range(self.tb_nums):
|
||||||
|
tbname = f"{self.dbname}.sub_{self.stable}_{i}"
|
||||||
|
ts = self.ts + i*10000
|
||||||
|
tdSql.query(f"select t1, t2, t3,count(*) from {tbname}")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 1, i)
|
||||||
|
tdSql.checkData(0, 2, i*10)
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(t2 as binary(12)),count(*) from {tbname}")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, i)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2 + 1, count(*) from {tbname}")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, i + 1)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1, t2, t3, count(*) from {tbname} group by tbname")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 1, i)
|
||||||
|
tdSql.checkData(0, 2, i*10)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1, t2, t3, count(*) from {tbname} group by tbname, c1, t4")
|
||||||
|
tdSql.checkData(0, 1, i)
|
||||||
|
tdSql.checkData(0, 2, i*10)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1, t2, t3, count(*) from {tbname} partition by tbname")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 1, i)
|
||||||
|
tdSql.checkData(0, 2, i*10)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1, t2, t3, count(*) from {tbname} partition by c1, tbname")
|
||||||
|
tdSql.checkData(0, 1, i)
|
||||||
|
tdSql.checkData(0, 2, i*10)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1, t2, t3, count(*) from {self.dbname}.{self.stable} partition by c1, tbname order by tbname desc")
|
||||||
|
tdSql.checkRows(50)
|
||||||
|
tdSql.checkData(0, 1, 4)
|
||||||
|
tdSql.checkData(0, 2, 40)
|
||||||
|
|
||||||
|
|
||||||
def test_multi_group_key(self, check_num, nonempty_tb_num):
|
def test_multi_group_key(self, check_num, nonempty_tb_num):
|
||||||
# multi tag/tbname
|
# multi tag/tbname
|
||||||
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} group by t2, t3, tbname")
|
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} group by t2, t3, tbname")
|
||||||
tdSql.checkRows(check_num)
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(t2 as binary(12)), count(*) from {self.dbname}.{self.stable} group by t2, t3, tbname")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} partition by t2, t3, tbname")
|
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} partition by t2, t3, tbname")
|
||||||
tdSql.checkRows(check_num)
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} group by tbname order by tbname asc")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
tdSql.checkData(1, 0, 1)
|
||||||
|
tdSql.checkData(2, 1, 20)
|
||||||
|
tdSql.checkData(3, 1, 30)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} partition by tbname order by tbname asc")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
tdSql.checkData(2, 1, 20)
|
||||||
|
tdSql.checkData(3, 1, 30)
|
||||||
|
|
||||||
# multi tag + col
|
# multi tag + col
|
||||||
tdSql.query(f"select t1, t2, c1, count(*) from {self.dbname}.{self.stable} partition by t1, t2, c1 ")
|
tdSql.query(f"select t1, t2, c1, count(*) from {self.dbname}.{self.stable} partition by t1, t2, c1 ")
|
||||||
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
@ -222,12 +278,14 @@ class TDTestCase:
|
||||||
|
|
||||||
self.test_groupby('group', self.tb_nums, nonempty_tb_num)
|
self.test_groupby('group', self.tb_nums, nonempty_tb_num)
|
||||||
self.test_groupby('partition', self.tb_nums, nonempty_tb_num)
|
self.test_groupby('partition', self.tb_nums, nonempty_tb_num)
|
||||||
|
self.test_groupby_sub_table()
|
||||||
self.test_innerSelect(self.tb_nums)
|
self.test_innerSelect(self.tb_nums)
|
||||||
self.test_multi_group_key(self.tb_nums, nonempty_tb_num)
|
self.test_multi_group_key(self.tb_nums, nonempty_tb_num)
|
||||||
self.test_multi_agg(self.tb_nums, nonempty_tb_num)
|
self.test_multi_agg(self.tb_nums, nonempty_tb_num)
|
||||||
self.test_window(nonempty_tb_num)
|
self.test_window(nonempty_tb_num)
|
||||||
self.test_event_window(nonempty_tb_num)
|
self.test_event_window(nonempty_tb_num)
|
||||||
|
|
||||||
|
|
||||||
## test old version before changed
|
## test old version before changed
|
||||||
# self.test_groupby('group', 0, 0)
|
# self.test_groupby('group', 0, 0)
|
||||||
# self.insert_db(5, self.row_nums)
|
# self.insert_db(5, self.row_nums)
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
###################################################################
|
||||||
|
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This file is proprietary and confidential to TAOS Technologies.
|
||||||
|
# No part of this file may be reproduced, stored, transmitted,
|
||||||
|
# disclosed or used in any form or by any means other than as
|
||||||
|
# expressly provided by the written permission from Jianhui Tao
|
||||||
|
#
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
import sys
|
||||||
|
import taos
|
||||||
|
from util.common import *
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.sql import *
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
self.rowNum = 10
|
||||||
|
self.tbnum = 20
|
||||||
|
self.ts = 1537146000000
|
||||||
|
self.binary_str = 'taosdata'
|
||||||
|
self.nchar_str = '涛思数据'
|
||||||
|
|
||||||
|
def first_check_base(self):
|
||||||
|
dbname = "db"
|
||||||
|
tdSql.prepare(dbname)
|
||||||
|
column_dict = {
|
||||||
|
'col1': 'tinyint',
|
||||||
|
'col2': 'smallint',
|
||||||
|
'col3': 'int',
|
||||||
|
'col4': 'bigint',
|
||||||
|
'col5': 'tinyint unsigned',
|
||||||
|
'col6': 'smallint unsigned',
|
||||||
|
'col7': 'int unsigned',
|
||||||
|
'col8': 'bigint unsigned',
|
||||||
|
'col9': 'float',
|
||||||
|
'col10': 'double',
|
||||||
|
'col11': 'bool',
|
||||||
|
'col12': 'binary(20)',
|
||||||
|
'col13': 'nchar(20)'
|
||||||
|
}
|
||||||
|
tdSql.execute(f"alter local \'keepColumnName\' \'1\'")
|
||||||
|
tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
|
||||||
|
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''')
|
||||||
|
tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')")
|
||||||
|
tdSql.execute(f"create table {dbname}.stb_2 using {dbname}.stb tags('beijing')")
|
||||||
|
|
||||||
|
column_list = ['col1','col2','col3','col4','col5','col6','col7','col8','col9','col10','col11','col12','col13']
|
||||||
|
for i in column_list:
|
||||||
|
for j in ['stb_1']:
|
||||||
|
tdSql.query(f"select first({i}) from {dbname}.{j}")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
for n in range(self.rowNum):
|
||||||
|
i = n
|
||||||
|
tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
|
||||||
|
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1))
|
||||||
|
|
||||||
|
for n in range(self.rowNum):
|
||||||
|
i = n + 10
|
||||||
|
tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
|
||||||
|
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1))
|
||||||
|
|
||||||
|
for n in range(self.rowNum):
|
||||||
|
i = n + 100
|
||||||
|
tdSql.execute(f"insert into {dbname}.stb_2 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
|
||||||
|
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1))
|
||||||
|
|
||||||
|
for k, v in column_dict.items():
|
||||||
|
|
||||||
|
if v == 'tinyint' or v == 'smallint' or v == 'int' or v == 'bigint' or v == 'tinyint unsigned' or v == 'smallint unsigned'\
|
||||||
|
or v == 'int unsigned' or v == 'bigint unsigned':
|
||||||
|
tdSql.query(f"select last({k})-first({k}) from {dbname}.stb")
|
||||||
|
tdSql.checkData(0, 0, 109)
|
||||||
|
tdSql.query(f"select first({k})+last({k}) from {dbname}.stb")
|
||||||
|
tdSql.checkData(0, 0, 111)
|
||||||
|
tdSql.query(f"select max({k})-first({k}) from {dbname}.stb")
|
||||||
|
tdSql.checkData(0, 0, 109)
|
||||||
|
tdSql.query(f"select max({k})-min({k}) from {dbname}.stb")
|
||||||
|
tdSql.checkData(0, 0, 109)
|
||||||
|
|
||||||
|
tdSql.query(f"select last({k})-first({k}) from {dbname}.stb_1")
|
||||||
|
tdSql.checkData(0, 0, 19)
|
||||||
|
tdSql.query(f"select first({k})+last({k}) from {dbname}.stb_1")
|
||||||
|
tdSql.checkData(0, 0, 21)
|
||||||
|
tdSql.query(f"select max({k})-first({k}) from {dbname}.stb_1")
|
||||||
|
tdSql.checkData(0, 0, 19)
|
||||||
|
tdSql.query(f"select max({k})-min({k}) from {dbname}.stb_1")
|
||||||
|
tdSql.checkData(0, 0, 19)
|
||||||
|
|
||||||
|
# float,double
|
||||||
|
elif v == 'float' or v == 'double':
|
||||||
|
tdSql.query(f"select first({k})+last({k}) from {dbname}.stb")
|
||||||
|
tdSql.checkData(0, 0, 109.2)
|
||||||
|
tdSql.query(f"select first({k})+last({k}) from {dbname}.stb_1")
|
||||||
|
tdSql.checkData(0, 0, 19.2)
|
||||||
|
# bool
|
||||||
|
elif v == 'bool':
|
||||||
|
continue
|
||||||
|
# binary
|
||||||
|
elif 'binary' in v:
|
||||||
|
continue
|
||||||
|
# nchar
|
||||||
|
elif 'nchar' in v:
|
||||||
|
continue
|
||||||
|
|
||||||
|
#tdSql.execute(f'drop database {dbname}')
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.first_check_base()
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
Loading…
Reference in New Issue