[td-14440] fix bug.
This commit is contained in:
parent
869b0b99a9
commit
14d8c5f7f1
|
@ -844,8 +844,7 @@ static int32_t setResultOutputBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowI
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, SqlFunctionCtx* pCtx,
|
||||
int32_t numOfOutput, int32_t* rowCellInfoOffset);
|
||||
static void setResultRowOutputBufInitCtx_rv(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset);
|
||||
|
||||
static int32_t setResultOutputBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_t id, STimeWindow* win, bool masterscan,
|
||||
SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx,
|
||||
|
@ -863,7 +862,7 @@ static int32_t setResultOutputBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_
|
|||
// set time window for current result
|
||||
pResultRow->win = (*win);
|
||||
*pResult = pResultRow;
|
||||
setResultRowOutputBufInitCtx_rv(pAggSup->pResultBuf, pResultRow, pCtx, numOfOutput, rowCellInfoOffset);
|
||||
setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfOutput, rowCellInfoOffset);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1046,7 +1045,9 @@ static void updateTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pWin) {
|
|||
static void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol,
|
||||
int32_t numOfTotal, int32_t numOfOutput, int32_t order) {
|
||||
SScalarParam intervalParam = {.numOfRows = 5, .columnData = pTimeWindowData}; //TODO move out of this function
|
||||
updateTimeWindowInfo(pTimeWindowData, pWin);
|
||||
if (pTimeWindowData != NULL) {
|
||||
updateTimeWindowInfo(pTimeWindowData, pWin);
|
||||
}
|
||||
|
||||
for (int32_t k = 0; k < numOfOutput; ++k) {
|
||||
pCtx[k].startTs = pWin->skey;
|
||||
|
@ -1894,9 +1895,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
}
|
||||
|
||||
/*int32_t ret = */ generatedHashKey(pInfo->keyBuf, &len, pInfo->pGroupColVals);
|
||||
int32_t ret =
|
||||
setGroupResultOutputBuf_rv(&(pInfo->binfo), pOperator->numOfOutput, pInfo->keyBuf, TSDB_DATA_TYPE_VARCHAR, len,
|
||||
0, pInfo->aggSup.pResultBuf, pTaskInfo, &pInfo->aggSup);
|
||||
int32_t ret = setGroupResultOutputBuf_rv(&(pInfo->binfo), pOperator->numOfOutput, pInfo->keyBuf, TSDB_DATA_TYPE_VARCHAR, len, 0, pInfo->aggSup.pResultBuf, pTaskInfo, &pInfo->aggSup);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
||||
}
|
||||
|
@ -2018,12 +2017,11 @@ static int32_t setGroupResultOutputBuf_rv(SOptrBasicInfo* binfo, int32_t numOfCo
|
|||
SqlFunctionCtx* pCtx = binfo->pCtx;
|
||||
|
||||
SResultRow* pResultRow = doSetResultOutBufByKey_rv(pBuf, pResultRowInfo, groupId, (char*)pData, bytes, true, groupId,
|
||||
pTaskInfo, true, pAggSup);
|
||||
pTaskInfo, false, pAggSup);
|
||||
assert(pResultRow != NULL);
|
||||
|
||||
setResultRowKey(pResultRow, pData, type);
|
||||
|
||||
setResultRowOutputBufInitCtx_rv(pBuf, pResultRow, pCtx, numOfCols, binfo->rowCellInfoOffset);
|
||||
setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfCols, binfo->rowCellInfoOffset);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2178,8 +2176,8 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t num
|
|||
}
|
||||
}
|
||||
pCtx->resDataInfo.interBufSize = env.calcMemSize;
|
||||
} else if (pExpr->pExpr->nodeType == QUERY_NODE_COLUMN) {
|
||||
} else if (pExpr->pExpr->nodeType == QUERY_NODE_OPERATOR) {
|
||||
} else if (pExpr->pExpr->nodeType == QUERY_NODE_COLUMN || pExpr->pExpr->nodeType == QUERY_NODE_OPERATOR) {
|
||||
pCtx->resDataInfo.interBufSize = pFunct->resSchema.bytes; // for simple column, the intermediate buffer needs to hold one element.
|
||||
}
|
||||
|
||||
pCtx->input.numOfInputCols = pFunct->numOfParams;
|
||||
|
@ -3775,8 +3773,7 @@ void setResultRowOutputBufInitCtx(STaskRuntimeEnv* pRuntimeEnv, SResultRow* pRes
|
|||
}
|
||||
}
|
||||
|
||||
void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, SqlFunctionCtx* pCtx,
|
||||
int32_t numOfOutput, int32_t* rowCellInfoOffset) {
|
||||
void setResultRowOutputBufInitCtx_rv(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset) {
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
pCtx[i].resultInfo = getResultCell(pResult, i, rowCellInfoOffset);
|
||||
|
||||
|
@ -3789,18 +3786,13 @@ void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, S
|
|||
continue;
|
||||
}
|
||||
|
||||
// if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) {
|
||||
// if (i > 0) pCtx[i].ptsOutputBuf = pCtx[i - 1].pOutput;
|
||||
// }
|
||||
|
||||
if (!pResInfo->initialized && pCtx[i].functionId != -1) {
|
||||
pCtx[i].fpSet.init(&pCtx[i], pResInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, int32_t tableGroupId,
|
||||
SExecTaskInfo* pTaskInfo) {
|
||||
void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, int32_t tableGroupId, SExecTaskInfo* pTaskInfo) {
|
||||
// for simple group by query without interval, all the tables belong to one group result.
|
||||
int64_t uid = 0;
|
||||
int64_t tid = 0;
|
||||
|
@ -3819,14 +3811,13 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, i
|
|||
* all group belong to one result set, and each group result has different group id so set the id to be one
|
||||
*/
|
||||
if (pResultRow->pageId == -1) {
|
||||
int32_t ret =
|
||||
addNewWindowResultBuf(pResultRow, pAggInfo->pResultBuf, tableGroupId, pAggInfo->binfo.pRes->info.rowSize);
|
||||
int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->pResultBuf, tableGroupId, pAggInfo->binfo.pRes->info.rowSize);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setResultRowOutputBufInitCtx_rv(pAggInfo->pResultBuf, pResultRow, pCtx, numOfOutput, rowCellInfoOffset);
|
||||
setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfOutput, rowCellInfoOffset);
|
||||
}
|
||||
|
||||
void setExecutionContext(int32_t numOfOutput, int32_t tableGroupId, TSKEY nextKey, SExecTaskInfo* pTaskInfo,
|
||||
|
|
|
@ -142,68 +142,68 @@ if $row != 10 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @2022-01-01 00:00:00.000@ then
|
||||
if $data00 != @22-01-01 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
if $data90 != @2022-01-01 00:00:00.009@ then
|
||||
if $data90 != @22-01-01 00:00:00.009@ then
|
||||
return -1
|
||||
endi
|
||||
if $data91 != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
sql select sum(c1), c1, avg(c1), min(c1), max(c2) from group_tb0 where c1 < 20 group by c1;
|
||||
if $row != 20 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print $data02
|
||||
if $data02 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print $data04
|
||||
if $data04 != 0.00000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != 100 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print $data12
|
||||
if $data12 != 1.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data13 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data14 != 1.00000 then
|
||||
print expect 1.00000, actual:$data14
|
||||
return -1
|
||||
endi
|
||||
print ============> filter not supported yet.
|
||||
#sql select sum(c1), c1, avg(c1), min(c1), max(c2) from group_tb0 where c1 < 20 group by c1;
|
||||
#if $row != 20 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#if $data00 != 0 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#if $data01 != 0 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print $data02
|
||||
#if $data02 != 0.000000000 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#if $data03 != 0 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print $data04
|
||||
#if $data04 != 0.00000 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#if $data10 != 100 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#if $data11 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print $data12
|
||||
#if $data12 != 1.000000000 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#if $data13 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#if $data14 != 1.00000 then
|
||||
# print expect 1.00000, actual:$data14
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
sql_error select sum(c1), ts, c1 from group_tb0 where c1<20 group by c1;
|
||||
sql_error select first(ts), ts, c2 from group_tb0 where c1 < 20 group by c1;
|
||||
|
|
Loading…
Reference in New Issue