“3fb2d7656d2d39941aaa25b29759a7dd9bf81f0e”上不存在“tests/system-test/2-query/sml_TS-3724.py”
未验证 提交 b353b162 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #8196 from taosdata/enhance/TD-10532

Allow schemaless default timestamp precision to be seconds and milliseconds
......@@ -20,6 +20,9 @@
extern "C" {
#endif
#define SML_TIMESTAMP_SECOND_DIGITS 10
#define SML_TIMESTAMP_MILLI_SECOND_DIGITS 13
typedef struct {
char* key;
uint8_t type;
......@@ -41,10 +44,13 @@ typedef struct {
typedef enum {
SML_TIME_STAMP_NOW,
SML_TIME_STAMP_HOURS,
SML_TIME_STAMP_MINUTES,
SML_TIME_STAMP_SECONDS,
SML_TIME_STAMP_MILLI_SECONDS,
SML_TIME_STAMP_MICRO_SECONDS,
SML_TIME_STAMP_NANO_SECONDS
SML_TIME_STAMP_NANO_SECONDS,
SML_TIME_STAMP_NOT_CONFIGURED
} SMLTimeStampType;
typedef enum {
......@@ -55,6 +61,8 @@ typedef enum {
typedef struct {
uint64_t id;
SMLProtocolType protocol;
SMLTimeStampType tsType;
SHashObj* smlDataToSchema;
} SSmlLinesInfo;
......@@ -66,15 +74,18 @@ bool isValidFloat(char *str);
int32_t isValidChildTableName(const char *pTbName, int16_t len, SSmlLinesInfo* info);
bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
uint16_t len, SSmlLinesInfo* info);
uint16_t len, SSmlLinesInfo* info, bool isTag);
int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
uint16_t len, SSmlLinesInfo* info);
void destroySmlDataPoint(TAOS_SML_DATA_POINT* point);
int taos_insert_sml_lines(TAOS* taos, char* lines[], int numLines);
int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines);
int taos_insert_json_payload(TAOS* taos, char* payload);
int taos_insert_sml_lines(TAOS* taos, char* lines[], int numLines,
SMLProtocolType protocol, SMLTimeStampType tsType);
int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines,
SMLProtocolType protocol, SMLTimeStampType tsType);
int taos_insert_json_payload(TAOS* taos, char* payload,
SMLProtocolType protocol, SMLTimeStampType tsType);
#ifdef __cplusplus
......
......@@ -1071,7 +1071,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0);
}
int code = taos_schemaless_insert(taos, c_lines, numLines, SML_LINE_PROTOCOL);
int code = taos_schemaless_insert(taos, c_lines, numLines, SML_LINE_PROTOCOL, "ms");
for (int i = 0; i < numLines; ++i) {
jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i));
......
......@@ -1210,6 +1210,22 @@ bool isValidFloat(char *str) {
return true;
}
static bool isInteger(char *pVal, uint16_t len, bool *has_sign) {
if (len <= 1) {
return false;
}
if (pVal[len - 1] == 'i') {
*has_sign = true;
return true;
}
if (pVal[len - 1] == 'u') {
*has_sign = false;
return true;
}
return false;
}
static bool isTinyInt(char *pVal, uint16_t len) {
if (len <= 2) {
return false;
......@@ -1383,24 +1399,35 @@ static bool isNchar(char *pVal, uint16_t len) {
return false;
}
static bool isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType) {
static bool isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType, SSmlLinesInfo* info) {
if (len == 0) {
return true;
}
if ((len == 1) && pVal[0] == '0') {
*tsType = SML_TIME_STAMP_NOW;
//printf("Type is timestamp(%s)\n", pVal);
return true;
}
if (len < 2) {
return false;
}
//No appendix use usec as default
//Default no appendix
if (isdigit(pVal[len - 1]) && isdigit(pVal[len - 2])) {
*tsType = SML_TIME_STAMP_MICRO_SECONDS;
//printf("Type is timestamp(%s)\n", pVal);
if (info->protocol == SML_LINE_PROTOCOL) {
if (info->tsType != SML_TIME_STAMP_NOT_CONFIGURED) {
*tsType = info->tsType;
} else {
*tsType = SML_TIME_STAMP_NANO_SECONDS;
}
} else if (info->protocol == SML_TELNET_PROTOCOL) {
if (len == SML_TIMESTAMP_SECOND_DIGITS) {
*tsType = SML_TIME_STAMP_SECONDS;
} else if (len == SML_TIMESTAMP_MILLI_SECOND_DIGITS) {
*tsType = SML_TIME_STAMP_MILLI_SECONDS;
} else {
return TSDB_CODE_TSC_INVALID_TIME_STAMP;
}
}
return true;
}
if (pVal[len - 1] == 's') {
switch (pVal[len - 2]) {
case 'm':
......@@ -1528,12 +1555,31 @@ static bool convertStrToNumber(TAOS_SML_KV *pVal, char *str, SSmlLinesInfo* info
}
//len does not include '\0' from value.
bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
uint16_t len, SSmlLinesInfo* info) {
uint16_t len, SSmlLinesInfo* info, bool isTag) {
if (len <= 0) {
return false;
}
//convert tags value to Nchar
if (isTag) {
pVal->type = TSDB_DATA_TYPE_NCHAR;
pVal->length = len;
pVal->value = calloc(pVal->length, 1);
memcpy(pVal->value, value, pVal->length);
return true;
}
//integer number
bool has_sign;
if (isInteger(value, len, &has_sign)) {
pVal->type = has_sign ? TSDB_DATA_TYPE_BIGINT : TSDB_DATA_TYPE_UBIGINT;
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
value[len - 1] = '\0';
if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) {
return false;
}
return true;
}
if (isTinyInt(value, len)) {
pVal->type = TSDB_DATA_TYPE_TINYINT;
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
......@@ -1652,18 +1698,9 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
memcpy(pVal->value, &bVal, pVal->length);
return true;
}
//Handle default(no appendix) interger type as BIGINT
if (isValidInteger(value)) {
pVal->type = TSDB_DATA_TYPE_BIGINT;
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
if (!convertStrToNumber(pVal, value, info)) {
return false;
}
return true;
}
//Handle default(no appendix) floating number type as DOUBLE
if (isValidFloat(value)) {
//Handle default(no appendix) type as DOUBLE
if (isValidInteger(value) || isValidFloat(value)) {
pVal->type = TSDB_DATA_TYPE_DOUBLE;
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
if (!convertStrToNumber(pVal, value, info)) {
......@@ -1675,7 +1712,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
}
static int32_t getTimeStampValue(char *value, uint16_t len,
SMLTimeStampType type, int64_t *ts) {
SMLTimeStampType type, int64_t *ts, SSmlLinesInfo* info) {
if (len >= 2) {
for (int i = 0; i < len - 2; ++i) {
......@@ -1684,11 +1721,9 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
}
}
}
//No appendix or no timestamp given (len = 0)
if (len >= 1 && isdigit(value[len - 1]) && type != SML_TIME_STAMP_NOW) {
type = SML_TIME_STAMP_MICRO_SECONDS;
}
if (len != 0) {
if (len != 0 && type != SML_TIME_STAMP_NOW) {
*ts = (int64_t)strtoll(value, NULL, 10);
} else {
type = SML_TIME_STAMP_NOW;
......@@ -1698,6 +1733,14 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
*ts = taosGetTimestampNs();
break;
}
case SML_TIME_STAMP_HOURS: {
*ts = (int64_t)(*ts * 3600 * 1e9);
break;
}
case SML_TIME_STAMP_MINUTES: {
*ts = (int64_t)(*ts * 60 * 1e9);
break;
}
case SML_TIME_STAMP_SECONDS: {
*ts = (int64_t)(*ts * 1e9);
break;
......@@ -1728,11 +1771,11 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
int64_t tsVal;
strntolower_s(value, value, len);
if (!isTimeStamp(value, len, &type)) {
if (!isTimeStamp(value, len, &type, info)) {
return TSDB_CODE_TSC_INVALID_TIME_STAMP;
}
ret = getTimeStampValue(value, len, type, &tsVal);
ret = getTimeStampValue(value, len, type, &tsVal, info);
if (ret) {
return ret;
}
......@@ -1844,7 +1887,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
bool *is_last_kv, SSmlLinesInfo* info) {
bool *is_last_kv, SSmlLinesInfo* info, bool isTag) {
const char *start, *cur;
char *value = NULL;
uint16_t len = 0;
......@@ -1855,7 +1898,12 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
if ((*cur == ',' || *cur == ' ' || *cur == '\0') && *(cur - 1) != '\\') {
//unescaped ' ' or '\0' indicates end of value
*is_last_kv = (*cur == ' ' || *cur == '\0') ? true : false;
break;
if (*cur == ' ' && *(cur + 1) == ' ') {
cur++;
continue;
} else {
break;
}
}
//Escape special character
if (*cur == '\\') {
......@@ -1868,7 +1916,7 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
value = calloc(len + 1, 1);
memcpy(value, start, len);
value[len] = '\0';
if (!convertSmlValueType(pKV, value, len, info)) {
if (!convertSmlValueType(pKV, value, len, info, isTag)) {
tscError("SML:0x%"PRIx64" Failed to convert sml value string(%s) to any type",
info->id, value);
//free previous alocated key field
......@@ -1913,7 +1961,13 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
break;
}
if (*cur == ' ' && *(cur - 1) != '\\') {
break;
if (*(cur + 1) != ' ') {
break;
}
else {
cur++;
continue;
}
}
//Comma, Space, Backslash needs to be escaped if any
if (*cur == '\\') {
......@@ -1974,13 +2028,12 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
tscError("SML:0x%"PRIx64" Unable to parse key", info->id);
goto error;
}
ret = parseSmlValue(pkv, &cur, &is_last_kv, info);
ret = parseSmlValue(pkv, &cur, &is_last_kv, info, !isField);
if (ret) {
tscError("SML:0x%"PRIx64" Unable to parse value", info->id);
goto error;
}
if (!isField &&
(strcasecmp(pkv->key, "ID") == 0) && pkv->type == TSDB_DATA_TYPE_BINARY) {
if (!isField && (strcasecmp(pkv->key, "ID") == 0)) {
ret = isValidChildTableName(pkv->value, pkv->length, info);
if (ret) {
goto error;
......@@ -2134,11 +2187,13 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile
return TSDB_CODE_SUCCESS;
}
int taos_insert_lines(TAOS* taos, char* lines[], int numLines) {
int taos_insert_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType) {
int32_t code = 0;
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
info->id = genLinesSmlId();
info->tsType = tsType;
info->protocol = protocol;
if (numLines <= 0 || numLines > 65536) {
tscError("SML:0x%"PRIx64" taos_insert_lines numLines should be between 1 and 65536. numLines: %d", info->id, numLines);
......@@ -2191,6 +2246,52 @@ cleanup:
return code;
}
int32_t convertPrecisionStrType(char* precision, SMLTimeStampType *tsType) {
if (precision == NULL) {
*tsType = SML_TIME_STAMP_NOT_CONFIGURED;
return TSDB_CODE_SUCCESS;
}
if (strcmp(precision, "μ") == 0) {
*tsType = SML_TIME_STAMP_MICRO_SECONDS;
return TSDB_CODE_SUCCESS;
}
int32_t len = (int32_t)strlen(precision);
if (len == 1) {
switch (precision[0]) {
case 'u':
*tsType = SML_TIME_STAMP_MICRO_SECONDS;
break;
case 's':
*tsType = SML_TIME_STAMP_SECONDS;
break;
case 'm':
*tsType = SML_TIME_STAMP_MINUTES;
break;
case 'h':
*tsType = SML_TIME_STAMP_HOURS;
break;
default:
return TSDB_CODE_TSC_INVALID_PRECISION_TYPE;
}
} else if (len == 2 && precision[1] == 's') {
switch (precision[0]) {
case 'm':
*tsType = SML_TIME_STAMP_MILLI_SECONDS;
break;
case 'n':
*tsType = SML_TIME_STAMP_NANO_SECONDS;
break;
default:
return TSDB_CODE_TSC_INVALID_PRECISION_TYPE;
}
} else {
return TSDB_CODE_TSC_INVALID_PRECISION_TYPE;
}
return TSDB_CODE_SUCCESS;
}
/**
* taos_schemaless_insert() parse and insert data points into database according to
* different protocol.
......@@ -2212,17 +2313,26 @@ cleanup:
*
*/
int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol) {
int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, char* timePrecision) {
int code;
SMLTimeStampType tsType;
if (protocol == SML_LINE_PROTOCOL) {
code = convertPrecisionStrType(timePrecision, &tsType);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
}
switch (protocol) {
case SML_LINE_PROTOCOL:
code = taos_insert_lines(taos, lines, numLines);
code = taos_insert_lines(taos, lines, numLines, protocol, tsType);
break;
case SML_TELNET_PROTOCOL:
code = taos_insert_telnet_lines(taos, lines, numLines);
code = taos_insert_telnet_lines(taos, lines, numLines, protocol, tsType);
break;
case SML_JSON_PROTOCOL:
code = taos_insert_json_payload(taos, *lines);
code = taos_insert_json_payload(taos, *lines, protocol, tsType);
break;
default:
code = TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE;
......
......@@ -55,7 +55,12 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index,
}
if (*cur == ' ') {
break;
if (*(cur + 1) != ' ') {
break;
} else {
cur++;
continue;
}
}
pSml->stableName[len] = *cur;
......@@ -91,7 +96,12 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
while(*cur != '\0') {
if (*cur == ' ') {
break;
if (*(cur + 1) != ' ') {
break;
} else {
cur++;
continue;
}
}
cur++;
len++;
......@@ -135,7 +145,14 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
while(*cur != '\0') {
if (*cur == ' ') {
break;
if (*cur == ' ') {
if (*(cur + 1) != ' ') {
break;
} else {
cur++;
continue;
}
}
}
cur++;
len++;
......@@ -148,7 +165,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
}
if (!convertSmlValueType(pVal, value, len, info)) {
if (!convertSmlValueType(pVal, value, len, info, false)) {
tscError("OTD:0x%"PRIx64" Failed to convert metric value string(%s) to any type",
info->id, value);
tfree(value);
......@@ -219,7 +236,12 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
if (*cur == ' ' || *cur == '\0') {
// '\0' indicates end of value
*is_last_kv = (*cur == '\0') ? true : false;
break;
if (*cur == ' ' && *(cur + 1) == ' ') {
cur++;
continue;
} else {
break;
}
}
cur++;
len++;
......@@ -233,7 +255,7 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
value = tcalloc(len + 1, 1);
memcpy(value, start, len);
value[len] = '\0';
if (!convertSmlValueType(pKV, value, len, info)) {
if (!convertSmlValueType(pKV, value, len, info, true)) {
tscError("OTD:0x%"PRIx64" Failed to convert sml value string(%s) to any type",
info->id, value);
//free previous alocated key field
......@@ -270,7 +292,7 @@ static int32_t parseTelnetTagKvs(TAOS_SML_KV **pKVs, int *num_kvs,
tscError("OTD:0x%"PRIx64" Unable to parse value", info->id);
return ret;
}
if ((strcasecmp(pkv->key, "ID") == 0) && pkv->type == TSDB_DATA_TYPE_BINARY) {
if ((strcasecmp(pkv->key, "ID") == 0)) {
ret = isValidChildTableName(pkv->value, pkv->length, info);
if (ret) {
return ret;
......@@ -367,11 +389,13 @@ static int32_t tscParseTelnetLines(char* lines[], int numLines, SArray* points,
return TSDB_CODE_SUCCESS;
}
int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines) {
int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType) {
int32_t code = 0;
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
info->id = genUID();
info->tsType = tsType;
info->protocol = protocol;
if (numLines <= 0 || numLines > 65536) {
tscError("OTD:0x%"PRIx64" taos_insert_telnet_lines numLines should be between 1 and 65536. numLines: %d", info->id, numLines);
......@@ -529,7 +553,14 @@ static int32_t parseTimestampFromJSON(cJSON *root, TAOS_SML_KV **pTS, int *num_k
tsVal = taosGetTimestampNs();
} else {
tsVal = strtoll(timestamp->numberstring, NULL, 10);
tsVal = convertTimePrecision(tsVal, TSDB_TIME_PRECISION_MICRO, TSDB_TIME_PRECISION_NANO);
size_t tsLen = strlen(timestamp->numberstring);
if (tsLen == SML_TIMESTAMP_SECOND_DIGITS) {
tsVal = (int64_t)(tsVal * 1e9);
} else if (tsLen == SML_TIMESTAMP_MILLI_SECOND_DIGITS) {
tsVal = convertTimePrecision(tsVal, TSDB_TIME_PRECISION_MILLI, TSDB_TIME_PRECISION_NANO);
} else {
return TSDB_CODE_TSC_INVALID_TIME_STAMP;
}
}
} else if (cJSON_IsObject(timestamp)) {
int32_t ret = parseTimestampFromJSONObj(timestamp, &tsVal, info);
......@@ -738,28 +769,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: {
......@@ -831,6 +869,10 @@ static int32_t parseTagsFromJSON(cJSON *root, TAOS_SML_KV **pKVs, int *num_kvs,
//only pick up the first ID value as child table name
cJSON *id = cJSON_GetObjectItem(tags, "ID");
if (id != NULL) {
if (!cJSON_IsString(id)) {
tscError("OTD:0x%"PRIx64" ID must be JSON string", info->id);
return TSDB_CODE_TSC_INVALID_JSON;
}
size_t idLen = strlen(id->valuestring);
ret = isValidChildTableName(id->valuestring, (int16_t)idLen, info);
if (ret != TSDB_CODE_SUCCESS) {
......@@ -965,7 +1007,7 @@ static int32_t tscParseMultiJSONPayload(char* payload, SArray* points, SSmlLines
for (int32_t i = 0; i < payloadNum; ++i) {
TAOS_SML_DATA_POINT point = {0};
cJSON *dataPoint = (payloadNum == 1) ? root : cJSON_GetArrayItem(root, i);
cJSON *dataPoint = (payloadNum == 1 && cJSON_IsObject(root)) ? root : cJSON_GetArrayItem(root, i);
ret = tscParseJSONPayload(dataPoint, &point, info);
if (ret != TSDB_CODE_SUCCESS) {
......@@ -983,11 +1025,13 @@ PARSE_JSON_OVER:
return ret;
}
int taos_insert_json_payload(TAOS* taos, char* payload) {
int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, SMLTimeStampType tsType) {
int32_t code = 0;
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
info->id = genUID();
info->tsType = tsType;
info->protocol = protocol;
if (payload == NULL) {
tscError("OTD:0x%"PRIx64" taos_insert_json_payload payload is NULL", info->id);
......
......@@ -401,16 +401,16 @@ conn.select_db(dbname)
lines = [
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000ns',
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns',
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns',
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000',
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000',
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0, "ns")
print("inserted")
lines = [
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns',
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000',
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0, "ns")
result = conn.query("show tables")
for row in result:
......
......@@ -7,12 +7,12 @@ conn.execute("create database if not exists %s precision 'us'" % dbname)
conn.select_db(dbname)
lines = [
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000ns',
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000',
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0, "ns")
print("inserted")
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0, "ns")
result = conn.query("show tables")
for row in result:
......
......@@ -402,17 +402,17 @@ conn.exec("create database if not exists %s precision 'us'" % dbname)
conn.select_db(dbname)
lines = [
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000ns',
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns',
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns',
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000',
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000',
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000',
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0, "ns")
print("inserted")
lines = [
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns',
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000',
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0, "ns")
result = conn.query("show tables")
for row in result:
......
......@@ -817,13 +817,15 @@ except AttributeError:
def taos_schemaless_insert(connection, lines, protocol):
def taos_schemaless_insert(connection, lines, protocol, precision):
# type: (c_void_p, list[str] | tuple(str)) -> None
num_of_lines = len(lines)
lines = (c_char_p(line.encode("utf-8")) for line in lines)
lines_type = ctypes.c_char_p * num_of_lines
p_lines = lines_type(*lines)
errno = _libtaos.taos_schemaless_insert(connection, p_lines, num_of_lines, protocol)
if precision != None:
precision = c_char_p(precision.encode("utf-8"))
errno = _libtaos.taos_schemaless_insert(connection, p_lines, num_of_lines, protocol, precision)
if errno != 0:
raise SchemalessError("schemaless insert error", errno)
......
......@@ -117,7 +117,7 @@ class TaosConnection(object):
stream = taos_open_stream(self._conn, sql, callback, stime, param, callback2)
return TaosStream(stream)
def schemaless_insert(self, lines, protocol):
def schemaless_insert(self, lines, protocol, precision):
# type: (list[str]) -> None
"""
1.Line protocol and schemaless support
......@@ -132,7 +132,7 @@ class TaosConnection(object):
lines = [
'ste,t2=5,t3=L"ste" c1=true,c2=4,c3="string" 1626056811855516532',
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0, "ns")
```
2.OpenTSDB telnet style API format support
......@@ -145,7 +145,7 @@ class TaosConnection(object):
lines = [
'cpu_load 1626056811855516532ns 2.0f32 id="tb1",host="host0",interface="eth0"',
]
conn.schemaless_insert(lines, 1)
conn.schemaless_insert(lines, 1, None)
3.OpenTSDB HTTP JSON format support
......@@ -168,10 +168,10 @@ class TaosConnection(object):
}
}
''']
conn.schemaless_insert(lines, 2)
conn.schemaless_insert(lines, 2, None)
"""
return taos_schemaless_insert(self._conn, lines, protocol)
return taos_schemaless_insert(self._conn, lines, protocol, precision)
def cursor(self):
......
......@@ -23,17 +23,17 @@ def test_schemaless_insert(conn):
conn.select_db(dbname)
lines = [
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000ns',
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns',
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns',
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000',
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000',
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000',
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0, "ns")
print("inserted")
lines = [
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns',
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000',
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0, "ns")
print("inserted")
result = conn.query("select * from st")
print(*result.fields)
......
......@@ -187,7 +187,7 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList);
DLL_EXPORT int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol);
DLL_EXPORT int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, char* precision);
#ifdef __cplusplus
}
......
......@@ -113,6 +113,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TSC_INVALID_JSON_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0223) //"Invalid JSON configuration")
#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0224) //"Value out of range")
#define TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x0225) //"Invalid line protocol type")
#define TSDB_CODE_TSC_INVALID_PRECISION_TYPE TAOS_DEF_ERROR_CODE(0, 0x0226) //"Invalid timestamp precision type")
// mnode
#define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed")
......
......@@ -121,6 +121,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_TYPE, "Invalid JSON data typ
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_CONFIG, "Invalid JSON configuration")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_VALUE_OUT_OF_RANGE, "Value out of range")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE, "Invalid line protocol type")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_PRECISION_TYPE, "Invalid timestamp precision type")
// mnode
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, "Message not processed")
......
......@@ -969,51 +969,51 @@ int32_t verify_schema_less(TAOS* taos) {
int code = 0;
char* lines[] = {
"st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns",
"ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532ns",
"st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000ns",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532ns",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000ns"
"st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000",
"ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532",
"st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000"
};
code = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), 0);
code = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), 0, "ns");
char* lines2[] = {
"stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns"
"stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000"
};
code = taos_schemaless_insert(taos, &lines2[0], 1, 0);
code = taos_schemaless_insert(taos, &lines2[1], 1, 0);
code = taos_schemaless_insert(taos, &lines2[0], 1, 0, "ns");
code = taos_schemaless_insert(taos, &lines2[1], 1, 0, "ns");
char* lines3[] = {
"sth,t1=4i64,t2=5f64,t4=5f64,ID=\"childtable\" c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641ms",
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654ms"
"sth,t1=4i64,t2=5f64,t4=5f64,ID=childTable c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641",
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654"
};
code = taos_schemaless_insert(taos, lines3, 2, 0);
code = taos_schemaless_insert(taos, lines3, 2, 0, "ms");
char* lines4[] = {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns",
"dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns"
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532"
};
code = taos_schemaless_insert(taos, lines4, 2, 0);
code = taos_schemaless_insert(taos, lines4, 2, 0, "ns");
char* lines5[] = {
"zqlbgs,id=\"zqlbgs_39302_21680\",t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000ns",
"zqlbgs,t9=f,id=\"zqlbgs_39302_21680\",t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\",t10=L\"ncharTagValue\" c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64,c11=L\"ncharColValue\" 1626006833639000000ns"
"zqlbgs,id=\"zqlbgs_39302_21680\",t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
"zqlbgs,t9=f,id=\"zqlbgs_39302_21680\",t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\",t10=L\"ncharTagValue\" c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64,c11=L\"ncharColValue\" 1626006833639000000"
};
code = taos_schemaless_insert(taos, &lines5[0], 1, 0);
code = taos_schemaless_insert(taos, &lines5[1], 1, 0);
code = taos_schemaless_insert(taos, &lines5[0], 1, 0, "ns");
code = taos_schemaless_insert(taos, &lines5[1], 1, 0, "ns");
char* lines6[] = {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns",
"dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns"
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532"
};
code = taos_schemaless_insert(taos, lines6, 2, 0);
code = taos_schemaless_insert(taos, lines6, 2, 0, "ns");
return (code);
}
......
......@@ -79,7 +79,7 @@ int main(int argc, char* argv[]) {
printf("%s\n", "begin taos_schemaless_insert");
int64_t begin = getTimeInUs();
int32_t code = taos_schemaless_insert(taos, lines, numSuperTables * numChildTables * numRowsPerChildTable, 0);
int32_t code = taos_schemaless_insert(taos, lines, numSuperTables * numChildTables * numRowsPerChildTable, 0, "ms");
int64_t end = getTimeInUs();
printf("code: %d, %s. time used: %"PRId64"\n", code, tstrerror(code), end-begin);
......
......@@ -36,7 +36,7 @@ class TDTestCase:
payload = ['''
{
"metric": "`.stb.0.`",
"timestamp": 1626006833610123,
"timestamp": 1626006833610,
"value": 10,
"tags": {
"t1": true,
......@@ -46,7 +46,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe `.stb.0.`")
......@@ -57,7 +57,7 @@ class TDTestCase:
payload = ['''
{
"metric": "stb0_0",
"timestamp": 1626006833610123,
"timestamp": 1626006833610,
"value": 10,
"tags": {
"t1": true,
......@@ -67,16 +67,16 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_0")
tdSql.checkData(1, 1, "BIGINT")
tdSql.checkData(1, 1, "DOUBLE")
payload = ['''
{
"metric": "stb0_1",
"timestamp": 1626006833610123,
"timestamp": 1626006833610,
"value": true,
"tags": {
"t1": true,
......@@ -86,7 +86,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_1")
......@@ -95,7 +95,7 @@ class TDTestCase:
payload = ['''
{
"metric": "stb0_2",
"timestamp": 1626006833610123,
"timestamp": 1626006833610,
"value": false,
"tags": {
"t1": true,
......@@ -105,7 +105,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_2")
......@@ -114,7 +114,7 @@ class TDTestCase:
payload = ['''
{
"metric": "stb0_3",
"timestamp": 1626006833610123,
"timestamp": 1626006833610,
"value": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>",
"tags": {
"t1": true,
......@@ -124,7 +124,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_3")
......@@ -133,7 +133,7 @@ class TDTestCase:
payload = ['''
{
"metric": "stb0_4",
"timestamp": 1626006833610123,
"timestamp": 1626006833610,
"value": 3.14,
"tags": {
"t1": true,
......@@ -143,7 +143,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_4")
......@@ -152,7 +152,7 @@ class TDTestCase:
payload = ['''
{
"metric": "stb0_5",
"timestamp": 1626006833610123,
"timestamp": 1626006833610,
"value": 3.14E-2,
"tags": {
"t1": true,
......@@ -162,7 +162,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_5")
......@@ -184,9 +184,25 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
### timestamp 10 digits second ###
payload = ['''
{
"metric": "stb0_7",
"timestamp": 1626006833,
"value": 123,
"tags": {
"t1": true,
"t2": false,
"t3": 10,
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
print("============= step3 : test tags ================")
### Default tag numeric types ###
......@@ -200,11 +216,11 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_8")
tdSql.checkData(2, 1, "BIGINT")
tdSql.checkData(2, 1, "DOUBLE")
payload = ['''
{
......@@ -216,7 +232,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_9")
......@@ -232,7 +248,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_10")
......@@ -258,7 +274,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_0")
......@@ -281,7 +297,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_1")
......@@ -304,7 +320,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_2")
......@@ -327,7 +343,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_3")
......@@ -351,7 +367,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
### metric value ###
......@@ -374,7 +390,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_0")
......@@ -399,7 +415,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_1")
......@@ -424,7 +440,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_2")
......@@ -449,7 +465,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_3")
......@@ -474,7 +490,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_4")
......@@ -499,7 +515,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_5")
......@@ -524,7 +540,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_6")
......@@ -549,7 +565,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_7")
......@@ -574,7 +590,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_8")
......@@ -633,7 +649,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2)
code = self._conn.schemaless_insert(payload, 2, None)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb3_0")
......
......@@ -39,7 +39,7 @@ class TDTestCase:
"`.stb0.3.` 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"",
]
code = self._conn.schemaless_insert(lines0, 1)
code = self._conn.schemaless_insert(lines0, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("show stables")
......@@ -63,16 +63,17 @@ class TDTestCase:
"stb1 1626006833s 1i8 host=\"host0\"",
"stb1 1626006833639000000ns 2i8 host=\"host0\"",
"stb1 1626006833640000us 3i8 host=\"host0\"",
"stb1 1626006833641123 4i8 host=\"host0\"",
"stb1 1626006833651ms 5i8 host=\"host0\"",
"stb1 0 6i8 host=\"host0\"",
"stb1 1626006833641 4i8 host=\"host0\"",
"stb1 1626006834 5i8 host=\"host0\"",
"stb1 1626006833651ms 6i8 host=\"host0\"",
"stb1 0 7i8 host=\"host0\"",
]
code = self._conn.schemaless_insert(lines1, 1)
code = self._conn.schemaless_insert(lines1, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb1")
tdSql.checkRows(6)
tdSql.checkRows(7)
### metric value ###
print("============= step3 : test metric value ================")
......@@ -82,7 +83,7 @@ class TDTestCase:
"stb2_0 1626006833651ms -127i8 host=\"host0\"",
"stb2_0 1626006833652ms 127i8 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_0, 1)
code = self._conn.schemaless_insert(lines2_0, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_0")
......@@ -97,7 +98,7 @@ class TDTestCase:
"stb2_1 1626006833651ms -32767i16 host=\"host0\"",
"stb2_1 1626006833652ms 32767i16 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_1, 1)
code = self._conn.schemaless_insert(lines2_1, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_1")
......@@ -113,7 +114,7 @@ class TDTestCase:
"stb2_2 1626006833652ms 2147483647i32 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_2, 1)
code = self._conn.schemaless_insert(lines2_2, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_2")
......@@ -126,15 +127,14 @@ class TDTestCase:
#bigint
lines2_3 = [
"stb2_3 1626006833651ms -9223372036854775807i64 host=\"host0\"",
"stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"",
"stb2_3 1626006833662ms 9223372036854775807 host=\"host0\""
"stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_3, 1)
code = self._conn.schemaless_insert(lines2_3, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_3")
tdSql.checkRows(3)
tdSql.checkRows(2)
tdSql.query("describe stb2_3")
tdSql.checkRows(3)
......@@ -154,7 +154,7 @@ class TDTestCase:
"stb2_4 1626006833710ms -3.4E38f32 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_4, 1)
code = self._conn.schemaless_insert(lines2_4, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_4")
......@@ -176,10 +176,10 @@ class TDTestCase:
"stb2_5 1626006833680ms -3.4e-2f64 host=\"host0\"",
"stb2_5 1626006833690ms 1.7E308f64 host=\"host0\"",
"stb2_5 1626006833700ms -1.7E308f64 host=\"host0\"",
"stb2_5 1626006833710ms 3.15 host=\"host0\""
"stb2_5 1626006833710ms 3 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_5, 1)
code = self._conn.schemaless_insert(lines2_5, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_5")
......@@ -203,7 +203,7 @@ class TDTestCase:
"stb2_6 1626006833700ms FALSE host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_6, 1)
code = self._conn.schemaless_insert(lines2_6, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_6")
......@@ -220,7 +220,7 @@ class TDTestCase:
"stb2_7 1626006833630ms \"binary_val.()[]{}<>\" host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_7, 1)
code = self._conn.schemaless_insert(lines2_7, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_7")
......@@ -236,7 +236,7 @@ class TDTestCase:
"stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_8, 1)
code = self._conn.schemaless_insert(lines2_8, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_8")
......@@ -254,7 +254,7 @@ class TDTestCase:
"stb3_0 1626006833610ms 2 t1=-127i8 t2=-32767i16 t3=-2147483647i32 t4=-9223372036854775807i64 t5=-3.4E38f32 t6=-1.7E308f64 t7=false t8=\"binary_val_2\" t9=L\"标签值2\""
]
code = self._conn.schemaless_insert(lines3_0, 1)
code = self._conn.schemaless_insert(lines3_0, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb3_0")
......@@ -263,28 +263,28 @@ class TDTestCase:
tdSql.query("describe stb3_0")
tdSql.checkRows(11)
tdSql.checkData(2, 1, "TINYINT")
tdSql.checkData(2, 1, "NCHAR")
tdSql.checkData(2, 3, "TAG")
tdSql.checkData(3, 1, "SMALLINT")
tdSql.checkData(3, 1, "NCHAR")
tdSql.checkData(3, 3, "TAG")
tdSql.checkData(4, 1, "INT")
tdSql.checkData(4, 1, "NCHAR")
tdSql.checkData(4, 3, "TAG")
tdSql.checkData(5, 1, "BIGINT")
tdSql.checkData(5, 1, "NCHAR")
tdSql.checkData(5, 3, "TAG")
tdSql.checkData(6, 1, "FLOAT")
tdSql.checkData(6, 1, "NCHAR")
tdSql.checkData(6, 3, "TAG")
tdSql.checkData(7, 1, "DOUBLE")
tdSql.checkData(7, 1, "NCHAR")
tdSql.checkData(7, 3, "TAG")
tdSql.checkData(8, 1, "BOOL")
tdSql.checkData(8, 1, "NCHAR")
tdSql.checkData(8, 3, "TAG")
tdSql.checkData(9, 1, "BINARY")
tdSql.checkData(9, 1, "NCHAR")
tdSql.checkData(9, 3, "TAG")
tdSql.checkData(10, 1, "NCHAR")
......@@ -293,12 +293,12 @@ class TDTestCase:
#tag ID as child table name
lines3_1 = [
"stb3_1 1626006833610ms 1 id=\"child_table1\" host=\"host1\"",
"stb3_1 1626006833610ms 2 host=\"host2\" iD=\"child_table2\"",
"stb3_1 1626006833610ms 3 ID=\"child_table3\" host=\"host3\""
"stb3_1 1626006833610ms 1 id=child_table1 host=host1",
"stb3_1 1626006833610ms 2 host=host2 iD=child_table2",
"stb3_1 1626006833610ms 3 ID=child_table3 host=host3"
]
code = self._conn.schemaless_insert(lines3_1, 1)
code = self._conn.schemaless_insert(lines3_1, 1, None)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb3_1")
......
......@@ -31,28 +31,28 @@ class TDTestCase:
tdSql.execute('create stable ste(ts timestamp, f int) tags(t1 bigint)')
lines = [ "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns",
"ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532ns",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns",
"st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000ns",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532ns",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000ns"
lines = [ "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000",
"ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000",
"st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000"
]
code = self._conn.schemaless_insert(lines, 0)
code = self._conn.schemaless_insert(lines, 0, "ns")
print("schemaless_insert result {}".format(code))
lines2 = [ "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns"
lines2 = [ "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000"
]
code = self._conn.schemaless_insert([ lines2[0] ], 0)
code = self._conn.schemaless_insert([ lines2[0] ], 0, "ns")
print("schemaless_insert result {}".format(code))
self._conn.schemaless_insert([ lines2[1] ], 0)
self._conn.schemaless_insert([ lines2[1] ], 0, "ns")
print("schemaless_insert result {}".format(code))
tdSql.query("select * from st")
......@@ -74,9 +74,9 @@ class TDTestCase:
tdSql.checkData(2, 2, 14)
self._conn.schemaless_insert([
"sth,t1=4i64,t2=5f64,t4=5f64,ID=\"childtable\" c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641ms",
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654ms"
], 0)
"sth,t1=4i64,t2=5f64,t4=5f64,ID=childtable c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641",
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654"
], 0, "ms")
tdSql.execute('reset query cache')
tdSql.query('select tbname, * from sth')
......
......@@ -26,7 +26,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb0_1 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"",
"stb0_2 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"",
};
code = taos_schemaless_insert(taos, lines0, 3, 1);
code = taos_schemaless_insert(taos, lines0, 3, 1, NULL);
if (code) {
printf("lines0 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -36,11 +36,12 @@ void verify_telnet_insert(TAOS* taos) {
"stb1 1626006833s 1i8 host=\"host0\"",
"stb1 1626006833639000000ns 2i8 host=\"host0\"",
"stb1 1626006833640000us 3i8 host=\"host0\"",
"stb1 1626006833641123 4i8 host=\"host0\"",
"stb1 1626006833651ms 5i8 host=\"host0\"",
"stb1 0 6i8 host=\"host0\"",
"stb1 1626006833641 4i8 host=\"host0\"",
"stb1 1626006832 5i8 host=\"host0\"",
"stb1 1626006833651ms 6i8 host=\"host0\"",
"stb1 0 7i8 host=\"host0\"",
};
code = taos_schemaless_insert(taos, lines1, 6, 1);
code = taos_schemaless_insert(taos, lines1, 7, 1, NULL);
if (code) {
printf("lines1 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -51,7 +52,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_0 1626006833651ms -127i8 host=\"host0\"",
"stb2_0 1626006833652ms 127i8 host=\"host0\""
};
code = taos_schemaless_insert(taos, lines2_0, 2, 1);
code = taos_schemaless_insert(taos, lines2_0, 2, 1, NULL);
if (code) {
printf("lines2_0 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -61,7 +62,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_1 1626006833651ms -32767i16 host=\"host0\"",
"stb2_1 1626006833652ms 32767i16 host=\"host0\""
};
code = taos_schemaless_insert(taos, lines2_1, 2, 1);
code = taos_schemaless_insert(taos, lines2_1, 2, 1, NULL);
if (code) {
printf("lines2_1 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -71,7 +72,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_2 1626006833651ms -2147483647i32 host=\"host0\"",
"stb2_2 1626006833652ms 2147483647i32 host=\"host0\""
};
code = taos_schemaless_insert(taos, lines2_2, 2, 1);
code = taos_schemaless_insert(taos, lines2_2, 2, 1, NULL);
if (code) {
printf("lines2_2 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -79,10 +80,9 @@ void verify_telnet_insert(TAOS* taos) {
//bigint
char* lines2_3[] = {
"stb2_3 1626006833651ms -9223372036854775807i64 host=\"host0\"",
"stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"",
"stb2_3 1626006833662ms 9223372036854775807 host=\"host0\""
"stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\""
};
code = taos_schemaless_insert(taos, lines2_3, 3, 1);
code = taos_schemaless_insert(taos, lines2_3, 2, 1, NULL);
if (code) {
printf("lines2_3 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -100,7 +100,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_4 1626006833700ms 3.4E38f32 host=\"host0\"",
"stb2_4 1626006833710ms -3.4E38f32 host=\"host0\""
};
code = taos_schemaless_insert(taos, lines2_4, 10, 1);
code = taos_schemaless_insert(taos, lines2_4, 10, 1, NULL);
if (code) {
printf("lines2_4 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -119,7 +119,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_5 1626006833700ms -1.7E308f64 host=\"host0\"",
"stb2_5 1626006833710ms 3.15 host=\"host0\""
};
code = taos_schemaless_insert(taos, lines2_5, 11, 1);
code = taos_schemaless_insert(taos, lines2_5, 11, 1, NULL);
if (code) {
printf("lines2_5 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -137,7 +137,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_6 1626006833690ms False host=\"host0\"",
"stb2_6 1626006833700ms FALSE host=\"host0\""
};
code = taos_schemaless_insert(taos, lines2_6, 10, 1);
code = taos_schemaless_insert(taos, lines2_6, 10, 1, NULL);
if (code) {
printf("lines2_6 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -148,7 +148,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_7 1626006833620ms \"binary_val.:;,./?|+-=\" host=\"host0\"",
"stb2_7 1626006833630ms \"binary_val.()[]{}<>\" host=\"host0\""
};
code = taos_schemaless_insert(taos, lines2_7, 3, 1);
code = taos_schemaless_insert(taos, lines2_7, 3, 1, NULL);
if (code) {
printf("lines2_7 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -158,7 +158,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_8 1626006833610ms L\"nchar_val数值一\" host=\"host0\"",
"stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\""
};
code = taos_schemaless_insert(taos, lines2_8, 2, 1);
code = taos_schemaless_insert(taos, lines2_8, 2, 1, NULL);
if (code) {
printf("lines2_8 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -169,18 +169,18 @@ void verify_telnet_insert(TAOS* taos) {
"stb3_0 1626006833610ms 1 t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=3.4E38f32 t6=1.7E308f64 t7=true t8=\"binary_val_1\" t9=L\"标签值1\"",
"stb3_0 1626006833610ms 2 t1=-127i8 t2=-32767i16 t3=-2147483647i32 t4=-9223372036854775807i64 t5=-3.4E38f32 t6=-1.7E308f64 t7=false t8=\"binary_val_2\" t9=L\"标签值2\""
};
code = taos_schemaless_insert(taos, lines3_0, 2, 1);
code = taos_schemaless_insert(taos, lines3_0, 2, 1, NULL);
if (code) {
printf("lines3_0 code: %d, %s.\n", code, tstrerror(code));
}
//tag ID as child table name
char* lines3_1[] = {
"stb3_1 1626006833610ms 1 id=\"child_table1\" host=\"host1\"",
"stb3_1 1626006833610ms 2 host=\"host2\" iD=\"child_table2\"",
"stb3_1 1626006833610ms 3 ID=\"child_table3\" host=\"host3\""
"stb3_1 1626006833610ms 1 id=child_table1 host=host1",
"stb3_1 1626006833610ms 2 host=host2 iD=child_table2",
"stb3_1 1626006833610ms 3 ID=child_table3 host=host3"
};
code = taos_schemaless_insert(taos, lines3_1, 3, 1);
code = taos_schemaless_insert(taos, lines3_1, 3, 1, NULL);
if (code) {
printf("lines3_1 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -204,7 +204,7 @@ void verify_json_insert(TAOS* taos) {
char *message[] = {
"{ \
\"metric\":\"cpu_load_0\", \
\"timestamp\": 1626006833610123, \
\"timestamp\": 1626006833610, \
\"value\": 55.5, \
\"tags\": \
{ \
......@@ -214,7 +214,7 @@ void verify_json_insert(TAOS* taos) {
} \
}"};
code = taos_schemaless_insert(taos, message, 0, 2);
code = taos_schemaless_insert(taos, message, 0, 2, NULL);
if (code) {
printf("payload_0 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -223,7 +223,7 @@ void verify_json_insert(TAOS* taos) {
"[ \
{ \
\"metric\":\"cpu_load_1\", \
\"timestamp\": 1626006833610123, \
\"timestamp\": 1626006833610, \
\"value\": 55.5, \
\"tags\": \
{ \
......@@ -234,7 +234,7 @@ void verify_json_insert(TAOS* taos) {
}, \
{ \
\"metric\":\"cpu_load_2\", \
\"timestamp\": 1626006833610123, \
\"timestamp\": 1626006833610, \
\"value\": 55.5, \
\"tags\": \
{ \
......@@ -245,7 +245,7 @@ void verify_json_insert(TAOS* taos) {
} \
]"};
code = taos_schemaless_insert(taos, message1, 0, 2);
code = taos_schemaless_insert(taos, message1, 0, 2, NULL);
if (code) {
printf("payload_1 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -256,8 +256,8 @@ void verify_json_insert(TAOS* taos) {
\"metric\":\"cpu_load_3\", \
\"timestamp\": \
{ \
\"value\": 1626006833610123, \
\"type\": \"us\" \
\"value\": 1626006833610, \
\"type\": \"ms\" \
}, \
\"value\": \
{ \
......@@ -286,7 +286,7 @@ void verify_json_insert(TAOS* taos) {
}, \
{ \
\"metric\":\"cpu_load_4\", \
\"timestamp\": 1626006833610123, \
\"timestamp\": 1626006833610, \
\"value\": 66.6, \
\"tags\": \
{ \
......@@ -296,7 +296,7 @@ void verify_json_insert(TAOS* taos) {
} \
} \
]"};
code = taos_schemaless_insert(taos, message2, 0, 2);
code = taos_schemaless_insert(taos, message2, 0, 2, NULL);
if (code) {
printf("payload_2 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -309,7 +309,7 @@ void verify_json_insert(TAOS* taos) {
//number
payload = cJSON_CreateObject();
cJSON_AddStringToObject(payload, "metric", "stb0_0");
cJSON_AddNumberToObject(payload, "timestamp", 1626006833610123);
cJSON_AddNumberToObject(payload, "timestamp", 1626006833610);
cJSON_AddNumberToObject(payload, "value", 10);
tags = cJSON_CreateObject();
cJSON_AddTrueToObject(tags, "t1");
......@@ -320,7 +320,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload0_0 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -330,7 +330,7 @@ void verify_json_insert(TAOS* taos) {
//true
payload = cJSON_CreateObject();
cJSON_AddStringToObject(payload, "metric", "stb0_1");
cJSON_AddNumberToObject(payload, "timestamp", 1626006833610123);
cJSON_AddNumberToObject(payload, "timestamp", 1626006833610);
cJSON_AddTrueToObject(payload, "value");
tags = cJSON_CreateObject();
cJSON_AddTrueToObject(tags, "t1");
......@@ -341,7 +341,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload0_1 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -351,7 +351,7 @@ void verify_json_insert(TAOS* taos) {
//false
payload = cJSON_CreateObject();
cJSON_AddStringToObject(payload, "metric", "stb0_2");
cJSON_AddNumberToObject(payload, "timestamp", 1626006833610123);
cJSON_AddNumberToObject(payload, "timestamp", 1626006833610);
cJSON_AddFalseToObject(payload, "value");
tags = cJSON_CreateObject();
cJSON_AddTrueToObject(tags, "t1");
......@@ -362,7 +362,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload0_2 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -372,7 +372,7 @@ void verify_json_insert(TAOS* taos) {
//string
payload = cJSON_CreateObject();
cJSON_AddStringToObject(payload, "metric", "stb0_3");
cJSON_AddNumberToObject(payload, "timestamp", 1626006833610123);
cJSON_AddNumberToObject(payload, "timestamp", 1626006833610);
cJSON_AddStringToObject(payload, "value", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
tags = cJSON_CreateObject();
cJSON_AddTrueToObject(tags, "t1");
......@@ -383,7 +383,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload0_3 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -404,7 +404,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload0_4 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -433,7 +433,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload1_0 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -459,7 +459,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload1_1 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -485,7 +485,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload1_2 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -511,7 +511,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload1_4 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -543,7 +543,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload2_0 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -573,7 +573,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload2_1 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -603,7 +603,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload2_2 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -633,7 +633,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload2_3 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -663,7 +663,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload2_4 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -693,7 +693,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload2_5 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -723,7 +723,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload2_6 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -753,7 +753,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload2_7 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -783,7 +783,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload2_8 code: %d, %s.\n", code, tstrerror(code));
}
......@@ -863,7 +863,7 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL);
if (code) {
printf("payload3_0 code: %d, %s.\n", code, tstrerror(code));
}
......
......@@ -16,10 +16,10 @@ sql create database $db precision 'us'
sql use $db
sql create stable $mte (ts timestamp, f int) TAGS(t1 bigint)
line_insert st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000ns
line_insert st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64 1626006833640000000ns
line_insert st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000
line_insert st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64 1626006833640000000
line_insert ste,t2=5f64,t3=L"ste" c1=true,c2=4i64,c3="iam" 1626056811823316532ns
line_insert stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns
line_insert stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
sql select * from st
if $rows != 2 then
return -1
......
......@@ -1084,7 +1084,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) {
simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true);
char * lines[] = {rest};
int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0);
int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0, "ns");
if (ret == TSDB_CODE_SUCCESS) {
simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest);
script->linePos++;
......@@ -1107,7 +1107,7 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true);
char * lines[] = {rest};
int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0);
int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0, "ns");
if (ret == TSDB_CODE_SUCCESS) {
sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest);
script->linePos++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册