diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index e1f86bae58ec09600792c89f567850cf50470fa9..cec6f1a6919ab66ad3928254d47a0943f60936b5 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -276,6 +276,7 @@ typedef struct SSelectStmt { bool hasLastRowFunc; bool hasTimeLineFunc; bool hasUdaf; + bool hasStateKey; bool onlyHasKeepOrderFunc; bool groupSort; } SSelectStmt; diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index b683723575eb5f103a244192bdc03e208704c5e2..2781fee9565c278db6f9173ba596fbbc6abaf9c8 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -408,6 +408,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); code = metaGetTableTags(metaHandle, suid, uidList, tags); if (code != TSDB_CODE_SUCCESS) { + qError("failed to get table tags from meta, reason:%s, suid:%" PRIu64, tstrerror(code), suid); terrno = code; goto end; } @@ -482,11 +483,13 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)}; code = createResultData(&type, rows, &output); if (code != TSDB_CODE_SUCCESS) { + qError("failed to create result, reason:%s", tstrerror(code)); goto end; } code = scalarCalculate(pTagCond, pBlockList, &output); if(code != TSDB_CODE_SUCCESS){ + qError("failed to calculate scalar, reason:%s", tstrerror(code)); terrno = code; } // int64_t st2 = taosGetTimestampUs(); diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 0922cdb6b9cdee6e5d2d1f6f315d84a8bafacc70..de9f8156187514fe27020beec1e641e132d3cfff 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -681,6 +681,11 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo* break; } + char tmpTokenBuf[TSDB_COL_NAME_LEN + 2] = {0}; // used for deleting Escape character backstick(`) + strncpy(tmpTokenBuf, sToken.z, sToken.n); + sToken.z = tmpTokenBuf; + sToken.n = strdequote(sToken.z); + col_id_t t = lastColIdx + 1; col_id_t index = findCol(&sToken, t, nCols, pSchema); if (index < 0 && t > 0) { diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 3c0d9a5f63bbf008469618589c206bc9eb9f447c..09847feb4db8842a908a536b404371a76a0858eb 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1881,6 +1881,12 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { return rewriteExprToGroupKeyFunc(pCxt, pNode); } } + if (NULL != pSelect->pWindow && QUERY_NODE_STATE_WINDOW == nodeType(pSelect->pWindow)) { + if (nodesEqualNode(((SStateWindowNode*)pSelect->pWindow)->pExpr, *pNode)) { + pSelect->hasStateKey = true; + return rewriteExprToGroupKeyFunc(pCxt, pNode); + } + } if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc) { return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt)); @@ -1973,7 +1979,7 @@ static int32_t checkWindowFuncCoexist(STranslateContext* pCxt, SSelectStmt* pSel if (NULL == pSelect->pWindow) { return TSDB_CODE_SUCCESS; } - if (NULL != pSelect->pWindow && !pSelect->hasAggFuncs) { + if (NULL != pSelect->pWindow && !pSelect->hasAggFuncs && !pSelect->hasStateKey) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN); } return TSDB_CODE_SUCCESS; @@ -2825,7 +2831,7 @@ static int32_t createDefaultFillNode(STranslateContext* pCxt, SNode** pOutput) { static int32_t checkEvery(STranslateContext* pCxt, SValueNode* pInterval) { int32_t len = strlen(pInterval->literal); - char *unit = &pInterval->literal[len - 1]; + char* unit = &pInterval->literal[len - 1]; if (*unit == 'n' || *unit == 'y') { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Unsupported time unit in EVERY clause"); @@ -2837,7 +2843,7 @@ static int32_t checkEvery(STranslateContext* pCxt, SValueNode* pInterval) { static int32_t translateInterpEvery(STranslateContext* pCxt, SNode** pEvery) { int32_t code = TSDB_CODE_SUCCESS; - code = checkEvery(pCxt, (SValueNode *)(*pEvery)); + code = checkEvery(pCxt, (SValueNode*)(*pEvery)); if (TSDB_CODE_SUCCESS == code) { code = translateExpr(pCxt, pEvery); }