From 8b342156600c90fb213e81dbda4adfbe64b6e067 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Sun, 10 Oct 2021 21:42:15 +0800 Subject: [PATCH] [TD-10532]: schemaless fix test cases --- src/client/src/tscParseOpenTSDB.c | 41 ++++++++++++++---------- tests/pytest/insert/insertJSONPayload.py | 4 +-- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/client/src/tscParseOpenTSDB.c b/src/client/src/tscParseOpenTSDB.c index 8a0b82150c..3739f53ba6 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 6f120e93b5..7e44ee883a 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 = [''' { -- GitLab