提交 8b342156 编写于 作者: G Ganlin Zhao

[TD-10532]<enhance>: schemaless fix test cases

上级 3fadb431
......@@ -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: {
......
......@@ -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 = ['''
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册