[TD-2570]<feature> fix bug
This commit is contained in:
parent
bcf7be5026
commit
10cfc73555
|
@ -127,6 +127,7 @@ int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, i
|
||||||
*/
|
*/
|
||||||
bool tscIsPointInterpQuery(SQueryInfo* pQueryInfo);
|
bool tscIsPointInterpQuery(SQueryInfo* pQueryInfo);
|
||||||
bool tscIsTWAQuery(SQueryInfo* pQueryInfo);
|
bool tscIsTWAQuery(SQueryInfo* pQueryInfo);
|
||||||
|
bool tscIsSessionWindowQuery(SQueryInfo* pQueryInfo);
|
||||||
bool tscIsSecondStageQuery(SQueryInfo* pQueryInfo);
|
bool tscIsSecondStageQuery(SQueryInfo* pQueryInfo);
|
||||||
bool tscGroupbyColumn(SQueryInfo* pQueryInfo);
|
bool tscGroupbyColumn(SQueryInfo* pQueryInfo);
|
||||||
bool tscIsTopBotQuery(SQueryInfo* pQueryInfo);
|
bool tscIsTopBotQuery(SQueryInfo* pQueryInfo);
|
||||||
|
|
|
@ -832,8 +832,8 @@ int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pS
|
||||||
static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode, bool isStable) {
|
static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode, bool isStable) {
|
||||||
|
|
||||||
const char* msg1 = "invalid column name";
|
const char* msg1 = "invalid column name";
|
||||||
const char* msg3 = "not support state window on super table/tag column";
|
const char* msg3 = "not support state_window with group by ";
|
||||||
const char* msg4 = "not support state_window with group by ";
|
const char* msg4 = "function not support for super table query";
|
||||||
|
|
||||||
SStrToken *col = &(pSqlNode->windowstateVal.col) ;
|
SStrToken *col = &(pSqlNode->windowstateVal.col) ;
|
||||||
if (col->z == NULL || col->n <= 0) {
|
if (col->z == NULL || col->n <= 0) {
|
||||||
|
@ -844,13 +844,13 @@ static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
|
||||||
pQueryInfo->colList = taosArrayInit(4, POINTER_BYTES);
|
pQueryInfo->colList = taosArrayInit(4, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) {
|
if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||||
}
|
}
|
||||||
pQueryInfo->groupbyExpr.numOfGroupCols = 1;
|
pQueryInfo->groupbyExpr.numOfGroupCols = 1;
|
||||||
|
|
||||||
//TODO(dengyihao): check tag column
|
//TODO(dengyihao): check tag column
|
||||||
if (isStable) {
|
if (isStable) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4);
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||||
|
@ -2938,6 +2938,9 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (tscIsSessionWindowQuery(pQueryInfo)) {
|
||||||
|
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -7373,6 +7376,10 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, int32_t index) {
|
||||||
* transfer sql functions that need secondary merge into another format
|
* transfer sql functions that need secondary merge into another format
|
||||||
* in dealing with super table queries such as: count/first/last
|
* in dealing with super table queries such as: count/first/last
|
||||||
*/
|
*/
|
||||||
|
if (validateSessionNode(pCmd, pQueryInfo, pSqlNode) != TSDB_CODE_SUCCESS) {
|
||||||
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
|
}
|
||||||
|
|
||||||
if (isSTable) {
|
if (isSTable) {
|
||||||
tscTansformFuncForSTableQuery(pQueryInfo);
|
tscTansformFuncForSTableQuery(pQueryInfo);
|
||||||
|
|
||||||
|
@ -7381,9 +7388,6 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, int32_t index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validateSessionNode(pCmd, pQueryInfo, pSqlNode) != TSDB_CODE_SUCCESS) {
|
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// no result due to invalid query time range
|
// no result due to invalid query time range
|
||||||
if (pQueryInfo->window.skey > pQueryInfo->window.ekey) {
|
if (pQueryInfo->window.skey > pQueryInfo->window.ekey) {
|
||||||
|
|
|
@ -356,6 +356,9 @@ bool tscIsTWAQuery(SQueryInfo* pQueryInfo) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool tscIsSessionWindowQuery(SQueryInfo* pQueryInfo) {
|
||||||
|
return pQueryInfo->sessionWindow.gap > 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool tscNeedReverseScan(SQueryInfo* pQueryInfo) {
|
bool tscNeedReverseScan(SQueryInfo* pQueryInfo) {
|
||||||
size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo);
|
size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo);
|
||||||
|
|
|
@ -1333,7 +1333,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
|
||||||
pInfo->start = j;
|
pInfo->start = j;
|
||||||
} else if (tsList[j] - pInfo->prevTs <= gap) {
|
} else if (tsList[j] - pInfo->prevTs <= gap) {
|
||||||
pInfo->curWindow.ekey = tsList[j];
|
pInfo->curWindow.ekey = tsList[j];
|
||||||
pInfo->prevTs = tsList[j];
|
//pInfo->prevTs = tsList[j];
|
||||||
pInfo->numOfRows += 1;
|
pInfo->numOfRows += 1;
|
||||||
if (j == 0 && pInfo->start != 0) {
|
if (j == 0 && pInfo->start != 0) {
|
||||||
pInfo->numOfRows = 1;
|
pInfo->numOfRows = 1;
|
||||||
|
@ -1342,6 +1342,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
|
||||||
} else { // start a new session window
|
} else { // start a new session window
|
||||||
SResultRow* pResult = NULL;
|
SResultRow* pResult = NULL;
|
||||||
|
|
||||||
|
pInfo->curWindow.ekey = pInfo->curWindow.skey;
|
||||||
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan,
|
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan,
|
||||||
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
|
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
|
||||||
pBInfo->rowCellInfoOffset);
|
pBInfo->rowCellInfoOffset);
|
||||||
|
@ -1362,6 +1363,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
|
||||||
|
|
||||||
SResultRow* pResult = NULL;
|
SResultRow* pResult = NULL;
|
||||||
|
|
||||||
|
pInfo->curWindow.ekey = pInfo->curWindow.skey;
|
||||||
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan,
|
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan,
|
||||||
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
|
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
|
||||||
pBInfo->rowCellInfoOffset);
|
pBInfo->rowCellInfoOffset);
|
||||||
|
@ -2063,6 +2065,8 @@ static bool onlyFirstQuery(SQueryAttr *pQueryAttr) { return onlyOneQueryType(pQu
|
||||||
|
|
||||||
static bool onlyLastQuery(SQueryAttr *pQueryAttr) { return onlyOneQueryType(pQueryAttr, TSDB_FUNC_LAST, TSDB_FUNC_LAST_DST); }
|
static bool onlyLastQuery(SQueryAttr *pQueryAttr) { return onlyOneQueryType(pQueryAttr, TSDB_FUNC_LAST, TSDB_FUNC_LAST_DST); }
|
||||||
|
|
||||||
|
static bool notContainSessionOrStateWindow(SQueryAttr *pQueryAttr) { return !(pQueryAttr->sw.gap > 0 || pQueryAttr->stateWindow); }
|
||||||
|
|
||||||
static int32_t updateBlockLoadStatus(SQueryAttr *pQuery, int32_t status) {
|
static int32_t updateBlockLoadStatus(SQueryAttr *pQuery, int32_t status) {
|
||||||
bool hasFirstLastFunc = false;
|
bool hasFirstLastFunc = false;
|
||||||
bool hasOtherFunc = false;
|
bool hasOtherFunc = false;
|
||||||
|
@ -2166,7 +2170,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo
|
||||||
}
|
}
|
||||||
|
|
||||||
pQueryAttr->order.order = TSDB_ORDER_ASC;
|
pQueryAttr->order.order = TSDB_ORDER_ASC;
|
||||||
} else if (onlyLastQuery(pQueryAttr)) {
|
} else if (onlyLastQuery(pQueryAttr) && notContainSessionOrStateWindow(pQueryAttr)) {
|
||||||
if (QUERY_IS_ASC_QUERY(pQueryAttr)) {
|
if (QUERY_IS_ASC_QUERY(pQueryAttr)) {
|
||||||
qDebug(msg, pQInfo, "only-last", pQueryAttr->order.order, TSDB_ORDER_DESC, pQueryAttr->window.skey,
|
qDebug(msg, pQInfo, "only-last", pQueryAttr->order.order, TSDB_ORDER_DESC, pQueryAttr->window.skey,
|
||||||
pQueryAttr->window.ekey, pQueryAttr->window.ekey, pQueryAttr->window.skey);
|
pQueryAttr->window.ekey, pQueryAttr->window.ekey, pQueryAttr->window.skey);
|
||||||
|
@ -5194,6 +5198,7 @@ static SSDataBlock* doSessionWindowAgg(void* param, bool* newgroup) {
|
||||||
SSWindowOperatorInfo* pWindowInfo = pOperator->info;
|
SSWindowOperatorInfo* pWindowInfo = pOperator->info;
|
||||||
SOptrBasicInfo* pBInfo = &pWindowInfo->binfo;
|
SOptrBasicInfo* pBInfo = &pWindowInfo->binfo;
|
||||||
|
|
||||||
|
|
||||||
SQueryRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv;
|
SQueryRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv;
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
toSSDataBlock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pBInfo->pRes);
|
toSSDataBlock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pBInfo->pRes);
|
||||||
|
@ -5206,6 +5211,7 @@ static SSDataBlock* doSessionWindowAgg(void* param, bool* newgroup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
|
SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
|
||||||
|
//pQueryAttr->order.order = TSDB_ORDER_ASC;
|
||||||
int32_t order = pQueryAttr->order.order;
|
int32_t order = pQueryAttr->order.order;
|
||||||
STimeWindow win = pQueryAttr->window;
|
STimeWindow win = pQueryAttr->window;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue