提交 a8b22666 编写于 作者: G Ganlin Zhao

[TD-11222]<feature>: Histogram function

上级 a5be0d1a
...@@ -2680,7 +2680,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col ...@@ -2680,7 +2680,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
const char* msg21 = "third parameter must be in JSON format"; const char* msg21 = "third parameter must be in JSON format";
const char* msg22 = "invalid parameters for bin_desciption"; const char* msg22 = "invalid parameters for bin_desciption";
const char* msg23 = "parameter/bin out of range [-DBL_MAX, DBL_MAX]"; const char* msg23 = "parameter/bin out of range [-DBL_MAX, DBL_MAX]";
const char* msg24 = "linear_bin 'width' param cannot be 0"; const char* msg24 = "width param cannot be 0";
const char* msg25 = "count param should be greater than 0";
switch (functionId) { switch (functionId) {
case TSDB_FUNC_COUNT: { case TSDB_FUNC_COUNT: {
...@@ -3421,6 +3422,10 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col ...@@ -3421,6 +3422,10 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg22); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg22);
} }
if (count->valueint <= 0) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg25);
}
if (isinf(start->valuedouble) || if (isinf(start->valuedouble) ||
(width != NULL && isinf(width->valuedouble)) || (width != NULL && isinf(width->valuedouble)) ||
(factor != NULL && isinf(factor->valuedouble))) { (factor != NULL && isinf(factor->valuedouble))) {
......
...@@ -1047,6 +1047,17 @@ class TDTestCase: ...@@ -1047,6 +1047,17 @@ class TDTestCase:
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": -1.80e+308, "count": 5, "infinity": false}\', 0) from stb;') tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": -1.80e+308, "count": 5, "infinity": false}\', 0) from stb;')
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": 1.80e+308, "count": 5, "infinity": false}\', 0) from stb;') tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": 1.80e+308, "count": 5, "infinity": false}\', 0) from stb;')
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": -1.4e+308, "width": 1.4e+308, "count": 3, "infinity": false}\', 0) from stb;')
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": -1.4e+308, "width": 1.4e+308, "count": 3, "infinity": true}\', 0) from stb;')
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": 1, "count": -1, "infinity": false}\', 0) from stb;')
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": 1, "count": 0, "infinity": true}\', 0) from stb;')
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": 1, "count": true, "infinity": true}\', 0) from stb;')
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": 1, "count": false, "infinity": true}\', 0) from stb;')
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": 1, "count": "abc", "infinity": true}\', 0) from stb;')
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": 1, "count": "中文", "infinity": true}\', 0) from stb;')
tdSql.error('select histogram(col_tinyint, \'linear_bin\', \'{"start": 0, "width": 1, "count": abc, "infinity": true}\', 0) from stb;')
return return
tdSql.execute('drop database db') tdSql.execute('drop database db')
def stop(self): def stop(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册