fix: the syntax problem of querying the state value in the state window
This commit is contained in:
parent
1000d40c1f
commit
4cf9bd6ac1
|
@ -276,6 +276,7 @@ typedef struct SSelectStmt {
|
||||||
bool hasLastRowFunc;
|
bool hasLastRowFunc;
|
||||||
bool hasTimeLineFunc;
|
bool hasTimeLineFunc;
|
||||||
bool hasUdaf;
|
bool hasUdaf;
|
||||||
|
bool hasStateKey;
|
||||||
bool onlyHasKeepOrderFunc;
|
bool onlyHasKeepOrderFunc;
|
||||||
bool groupSort;
|
bool groupSort;
|
||||||
} SSelectStmt;
|
} SSelectStmt;
|
||||||
|
|
|
@ -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);
|
tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
code = metaGetTableTags(metaHandle, suid, uidList, tags);
|
code = metaGetTableTags(metaHandle, suid, uidList, tags);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
qError("failed to get table tags from meta, reason:%s, suid:%" PRIu64, tstrerror(code), suid);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -484,11 +485,13 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
|
||||||
SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
|
SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
|
||||||
code = createResultData(&type, rows, &output);
|
code = createResultData(&type, rows, &output);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
qError("failed to create result, reason:%s", tstrerror(code));
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = scalarCalculate(pTagCond, pBlockList, &output);
|
code = scalarCalculate(pTagCond, pBlockList, &output);
|
||||||
if(code != TSDB_CODE_SUCCESS){
|
if(code != TSDB_CODE_SUCCESS){
|
||||||
|
qError("failed to calculate scalar, reason:%s", tstrerror(code));
|
||||||
terrno = code;
|
terrno = code;
|
||||||
}
|
}
|
||||||
// int64_t st2 = taosGetTimestampUs();
|
// int64_t st2 = taosGetTimestampUs();
|
||||||
|
|
|
@ -681,6 +681,11 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
|
||||||
break;
|
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 t = lastColIdx + 1;
|
||||||
col_id_t index = findCol(&sToken, t, nCols, pSchema);
|
col_id_t index = findCol(&sToken, t, nCols, pSchema);
|
||||||
if (index < 0 && t > 0) {
|
if (index < 0 && t > 0) {
|
||||||
|
|
|
@ -1881,6 +1881,12 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
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 (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc) {
|
if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc) {
|
||||||
return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt));
|
return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt));
|
||||||
|
@ -1973,7 +1979,7 @@ static int32_t checkWindowFuncCoexist(STranslateContext* pCxt, SSelectStmt* pSel
|
||||||
if (NULL == pSelect->pWindow) {
|
if (NULL == pSelect->pWindow) {
|
||||||
return TSDB_CODE_SUCCESS;
|
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 generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue