diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 365e6426f95de994b63f008d0b2d592d8af9acc8..e41141c2861edf71715a997f5f5ee6175f863e7a 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3463,6 +3463,9 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col int i = 0; while (bin) { intervals[i] = bin->valuedouble; + if (!cJSON_IsNumber(bin)) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg22); + } if (i != 0 && intervals[i] <= intervals[i - 1]) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg22); } diff --git a/tests/develop-test/2-query/function_histogram.py b/tests/develop-test/2-query/function_histogram.py index 72c8ed7cb6d0b573294e12c66b45bebc7036e5a8..abdba47171ef38170bfcdcec60ddc44b64987e17 100644 --- a/tests/develop-test/2-query/function_histogram.py +++ b/tests/develop-test/2-query/function_histogram.py @@ -193,7 +193,7 @@ class TDTestCase: print("============== STEP 2: bin types ================== ") - #user_input + ## user_input ## #TINYINT tdSql.query('select histogram(col_tinyint, "user_input", "[1,3,5]", 0) from stb;') tdSql.checkRows(2); @@ -760,6 +760,30 @@ class TDTestCase: tdSql.checkData(1, 0, "(9.9-19.9]:2"); tdSql.checkData(2, 0, "(19.9-1e+14]:2"); + #ERROR CASE + tdSql.error('select histogram(col_double, "user_input", "[1,5,3,7]", 0) from stb;') + tdSql.error('select histogram(col_double, "user_input", "[1,-1,3,-3]", 0) from stb;') + tdSql.error('select histogram(col_double, "user_input", "[1.0,5.5,3.3,7.7]", 0) from stb;') + tdSql.error('select histogram(col_double, "user_input", "[1,1,1]", 0) from stb;') + tdSql.error('select histogram(col_double, "user_input", "[false,3,5]", 0) from stb;') + tdSql.error('select histogram(col_double, "user_input", "[true,3,5]", 0) from stb;') + + + ## user_input ## + #TINYINT + tdSql.query('select histogram(col_tinyint, "user_input", "[1,3,5]", 0) from stb;') + tdSql.checkRows(2); + tdSql.checkData(0, 0, "(1-3]:2"); + tdSql.checkData(1, 0, "(3-5]:2"); + tdSql.query('select histogram(col_tinyint, "user_input", "[1,3,5]", 0) from ctb;') + tdSql.checkRows(2); + tdSql.checkData(0, 0, "(1-3]:2"); + tdSql.checkData(1, 0, "(3-5]:2"); + tdSql.query('select histogram(col_tinyint, "user_input", "[1,3,5]", 0) from tb;') + tdSql.checkRows(2); + tdSql.checkData(0, 0, "(1-3]:2"); + tdSql.checkData(1, 0, "(3-5]:2"); + return tdSql.execute('drop database db') def stop(self):