Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1b9ed345
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1b9ed345
编写于
9月 18, 2021
作者:
D
dapan1121
提交者:
GitHub
9月 18, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7971 from taosdata/enhance/TD-6645
[TD-6645/enhance]: Minor modification to OpenTSDB writing protocol parsing
上级
1c281088
65206793
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
241 addition
and
65 deletion
+241
-65
src/client/inc/tscParseLine.h
src/client/inc/tscParseLine.h
+3
-0
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+33
-31
src/client/src/tscParseOpenTSDB.c
src/client/src/tscParseOpenTSDB.c
+43
-9
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+5
-2
src/common/src/tglobal.c
src/common/src/tglobal.c
+14
-0
src/inc/taoserror.h
src/inc/taoserror.h
+2
-1
src/util/inc/tconfig.h
src/util/inc/tconfig.h
+1
-1
src/util/src/terror.c
src/util/src/terror.c
+1
-0
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+8
-7
tests/pytest/insert/insertJSONPayload.py
tests/pytest/insert/insertJSONPayload.py
+119
-7
tests/pytest/insert/insertTelnetLines.py
tests/pytest/insert/insertTelnetLines.py
+12
-7
未找到文件。
src/client/inc/tscParseLine.h
浏览文件 @
1b9ed345
...
...
@@ -54,6 +54,9 @@ typedef struct {
int
tscSmlInsert
(
TAOS
*
taos
,
TAOS_SML_DATA_POINT
*
points
,
int
numPoint
,
SSmlLinesInfo
*
info
);
bool
checkDuplicateKey
(
char
*
key
,
SHashObj
*
pHash
,
SSmlLinesInfo
*
info
);
bool
isValidInteger
(
char
*
str
);
bool
isValidFloat
(
char
*
str
);
int32_t
isValidChildTableName
(
const
char
*
pTbName
,
int16_t
len
);
bool
convertSmlValueType
(
TAOS_SML_KV
*
pVal
,
char
*
value
,
...
...
src/client/src/tscParseLineProtocol.c
浏览文件 @
1b9ed345
...
...
@@ -1137,7 +1137,7 @@ static void escapeSpecialCharacter(uint8_t field, const char **pos) {
*
pos
=
cur
;
}
static
bool
isValidInteger
(
char
*
str
)
{
bool
isValidInteger
(
char
*
str
)
{
char
*
c
=
str
;
if
(
*
c
!=
'+'
&&
*
c
!=
'-'
&&
!
isdigit
(
*
c
))
{
return
false
;
...
...
@@ -1152,7 +1152,7 @@ static bool isValidInteger(char *str) {
return
true
;
}
static
bool
isValidFloat
(
char
*
str
)
{
bool
isValidFloat
(
char
*
str
)
{
char
*
c
=
str
;
uint8_t
has_dot
,
has_exp
,
has_sign
;
has_dot
=
0
;
...
...
@@ -1212,7 +1212,7 @@ static bool isTinyInt(char *pVal, uint16_t len) {
if
(
len
<=
2
)
{
return
false
;
}
if
(
!
strcmp
(
&
pVal
[
len
-
2
],
"i8"
))
{
if
(
!
strc
asec
mp
(
&
pVal
[
len
-
2
],
"i8"
))
{
//printf("Type is int8(%s)\n", pVal);
return
true
;
}
...
...
@@ -1226,7 +1226,7 @@ static bool isTinyUint(char *pVal, uint16_t len) {
if
(
pVal
[
0
]
==
'-'
)
{
return
false
;
}
if
(
!
strcmp
(
&
pVal
[
len
-
2
],
"u8"
))
{
if
(
!
strc
asec
mp
(
&
pVal
[
len
-
2
],
"u8"
))
{
//printf("Type is uint8(%s)\n", pVal);
return
true
;
}
...
...
@@ -1237,7 +1237,7 @@ static bool isSmallInt(char *pVal, uint16_t len) {
if
(
len
<=
3
)
{
return
false
;
}
if
(
!
strcmp
(
&
pVal
[
len
-
3
],
"i16"
))
{
if
(
!
strc
asec
mp
(
&
pVal
[
len
-
3
],
"i16"
))
{
//printf("Type is int16(%s)\n", pVal);
return
true
;
}
...
...
@@ -1251,7 +1251,7 @@ static bool isSmallUint(char *pVal, uint16_t len) {
if
(
pVal
[
0
]
==
'-'
)
{
return
false
;
}
if
(
strcmp
(
&
pVal
[
len
-
3
],
"u16"
)
==
0
)
{
if
(
strc
asec
mp
(
&
pVal
[
len
-
3
],
"u16"
)
==
0
)
{
//printf("Type is uint16(%s)\n", pVal);
return
true
;
}
...
...
@@ -1262,7 +1262,7 @@ static bool isInt(char *pVal, uint16_t len) {
if
(
len
<=
3
)
{
return
false
;
}
if
(
strcmp
(
&
pVal
[
len
-
3
],
"i32"
)
==
0
)
{
if
(
strc
asec
mp
(
&
pVal
[
len
-
3
],
"i32"
)
==
0
)
{
//printf("Type is int32(%s)\n", pVal);
return
true
;
}
...
...
@@ -1276,7 +1276,7 @@ static bool isUint(char *pVal, uint16_t len) {
if
(
pVal
[
0
]
==
'-'
)
{
return
false
;
}
if
(
strcmp
(
&
pVal
[
len
-
3
],
"u32"
)
==
0
)
{
if
(
strc
asec
mp
(
&
pVal
[
len
-
3
],
"u32"
)
==
0
)
{
//printf("Type is uint32(%s)\n", pVal);
return
true
;
}
...
...
@@ -1287,7 +1287,7 @@ static bool isBigInt(char *pVal, uint16_t len) {
if
(
len
<=
3
)
{
return
false
;
}
if
(
strcmp
(
&
pVal
[
len
-
3
],
"i64"
)
==
0
)
{
if
(
strc
asec
mp
(
&
pVal
[
len
-
3
],
"i64"
)
==
0
)
{
//printf("Type is int64(%s)\n", pVal);
return
true
;
}
...
...
@@ -1301,7 +1301,7 @@ static bool isBigUint(char *pVal, uint16_t len) {
if
(
pVal
[
0
]
==
'-'
)
{
return
false
;
}
if
(
strcmp
(
&
pVal
[
len
-
3
],
"u64"
)
==
0
)
{
if
(
strc
asec
mp
(
&
pVal
[
len
-
3
],
"u64"
)
==
0
)
{
//printf("Type is uint64(%s)\n", pVal);
return
true
;
}
...
...
@@ -1312,7 +1312,7 @@ static bool isFloat(char *pVal, uint16_t len) {
if
(
len
<=
3
)
{
return
false
;
}
if
(
strcmp
(
&
pVal
[
len
-
3
],
"f32"
)
==
0
)
{
if
(
strc
asec
mp
(
&
pVal
[
len
-
3
],
"f32"
)
==
0
)
{
//printf("Type is float(%s)\n", pVal);
return
true
;
}
...
...
@@ -1323,7 +1323,7 @@ static bool isDouble(char *pVal, uint16_t len) {
if
(
len
<=
3
)
{
return
false
;
}
if
(
strcmp
(
&
pVal
[
len
-
3
],
"f64"
)
==
0
)
{
if
(
strc
asec
mp
(
&
pVal
[
len
-
3
],
"f64"
)
==
0
)
{
//printf("Type is double(%s)\n", pVal);
return
true
;
}
...
...
@@ -1331,34 +1331,24 @@ static bool isDouble(char *pVal, uint16_t len) {
}
static
bool
isBool
(
char
*
pVal
,
uint16_t
len
,
bool
*
bVal
)
{
if
((
len
==
1
)
&&
(
pVal
[
len
-
1
]
==
't'
||
pVal
[
len
-
1
]
==
'T'
))
{
if
((
len
==
1
)
&&
!
strcasecmp
(
&
pVal
[
len
-
1
],
"t"
))
{
//printf("Type is bool(%c)\n", pVal[len - 1]);
*
bVal
=
true
;
return
true
;
}
if
((
len
==
1
)
&&
(
pVal
[
len
-
1
]
==
'f'
||
pVal
[
len
-
1
]
==
'F'
))
{
if
((
len
==
1
)
&&
!
strcasecmp
(
&
pVal
[
len
-
1
],
"f"
))
{
//printf("Type is bool(%c)\n", pVal[len - 1]);
*
bVal
=
false
;
return
true
;
}
if
((
len
==
4
)
&&
(
!
strcmp
(
&
pVal
[
len
-
4
],
"true"
)
||
!
strcmp
(
&
pVal
[
len
-
4
],
"True"
)
||
!
strcmp
(
&
pVal
[
len
-
4
],
"TRUE"
)))
{
if
((
len
==
4
)
&&
!
strcasecmp
(
&
pVal
[
len
-
4
],
"true"
))
{
//printf("Type is bool(%s)\n", &pVal[len - 4]);
*
bVal
=
true
;
return
true
;
}
if
((
len
==
5
)
&&
(
!
strcmp
(
&
pVal
[
len
-
5
],
"false"
)
||
!
strcmp
(
&
pVal
[
len
-
5
],
"False"
)
||
!
strcmp
(
&
pVal
[
len
-
5
],
"FALSE"
)))
{
if
((
len
==
5
)
&&
!
strcasecmp
(
&
pVal
[
len
-
5
],
"false"
))
{
//printf("Type is bool(%s)\n", &pVal[len - 5]);
*
bVal
=
false
;
return
true
;
...
...
@@ -1384,7 +1374,7 @@ static bool isNchar(char *pVal, uint16_t len) {
if
(
len
<
3
)
{
return
false
;
}
if
(
pVal
[
0
]
==
'L'
&&
pVal
[
1
]
==
'"'
&&
pVal
[
len
-
1
]
==
'"'
)
{
if
(
(
pVal
[
0
]
==
'l'
||
pVal
[
0
]
==
'L'
)
&&
pVal
[
1
]
==
'"'
&&
pVal
[
len
-
1
]
==
'"'
)
{
//printf("Type is nchar(%s)\n", pVal);
return
true
;
}
...
...
@@ -1434,7 +1424,7 @@ static bool isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType) {
return
false
;
}
static
bool
convertStrToNumber
(
TAOS_SML_KV
*
pVal
,
char
*
str
,
SSmlLinesInfo
*
info
)
{
static
bool
convertStrToNumber
(
TAOS_SML_KV
*
pVal
,
char
*
str
,
SSmlLinesInfo
*
info
)
{
errno
=
0
;
uint8_t
type
=
pVal
->
type
;
int16_t
length
=
pVal
->
length
;
...
...
@@ -1442,6 +1432,7 @@ static bool convertStrToNumber(TAOS_SML_KV *pVal, char*str, SSmlLinesInfo* info)
uint64_t
val_u
;
double
val_d
;
strntolower_s
(
str
,
str
,
(
int32_t
)
strlen
(
str
));
if
(
IS_FLOAT_TYPE
(
type
))
{
val_d
=
strtod
(
str
,
NULL
);
}
else
{
...
...
@@ -1659,9 +1650,19 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
memcpy
(
pVal
->
value
,
&
bVal
,
pVal
->
length
);
return
true
;
}
//Handle default(no appendix) as float
if
(
isValidInteger
(
value
)
||
isValidFloat
(
value
))
{
pVal
->
type
=
TSDB_DATA_TYPE_FLOAT
;
//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
))
{
pVal
->
type
=
TSDB_DATA_TYPE_DOUBLE
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
if
(
!
convertStrToNumber
(
pVal
,
value
,
info
))
{
return
false
;
...
...
@@ -1724,6 +1725,7 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
SMLTimeStampType
type
;
int64_t
tsVal
;
strntolower_s
(
value
,
value
,
len
);
if
(
!
isTimeStamp
(
value
,
len
,
&
type
))
{
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
...
...
src/client/src/tscParseOpenTSDB.c
浏览文件 @
1b9ed345
...
...
@@ -38,7 +38,7 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index,
uint16_t
len
=
0
;
pSml
->
stableName
=
tcalloc
(
TSDB_TABLE_NAME_LEN
+
1
,
1
);
// +1 to avoid 1772 line over write
if
(
pSml
->
stableName
==
NULL
){
if
(
pSml
->
stableName
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
if
(
isdigit
(
*
cur
))
{
...
...
@@ -58,7 +58,13 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index,
break
;
}
pSml
->
stableName
[
len
]
=
*
cur
;
//convert dot to underscore for now, will be removed once dot is allowed in tbname.
if
(
*
cur
==
'.'
)
{
pSml
->
stableName
[
len
]
=
'_'
;
}
else
{
pSml
->
stableName
[
len
]
=
*
cur
;
}
cur
++
;
len
++
;
}
...
...
@@ -455,6 +461,13 @@ int32_t parseMetricFromJSON(cJSON *root, TAOS_SML_DATA_POINT* pSml, SSmlLinesInf
return
TSDB_CODE_TSC_INVALID_JSON
;
}
//convert dot to underscore for now, will be removed once dot is allowed in tbname.
for
(
int
i
=
0
;
i
<
strlen
(
metric
->
valuestring
);
++
i
)
{
if
(
metric
->
valuestring
[
i
]
==
'.'
)
{
metric
->
valuestring
[
i
]
=
'_'
;
}
}
tstrncpy
(
pSml
->
stableName
,
metric
->
valuestring
,
stableLen
+
1
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -485,6 +498,7 @@ int32_t parseTimestampFromJSONObj(cJSON *root, int64_t *tsVal, SSmlLinesInfo* in
}
size_t
typeLen
=
strlen
(
type
->
valuestring
);
strntolower_s
(
type
->
valuestring
,
type
->
valuestring
,
(
int32_t
)
typeLen
);
if
(
typeLen
==
1
&&
type
->
valuestring
[
0
]
==
's'
)
{
//seconds
*
tsVal
=
(
int64_t
)(
*
tsVal
*
1e9
);
...
...
@@ -505,6 +519,8 @@ int32_t parseTimestampFromJSONObj(cJSON *root, int64_t *tsVal, SSmlLinesInfo* in
default:
return
TSDB_CODE_TSC_INVALID_JSON
;
}
}
else
{
return
TSDB_CODE_TSC_INVALID_JSON
;
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -725,16 +741,34 @@ int32_t parseValueFromJSON(cJSON *root, TAOS_SML_KV *pVal, SSmlLinesInfo* info)
break
;
}
case
cJSON_Number
:
{
//convert default JSON Number type to float
pVal
->
type
=
TSDB_DATA_TYPE_FLOAT
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
pVal
->
value
=
tcalloc
(
pVal
->
length
,
1
);
*
(
float
*
)(
pVal
->
value
)
=
(
float
)(
root
->
valuedouble
);
//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
);
*
(
int64_t
*
)(
pVal
->
value
)
=
(
int64_t
)(
root
->
valuedouble
);
}
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
;
}
break
;
}
case
cJSON_String
:
{
//convert default JSON String type to nchar
pVal
->
type
=
TSDB_DATA_TYPE_NCHAR
;
/* set default JSON type to binary/nchar according to
* user configured parameter tsDefaultJSONStrType
*/
if
(
strcasecmp
(
tsDefaultJSONStrType
,
"binary"
)
==
0
)
{
pVal
->
type
=
TSDB_DATA_TYPE_BINARY
;
}
else
if
(
strcasecmp
(
tsDefaultJSONStrType
,
"nchar"
)
==
0
)
{
pVal
->
type
=
TSDB_DATA_TYPE_NCHAR
;
}
else
{
tscError
(
"OTD:0x%"
PRIx64
" Invalid default JSON string type set from config %s"
,
info
->
id
,
tsDefaultJSONStrType
);
return
TSDB_CODE_TSC_INVALID_JSON_CONFIG
;
}
//pVal->length = wcslen((wchar_t *)root->valuestring) * TSDB_NCHAR_SIZE;
pVal
->
length
=
(
int16_t
)
strlen
(
root
->
valuestring
);
pVal
->
value
=
tcalloc
(
pVal
->
length
+
1
,
1
);
...
...
src/common/inc/tglobal.h
浏览文件 @
1b9ed345
...
...
@@ -216,7 +216,7 @@ extern int32_t cqDebugFlag;
extern
int32_t
debugFlag
;
#ifdef TD_TSZ
// lossy
// lossy
extern
char
lossyColumns
[];
extern
double
fPrecision
;
extern
double
dPrecision
;
...
...
@@ -224,9 +224,12 @@ extern uint32_t maxRange;
extern
uint32_t
curRange
;
extern
char
Compressor
[];
#endif
// long query
// long query
extern
int8_t
tsDeadLockKillQuery
;
// schemaless
extern
char
tsDefaultJSONStrType
[];
typedef
struct
{
char
dir
[
TSDB_FILENAME_LEN
];
int
level
;
...
...
src/common/src/tglobal.c
浏览文件 @
1b9ed345
...
...
@@ -282,6 +282,9 @@ char Compressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESS
// long query death-lock
int8_t
tsDeadLockKillQuery
=
0
;
// default JSON string type
char
tsDefaultJSONStrType
[
7
]
=
"binary"
;
int32_t
(
*
monStartSystemFp
)()
=
NULL
;
void
(
*
monStopSystemFp
)()
=
NULL
;
void
(
*
monExecuteSQLFp
)(
char
*
sql
)
=
NULL
;
...
...
@@ -1637,6 +1640,17 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
// default JSON string type option "binary"/"nchar"
cfg
.
option
=
"defaultJSONStrType"
;
cfg
.
ptr
=
tsDefaultJSONStrType
;
cfg
.
valType
=
TAOS_CFG_VTYPE_STRING
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
|
TSDB_CFG_CTYPE_B_CLIENT
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
0
;
cfg
.
ptrLength
=
tListLen
(
tsDefaultJSONStrType
);
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
#ifdef TD_TSZ
// lossy compress
cfg
.
option
=
"lossyColumns"
;
...
...
src/inc/taoserror.h
浏览文件 @
1b9ed345
...
...
@@ -110,7 +110,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TSC_DUP_TAG_NAMES TAOS_DEF_ERROR_CODE(0, 0x0220) //"duplicated tag names")
#define TSDB_CODE_TSC_INVALID_JSON TAOS_DEF_ERROR_CODE(0, 0x0221) //"Invalid JSON format")
#define TSDB_CODE_TSC_INVALID_JSON_TYPE TAOS_DEF_ERROR_CODE(0, 0x0222) //"Invalid JSON data type")
#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0223) //"Value out of range")
#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")
// mnode
#define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed")
...
...
src/util/inc/tconfig.h
浏览文件 @
1b9ed345
...
...
@@ -20,7 +20,7 @@
extern
"C"
{
#endif
#define TSDB_CFG_MAX_NUM 12
3
#define TSDB_CFG_MAX_NUM 12
4
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41
...
...
src/util/src/terror.c
浏览文件 @
1b9ed345
...
...
@@ -118,6 +118,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_COLUMN_LENGTH, "Invalid column length
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_DUP_TAG_NAMES
,
"duplicated tag names"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_JSON
,
"Invalid JSON format"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_JSON_TYPE
,
"Invalid JSON data type"
)
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"
)
// mnode
...
...
tests/examples/c/apitest.c
浏览文件 @
1b9ed345
...
...
@@ -1090,9 +1090,10 @@ void verify_telnet_insert(TAOS* taos) {
//bigint
char
*
lines2_3
[]
=
{
"stb2_3 1626006833651ms -9223372036854775807i64 host=
\"
host0
\"
"
,
"stb2_3 1626006833652ms 9223372036854775807i64 host=
\"
host0
\"
"
"stb2_3 1626006833652ms 9223372036854775807i64 host=
\"
host0
\"
"
,
"stb2_3 1626006833662ms 9223372036854775807 host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_3
,
2
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_3
,
3
);
if
(
code
)
{
printf
(
"lines2_3 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
...
...
@@ -1107,11 +1108,10 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_4 1626006833660ms -3.4e10f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833670ms 3.4E+2f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833680ms -3.4e-2f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833690ms 3.15 host=
\"
host0
\"
"
,
"stb2_4 1626006833700ms 3.4E38f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833710ms -3.4E38f32 host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_4
,
1
1
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_4
,
1
0
);
if
(
code
)
{
printf
(
"lines2_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
...
...
@@ -1127,9 +1127,10 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_5 1626006833670ms 3.4E+2f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833680ms -3.4e-2f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833690ms 1.7E308f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833700ms -1.7E308f64 host=
\"
host0
\"
"
"stb2_5 1626006833700ms -1.7E308f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833710ms 3.15 host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_5
,
1
0
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_5
,
1
1
);
if
(
code
)
{
printf
(
"lines2_5 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
...
...
@@ -1166,7 +1167,7 @@ void verify_telnet_insert(TAOS* taos) {
//nchar
char
*
lines2_8
[]
=
{
"stb2_8 1626006833610ms L
\"
nchar_val数值一
\"
host=
\"
host0
\"
"
,
"stb2_8 1626006833620ms L
\"
nchar_val数值二
\"
host=
\"
host0
\"
"
,
"stb2_8 1626006833620ms L
\"
nchar_val数值二
\"
host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_8
,
2
);
if
(
code
)
{
...
...
tests/pytest/insert/insertJSONPayload.py
浏览文件 @
1b9ed345
...
...
@@ -31,6 +31,27 @@ class TDTestCase:
### Default format ###
### metric ###
print
(
"============= step0 : test metric ================"
)
payload
=
'''
{
"metric": ".stb.0.",
"timestamp": 1626006833610123,
"value": 10,
"tags": {
"t1": true,
"t2": false,
"t3": 10,
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
}
}
'''
code
=
self
.
_conn
.
insert_json_payload
(
payload
)
print
(
"insert_json_payload result {}"
.
format
(
code
))
tdSql
.
query
(
"describe _stb_0_"
)
tdSql
.
checkRows
(
6
)
### metric value ###
print
(
"============= step1 : test metric value types ================"
)
payload
=
'''
...
...
@@ -50,7 +71,7 @@ class TDTestCase:
print
(
"insert_json_payload result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_0"
)
tdSql
.
checkData
(
1
,
1
,
"
FLOA
T"
)
tdSql
.
checkData
(
1
,
1
,
"
BIGIN
T"
)
payload
=
'''
{
...
...
@@ -107,12 +128,52 @@ class TDTestCase:
print
(
"insert_json_payload result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_3"
)
tdSql
.
checkData
(
1
,
1
,
"
NCHAR
"
)
tdSql
.
checkData
(
1
,
1
,
"
BINARY
"
)
### timestamp 0 ###
payload
=
'''
{
"metric": "stb0_4",
"timestamp": 1626006833610123,
"value": 3.14,
"tags": {
"t1": true,
"t2": false,
"t3": 10,
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
}
}
'''
code
=
self
.
_conn
.
insert_json_payload
(
payload
)
print
(
"insert_json_payload result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_4"
)
tdSql
.
checkData
(
1
,
1
,
"DOUBLE"
)
payload
=
'''
{
"metric": "stb0_5",
"timestamp": 1626006833610123,
"value": 3.14E-2,
"tags": {
"t1": true,
"t2": false,
"t3": 10,
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
}
}
'''
code
=
self
.
_conn
.
insert_json_payload
(
payload
)
print
(
"insert_json_payload result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_5"
)
tdSql
.
checkData
(
1
,
1
,
"DOUBLE"
)
print
(
"============= step2 : test timestamp ================"
)
### timestamp 0 ###
payload
=
'''
{
"metric": "stb0_6",
"timestamp": 0,
"value": 123,
"tags": {
...
...
@@ -127,14 +188,15 @@ class TDTestCase:
print
(
"insert_json_payload result {}"
.
format
(
code
))
print
(
"============= step3 : test tags ================"
)
### ID ###
payload
=
'''
{
"metric": "stb0_
5
",
"metric": "stb0_
7
",
"timestamp": 0,
"value": 123,
"tags": {
"ID": "tb0_
5
",
"ID": "tb0_
7
",
"t1": true,
"iD": "tb000",
"t2": false,
...
...
@@ -147,10 +209,60 @@ class TDTestCase:
code
=
self
.
_conn
.
insert_json_payload
(
payload
)
print
(
"insert_json_payload result {}"
.
format
(
code
))
tdSql
.
query
(
"select tbname from stb0_5"
)
tdSql
.
checkData
(
0
,
0
,
"tb0_5"
)
tdSql
.
query
(
"select tbname from stb0_7"
)
tdSql
.
checkData
(
0
,
0
,
"tb0_7"
)
### Default tag numeric types ###
payload
=
'''
{
"metric": "stb0_8",
"timestamp": 0,
"value": 123,
"tags": {
"t1": 123
}
}
'''
code
=
self
.
_conn
.
insert_json_payload
(
payload
)
print
(
"insert_json_payload result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_8"
)
tdSql
.
checkData
(
2
,
1
,
"BIGINT"
)
payload
=
'''
{
"metric": "stb0_9",
"timestamp": 0,
"value": 123,
"tags": {
"t1": 123.00
}
}
'''
code
=
self
.
_conn
.
insert_json_payload
(
payload
)
print
(
"insert_json_payload result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_9"
)
tdSql
.
checkData
(
2
,
1
,
"DOUBLE"
)
payload
=
'''
{
"metric": "stb0_10",
"timestamp": 0,
"value": 123,
"tags": {
"t1": 123E-1
}
}
'''
code
=
self
.
_conn
.
insert_json_payload
(
payload
)
print
(
"insert_json_payload result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_10"
)
tdSql
.
checkData
(
2
,
1
,
"DOUBLE"
)
### Nested format ###
print
(
"============= step4 : test nested format ================"
)
### timestamp ###
#seconds
payload
=
'''
...
...
tests/pytest/insert/insertTelnetLines.py
浏览文件 @
1b9ed345
...
...
@@ -36,13 +36,14 @@ class TDTestCase:
"stb0_0 1626006833639000000ns 4i8 host=
\"
host0
\"
interface=
\"
eth0
\"
"
,
"stb0_1 1626006833639000000ns 4i8 host=
\"
host0
\"
interface=
\"
eth0
\"
"
,
"stb0_2 1626006833639000000ns 4i8 host=
\"
host0
\"
interface=
\"
eth0
\"
"
,
".stb0.3. 1626006833639000000ns 4i8 host=
\"
host0
\"
interface=
\"
eth0
\"
"
,
]
code
=
self
.
_conn
.
insert_telnet_lines
(
lines0
)
print
(
"insert_telnet_lines result {}"
.
format
(
code
))
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"describe stb0_0"
)
tdSql
.
checkRows
(
4
)
...
...
@@ -53,6 +54,9 @@ class TDTestCase:
tdSql
.
query
(
"describe stb0_2"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"describe _stb0_3_"
)
tdSql
.
checkRows
(
4
)
### timestamp ###
print
(
"============= step2 : test timestamp ================"
)
lines1
=
[
...
...
@@ -122,14 +126,15 @@ class TDTestCase:
#bigint
lines2_3
=
[
"stb2_3 1626006833651ms -9223372036854775807i64 host=
\"
host0
\"
"
,
"stb2_3 1626006833652ms 9223372036854775807i64 host=
\"
host0
\"
"
"stb2_3 1626006833652ms 9223372036854775807i64 host=
\"
host0
\"
"
,
"stb2_3 1626006833662ms 9223372036854775807 host=
\"
host0
\"
"
]
code
=
self
.
_conn
.
insert_telnet_lines
(
lines2_3
)
print
(
"insert_telnet_lines result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb2_3"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"describe stb2_3"
)
tdSql
.
checkRows
(
3
)
...
...
@@ -145,7 +150,6 @@ class TDTestCase:
"stb2_4 1626006833660ms -3.4e10f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833670ms 3.4E+2f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833680ms -3.4e-2f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833690ms 3.15 host=
\"
host0
\"
"
,
"stb2_4 1626006833700ms 3.4E38f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833710ms -3.4E38f32 host=
\"
host0
\"
"
]
...
...
@@ -154,7 +158,7 @@ class TDTestCase:
print
(
"insert_telnet_lines result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb2_4"
)
tdSql
.
checkRows
(
1
1
)
tdSql
.
checkRows
(
1
0
)
tdSql
.
query
(
"describe stb2_4"
)
tdSql
.
checkRows
(
3
)
...
...
@@ -171,14 +175,15 @@ class TDTestCase:
"stb2_5 1626006833670ms 3.4E+2f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833680ms -3.4e-2f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833690ms 1.7E308f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833700ms -1.7E308f64 host=
\"
host0
\"
"
"stb2_5 1626006833700ms -1.7E308f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833710ms 3.15 host=
\"
host0
\"
"
]
code
=
self
.
_conn
.
insert_telnet_lines
(
lines2_5
)
print
(
"insert_telnet_lines result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb2_5"
)
tdSql
.
checkRows
(
1
0
)
tdSql
.
checkRows
(
1
1
)
tdSql
.
query
(
"describe stb2_5"
)
tdSql
.
checkRows
(
3
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录