提交 1d5e1e55 编写于 作者: G Ganlin Zhao

[TD-11222]<feature>: Histogram function

上级 0f8449d9
......@@ -2682,6 +2682,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
const char* msg23 = "parameter/bin out of range [-DBL_MAX, DBL_MAX]";
const char* msg24 = "width param cannot be 0";
const char* msg25 = "count param should be greater than 0";
const char* msg26 = "start param cannot be 0 with 'log_bin'";
const char* msg27 = "factor param should be greater than 1";
switch (functionId) {
case TSDB_FUNC_COUNT: {
......@@ -3459,6 +3461,14 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
}
} else if (cJSON_IsNumber(factor) && width == NULL && binType == LOG_BIN) {
//log bin process
if (start->valuedouble == 0) {
tfree(intervals);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg26);
}
if (factor->valuedouble <= 1) {
tfree(intervals);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg27);
}
for (int i = 0; i < counter + 1; ++i) {
intervals[startIndex] = start->valuedouble * pow(factor->valuedouble, i * 1.0);
if (isinf(intervals[startIndex])) {
......@@ -3479,6 +3489,11 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
tfree(intervals);
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg23);
}
//in case of desc bin orders, -inf/inf should be swapped
assert(numBins >= 4);
if (intervals[1] > intervals[numBins - 2]) {
SWAP(intervals[0], intervals[numBins - 1], double);
}
}
} else if (cJSON_IsArray(binDesc)) { /* user input bins */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册