fix:[TD-32454] Use SMA when using min/max on numeric column.
This commit is contained in:
parent
b7d7a23eea
commit
f5872e6cec
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue