未验证 提交 74d7e141 编写于 作者: S shenglian-zhou 提交者: GitHub

Merge pull request #10500 from taosdata/feature/TD-13589

[TD-13589]<feature>(query): Improve Histogram function output as JSON string
...@@ -3546,12 +3546,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col ...@@ -3546,12 +3546,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
} }
if (infinity->valueint == true) { if (infinity->valueint == true) {
intervals[0] = -DBL_MAX; intervals[0] = -INFINITY;
intervals[numBins - 1] = DBL_MAX; intervals[numBins - 1] = INFINITY;
if (isinf(intervals[0]) || isinf(intervals[numBins - 1])) {
tfree(intervals);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg23);
}
// in case of desc bin orders, -inf/inf should be swapped // in case of desc bin orders, -inf/inf should be swapped
assert(numBins >= 4); assert(numBins >= 4);
if (intervals[1] > intervals[numBins - 2]) { if (intervals[1] > intervals[numBins - 2]) {
......
...@@ -5100,10 +5100,10 @@ static void histogram_func_finalizer(SQLFunctionCtx *pCtx) { ...@@ -5100,10 +5100,10 @@ static void histogram_func_finalizer(SQLFunctionCtx *pCtx) {
int sz; int sz;
if (!pRes->normalized) { if (!pRes->normalized) {
int64_t count = (int64_t)pRes->orderedBins[i].count; int64_t count = (int64_t)pRes->orderedBins[i].count;
sz = sprintf(pCtx->pOutput + VARSTR_HEADER_SIZE, "(%g:%g]:%"PRId64, sz = sprintf(pCtx->pOutput + VARSTR_HEADER_SIZE, "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%"PRId64"}",
pRes->orderedBins[i].lower, pRes->orderedBins[i].upper, count); pRes->orderedBins[i].lower, pRes->orderedBins[i].upper, count);
} else { } else {
sz = sprintf(pCtx->pOutput + VARSTR_HEADER_SIZE, "(%g:%g]:%lf", sz = sprintf(pCtx->pOutput + VARSTR_HEADER_SIZE, "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%lf}",
pRes->orderedBins[i].lower, pRes->orderedBins[i].upper, pRes->orderedBins[i].count); pRes->orderedBins[i].lower, pRes->orderedBins[i].upper, pRes->orderedBins[i].count);
} }
varDataSetLen(pCtx->pOutput, sz); varDataSetLen(pCtx->pOutput, sz);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册