diff --git a/src/client/src/tscParseOpenTSDB.c b/src/client/src/tscParseOpenTSDB.c index 8a0b82150cf315d36fcec6c79fc6181a4b3ed81b..3739f53ba64c6bac24ed2d639fc930b4110ca93f 100644 --- a/src/client/src/tscParseOpenTSDB.c +++ b/src/client/src/tscParseOpenTSDB.c @@ -781,28 +781,35 @@ static int32_t parseValueFromJSON(cJSON *root, TAOS_SML_KV *pVal, SSmlLinesInfo* } case cJSON_Number: { //convert default JSON Number type to BIGINT/DOUBLE - if (isValidInteger(root->numberstring)) { - pVal->type = TSDB_DATA_TYPE_BIGINT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; - pVal->value = tcalloc(pVal->length, 1); - /* cJSON conversion of legit BIGINT may overflow, - * use original string to do the conversion. - */ - errno = 0; - int64_t val = (int64_t)strtoll(root->numberstring, NULL, 10); - if (errno == ERANGE || !IS_VALID_BIGINT(val)) { - tscError("OTD:0x%"PRIx64" JSON value(%s) cannot fit in type(bigint)", info->id, root->numberstring); - return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; - } - *(int64_t *)(pVal->value) = val; - } else if (isValidFloat(root->numberstring)) { + //if (isValidInteger(root->numberstring)) { + // pVal->type = TSDB_DATA_TYPE_BIGINT; + // pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + // pVal->value = tcalloc(pVal->length, 1); + // /* cJSON conversion of legit BIGINT may overflow, + // * use original string to do the conversion. + // */ + // errno = 0; + // int64_t val = (int64_t)strtoll(root->numberstring, NULL, 10); + // if (errno == ERANGE || !IS_VALID_BIGINT(val)) { + // tscError("OTD:0x%"PRIx64" JSON value(%s) cannot fit in type(bigint)", info->id, root->numberstring); + // return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; + // } + // *(int64_t *)(pVal->value) = val; + //} else if (isValidFloat(root->numberstring)) { + // pVal->type = TSDB_DATA_TYPE_DOUBLE; + // pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + // pVal->value = tcalloc(pVal->length, 1); + // *(double *)(pVal->value) = (double)(root->valuedouble); + //} else { + // return TSDB_CODE_TSC_INVALID_JSON_TYPE; + //} + if (isValidInteger(root->numberstring) || isValidFloat(root->numberstring)) { pVal->type = TSDB_DATA_TYPE_DOUBLE; pVal->length = (int16_t)tDataTypes[pVal->type].bytes; pVal->value = tcalloc(pVal->length, 1); *(double *)(pVal->value) = (double)(root->valuedouble); - } else { - return TSDB_CODE_TSC_INVALID_JSON_TYPE; } + break; } case cJSON_String: { diff --git a/tests/pytest/insert/insertJSONPayload.py b/tests/pytest/insert/insertJSONPayload.py index 6f120e93b53aef5f973d28c06d55e9337371b9eb..7e44ee883a7176a6d3b4ddcd0ad2d6682ec5dc13 100644 --- a/tests/pytest/insert/insertJSONPayload.py +++ b/tests/pytest/insert/insertJSONPayload.py @@ -71,7 +71,7 @@ class TDTestCase: print("schemaless_insert result {}".format(code)) tdSql.query("describe stb0_0") - tdSql.checkData(1, 1, "BIGINT") + tdSql.checkData(1, 1, "DOUBLE") payload = [''' { @@ -220,7 +220,7 @@ class TDTestCase: print("schemaless_insert result {}".format(code)) tdSql.query("describe stb0_8") - tdSql.checkData(2, 1, "BIGINT") + tdSql.checkData(2, 1, "DOUBLE") payload = [''' {