fix decimal order by
This commit is contained in:
parent
7f1eabf905
commit
c955c23076
|
@ -1072,7 +1072,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
SValueNode* pValue = (SValueNode*)pNode;
|
SValueNode* pValue = (SValueNode*)pNode;
|
||||||
destroyExprNode((SExprNode*)pNode);
|
destroyExprNode((SExprNode*)pNode);
|
||||||
taosMemoryFreeClear(pValue->literal);
|
taosMemoryFreeClear(pValue->literal);
|
||||||
if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) {
|
if (IS_VAR_DATA_TYPE(pValue->node.resType.type) || pValue->node.resType.type == TSDB_DATA_TYPE_DECIMAL) {
|
||||||
taosMemoryFreeClear(pValue->datum.p);
|
taosMemoryFreeClear(pValue->datum.p);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1298,6 +1298,16 @@ EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) {
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
(void)memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData));
|
(void)memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData));
|
||||||
|
} else if (type == TSDB_DATA_TYPE_DECIMAL) {
|
||||||
|
res->datum.p = taosMemoryCalloc(1, DECIMAL128_BYTES);
|
||||||
|
if (!res->datum.p) {
|
||||||
|
sclError("calloc %d failed", DECIMAL128_BYTES);
|
||||||
|
sclFreeParam(&output);
|
||||||
|
nodesDestroyNode((SNode*)res);
|
||||||
|
ctx->code = terrno;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
(void)memcpy(res->datum.p, output.columnData->pData, DECIMAL128_BYTES);
|
||||||
} else {
|
} else {
|
||||||
ctx->code = nodesSetValueNodeValue(res, output.columnData->pData);
|
ctx->code = nodesSetValueNodeValue(res, output.columnData->pData);
|
||||||
if (ctx->code) {
|
if (ctx->code) {
|
||||||
|
|
|
@ -1063,6 +1063,13 @@ int32_t compareDecimal64SameScale(const void* pleft, const void* pright) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t compareDecimal64SameScaleDesc(const void* pLeft, const void* pRight) {
|
||||||
|
SDecimalOps* pOps = getDecimalOps(TSDB_DATA_TYPE_DECIMAL64);
|
||||||
|
if (pOps->lt(pLeft, pRight, WORD_NUM(Decimal64))) return 1;
|
||||||
|
if (pOps->gt(pLeft, pRight, WORD_NUM(Decimal64))) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t compareDecimal128SameScale(const void* pleft, const void* pright) {
|
int32_t compareDecimal128SameScale(const void* pleft, const void* pright) {
|
||||||
SDecimalOps* pOps = getDecimalOps(TSDB_DATA_TYPE_DECIMAL);
|
SDecimalOps* pOps = getDecimalOps(TSDB_DATA_TYPE_DECIMAL);
|
||||||
if (pOps->gt(pleft, pright, WORD_NUM(Decimal))) return 1;
|
if (pOps->gt(pleft, pright, WORD_NUM(Decimal))) return 1;
|
||||||
|
@ -1070,6 +1077,13 @@ int32_t compareDecimal128SameScale(const void* pleft, const void* pright) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t compareDecimal128SameScaleDesc(const void* pLeft, const void* pRight) {
|
||||||
|
SDecimalOps* pOps = getDecimalOps(TSDB_DATA_TYPE_DECIMAL);
|
||||||
|
if (pOps->lt(pLeft, pRight, WORD_NUM(Decimal))) return 1;
|
||||||
|
if (pOps->gt(pLeft, pRight, WORD_NUM(Decimal))) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t compareJsonValDesc(const void *pLeft, const void *pRight) { return compareJsonVal(pRight, pLeft); }
|
int32_t compareJsonValDesc(const void *pLeft, const void *pRight) { return compareJsonVal(pRight, pLeft); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1810,6 +1824,10 @@ __compar_fn_t getKeyComparFunc(int32_t keyType, int32_t order) {
|
||||||
return (order == TSDB_ORDER_ASC) ? compareLenPrefixedWStr : compareLenPrefixedWStrDesc;
|
return (order == TSDB_ORDER_ASC) ? compareLenPrefixedWStr : compareLenPrefixedWStrDesc;
|
||||||
case TSDB_DATA_TYPE_JSON:
|
case TSDB_DATA_TYPE_JSON:
|
||||||
return (order == TSDB_ORDER_ASC) ? compareJsonVal : compareJsonValDesc;
|
return (order == TSDB_ORDER_ASC) ? compareJsonVal : compareJsonValDesc;
|
||||||
|
case TSDB_DATA_TYPE_DECIMAL64:
|
||||||
|
return (order == TSDB_ORDER_ASC) ? compareDecimal64SameScale : compareDecimal64SameScaleDesc;
|
||||||
|
case TSDB_DATA_TYPE_DECIMAL:
|
||||||
|
return (order == TSDB_ORDER_ASC) ? compareDecimal128SameScale : compareDecimal128SameScaleDesc;
|
||||||
default:
|
default:
|
||||||
return (order == TSDB_ORDER_ASC) ? compareInt32Val : compareInt32ValDesc;
|
return (order == TSDB_ORDER_ASC) ? compareInt32Val : compareInt32ValDesc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue