Merge pull request #28247 from taosdata/fix/3.0/TD-32454

fix:[TD-32454] Use SMA when using min/max on numeric column.
This commit is contained in:
Pan Wei 2024-10-09 09:14:02 +08:00 committed by GitHub
commit 0c99d5b220
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 1 additions and 7 deletions

View File

@ -190,7 +190,6 @@ typedef struct SFunctionNode {
bool hasOriginalFunc; bool hasOriginalFunc;
int32_t originalFuncId; int32_t originalFuncId;
ETrimType trimType; ETrimType trimType;
bool hasSMA;
bool dual; // whether select stmt without from stmt, true for without. bool dual; // whether select stmt without from stmt, true for without.
} SFunctionNode; } SFunctionNode;

View File

@ -327,7 +327,6 @@ static int32_t translateMinMax(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
} else if (IS_NULL_TYPE(paraType)) { } else if (IS_NULL_TYPE(paraType)) {
paraType = TSDB_DATA_TYPE_BIGINT; paraType = TSDB_DATA_TYPE_BIGINT;
} }
pFunc->hasSMA = !IS_VAR_DATA_TYPE(paraType);
int32_t bytes = IS_STR_DATA_TYPE(paraType) ? dataType->bytes : tDataTypes[paraType].bytes; int32_t bytes = IS_STR_DATA_TYPE(paraType) ? dataType->bytes : tDataTypes[paraType].bytes;
pFunc->node.resType = (SDataType){.bytes = bytes, .type = paraType}; pFunc->node.resType = (SDataType){.bytes = bytes, .type = paraType};
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;

View File

@ -294,9 +294,6 @@ static bool scanPathOptIsSpecifiedFuncType(const SFunctionNode* pFunc, bool (*ty
return true; return true;
} }
static bool isMinMaxFunction(int32_t funcType) {
return funcType == FUNCTION_TYPE_MIN || funcType == FUNCTION_TYPE_MAX;
}
static int32_t scanPathOptGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSdrFuncs, SNodeList** pDsoFuncs) { static int32_t scanPathOptGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSdrFuncs, SNodeList** pDsoFuncs) {
SNodeList* pAllFuncs = scanPathOptGetAllFuncs(pScan->node.pParent); SNodeList* pAllFuncs = scanPathOptGetAllFuncs(pScan->node.pParent);
SNodeList* pTmpSdrFuncs = NULL; SNodeList* pTmpSdrFuncs = NULL;
@ -306,8 +303,7 @@ static int32_t scanPathOptGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSd
FOREACH(pNode, pAllFuncs) { FOREACH(pNode, pAllFuncs) {
SFunctionNode* pFunc = (SFunctionNode*)pNode; SFunctionNode* pFunc = (SFunctionNode*)pNode;
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
if ((!isMinMaxFunction(pFunc->funcType) && scanPathOptIsSpecifiedFuncType(pFunc, fmIsSpecialDataRequiredFunc)) || if (scanPathOptIsSpecifiedFuncType(pFunc, fmIsSpecialDataRequiredFunc)) {
(isMinMaxFunction(pFunc->funcType) && pFunc->hasSMA)) {
SNode* pNew = NULL; SNode* pNew = NULL;
code = nodesCloneNode(pNode, &pNew); code = nodesCloneNode(pNode, &pNew);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {