fix bug
This commit is contained in:
parent
2eb7174f76
commit
22882196c3
|
@ -3079,14 +3079,10 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumn* pColumn) {
|
|||
}
|
||||
|
||||
static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SColumnFilterInfo* pColumnFilter,
|
||||
SColumnIndex* columnIndex, tSqlExpr* pExpr) {
|
||||
int16_t colType, tSqlExpr* pExpr) {
|
||||
const char* msg = "not supported filter condition";
|
||||
|
||||
tSqlExpr* pRight = pExpr->pRight;
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, columnIndex->tableIndex);
|
||||
SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, columnIndex->columnIndex);
|
||||
|
||||
int16_t colType = pSchema->type;
|
||||
|
||||
if (colType >= TSDB_DATA_TYPE_TINYINT && colType <= TSDB_DATA_TYPE_BIGINT) {
|
||||
colType = TSDB_DATA_TYPE_BIGINT;
|
||||
|
@ -3291,8 +3287,10 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SC
|
|||
}
|
||||
|
||||
pColumn->colIndex = *pIndex;
|
||||
|
||||
int16_t colType = pSchema->type;
|
||||
|
||||
return doExtractColumnFilterInfo(pCmd, pQueryInfo, pColFilter, pIndex, pExpr);
|
||||
return doExtractColumnFilterInfo(pCmd, pQueryInfo, pColFilter, colType, pExpr);
|
||||
}
|
||||
|
||||
static int32_t getTablenameCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pTableCond, SStringBuilder* sb) {
|
||||
|
@ -6898,12 +6896,7 @@ static int32_t handleExprInHavingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
|
|||
}
|
||||
}
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &pExpr->pLeft->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
||||
int32_t ret = doExtractColumnFilterInfo(pCmd, pQueryInfo, pColFilter, &index, pExpr);
|
||||
int32_t ret = doExtractColumnFilterInfo(pCmd, pQueryInfo, pColFilter, pInfo->field.type, pExpr);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -862,7 +862,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
pSqlFuncExpr->functionId = htons(pExpr->functionId);
|
||||
pSqlFuncExpr->numOfParams = htons(pExpr->numOfParams);
|
||||
pSqlFuncExpr->resColId = htons(pExpr->resColId);
|
||||
if (pExpr->pFilter && pExpr->pFilter->numOfFilters > 0) {
|
||||
if (pTableMeta->tableType != TSDB_SUPER_TABLE && pExpr->pFilter && pExpr->pFilter->numOfFilters > 0) {
|
||||
pSqlFuncExpr->filterNum = htonl(pExpr->pFilter->numOfFilters);
|
||||
} else {
|
||||
pSqlFuncExpr->filterNum = 0;
|
||||
|
|
|
@ -200,6 +200,7 @@ static bool isPointInterpoQuery(SQuery *pQuery);
|
|||
static void setResultBufSize(SQuery* pQuery, SRspResultInfo* pResultInfo);
|
||||
static void setCtxTagForJoin(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, SExprInfo* pExprInfo, void* pTable);
|
||||
static void setParamForStableStddev(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput, SExprInfo* pExpr);
|
||||
static void setParamForStableStddevByColData(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput, SExprInfo* pExpr, char* val, int16_t bytes);
|
||||
static void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo,
|
||||
SQLFunctionCtx* pCtx, int32_t* rowCellInfoOffset, int32_t numOfOutput,
|
||||
int32_t groupIndex);
|
||||
|
@ -1330,6 +1331,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
|
|||
SColumnInfoData* pColInfoData = taosArrayGet(pSDataBlock->pDataBlock, pInfo->colIndex);
|
||||
int16_t bytes = pColInfoData->info.bytes;
|
||||
int16_t type = pColInfoData->info.type;
|
||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||
|
||||
if (type == TSDB_DATA_TYPE_FLOAT || type == TSDB_DATA_TYPE_DOUBLE) {
|
||||
qError("QInfo:%"PRIu64" group by not supported on double/float columns, abort", GET_QID(pRuntimeEnv));
|
||||
|
@ -1350,6 +1352,10 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
|
|||
|
||||
memcpy(pInfo->prevData, val, bytes);
|
||||
|
||||
if (pQuery->stableQuery && pQuery->stabledev && (pRuntimeEnv->prevResult != NULL)) {
|
||||
setParamForStableStddevByColData(pRuntimeEnv, pInfo->binfo.pCtx, pOperator->numOfOutput, pOperator->pExpr, val, bytes);
|
||||
}
|
||||
|
||||
int32_t ret =
|
||||
setGroupResultOutputBuf(pRuntimeEnv, pInfo, pOperator->numOfOutput, val, type, bytes, item->groupIndex);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
|
@ -3396,6 +3402,42 @@ void setParamForStableStddev(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx
|
|||
|
||||
}
|
||||
|
||||
void setParamForStableStddevByColData(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput, SExprInfo* pExpr, char* val, int16_t bytes) {
|
||||
SQuery* pQuery = pRuntimeEnv->pQuery;
|
||||
|
||||
int32_t numOfExprs = pQuery->numOfOutput;
|
||||
for(int32_t i = 0; i < numOfExprs; ++i) {
|
||||
SExprInfo* pExprInfo = &(pExpr[i]);
|
||||
if (pExprInfo->base.functionId != TSDB_FUNC_STDDEV_DST) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SSqlFuncMsg* pFuncMsg = &pExprInfo->base;
|
||||
|
||||
pCtx[i].param[0].arr = NULL;
|
||||
pCtx[i].param[0].nType = TSDB_DATA_TYPE_INT; // avoid freeing the memory by setting the type to be int
|
||||
|
||||
// TODO use hash to speedup this loop
|
||||
int32_t numOfGroup = (int32_t)taosArrayGetSize(pRuntimeEnv->prevResult);
|
||||
for (int32_t j = 0; j < numOfGroup; ++j) {
|
||||
SInterResult* p = taosArrayGet(pRuntimeEnv->prevResult, j);
|
||||
if (bytes == 0 || memcmp(p->tags, val, bytes) == 0) {
|
||||
int32_t numOfCols = (int32_t)taosArrayGetSize(p->pResult);
|
||||
for (int32_t k = 0; k < numOfCols; ++k) {
|
||||
SStddevInterResult* pres = taosArrayGet(p->pResult, k);
|
||||
if (pres->colId == pFuncMsg->colInfo.colId) {
|
||||
pCtx[i].param[0].arr = pres->pResult;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* There are two cases to handle:
|
||||
*
|
||||
|
|
|
@ -319,6 +319,14 @@ int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (left->tokenId != right->tokenId) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (left->functionId != right->functionId) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((left->pLeft && right->pLeft == NULL)
|
||||
|| (left->pLeft == NULL && right->pLeft)
|
||||
|| (left->pRight && right->pRight == NULL)
|
||||
|
@ -336,12 +344,13 @@ int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
size_t size = taosArrayGetSize(right->pParam);
|
||||
if (left->pParam && taosArrayGetSize(left->pParam) != size) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (right->pParam && left->pParam) {
|
||||
size_t size = taosArrayGetSize(right->pParam);
|
||||
if (left->pParam && taosArrayGetSize(left->pParam) != size) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
tSqlExprItem* pLeftElem = taosArrayGet(left->pParam, i);
|
||||
tSqlExpr* pSubLeft = pLeftElem->pNode;
|
||||
|
|
Loading…
Reference in New Issue