Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c2c2dbf2
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看板
提交
c2c2dbf2
编写于
5月 17, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor:add test cases for schemaless
上级
7cde3521
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
149 addition
and
58 deletion
+149
-58
source/client/src/clientSml.c
source/client/src/clientSml.c
+3
-3
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+146
-55
未找到文件。
source/client/src/clientSml.c
浏览文件 @
c2c2dbf2
...
...
@@ -663,12 +663,12 @@ static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){
static
bool
smlParseBool
(
SSmlKv
*
kvVal
)
{
const
char
*
pVal
=
kvVal
->
value
;
int32_t
len
=
kvVal
->
length
;
if
((
len
==
1
)
&&
pVal
[
0
]
==
't'
)
{
if
((
len
==
1
)
&&
(
pVal
[
0
]
==
't'
||
pVal
[
0
]
==
'T'
)
)
{
kvVal
->
i
=
true
;
return
true
;
}
if
((
len
==
1
)
&&
pVal
[
0
]
==
'f'
)
{
if
((
len
==
1
)
&&
(
pVal
[
0
]
==
'f'
||
pVal
[
0
]
==
'F'
)
)
{
kvVal
->
i
=
false
;
return
true
;
}
...
...
@@ -2344,7 +2344,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
goto
end
;
}
if
(
protocol
==
TSDB_SML_LINE_PROTOCOL
&&
(
precision
<
TSDB_SML_TIMESTAMP_
HOURS
||
precision
>
TSDB_SML_TIMESTAMP_NANO_SECONDS
)){
if
(
protocol
==
TSDB_SML_LINE_PROTOCOL
&&
(
precision
<
TSDB_SML_TIMESTAMP_
NOT_CONFIGURED
||
precision
>
TSDB_SML_TIMESTAMP_NANO_SECONDS
)){
request
->
code
=
TSDB_CODE_SML_INVALID_PRECISION_TYPE
;
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"precision invalidate for line protocol"
,
NULL
);
goto
end
;
...
...
source/client/test/smlTest.cpp
浏览文件 @
c2c2dbf2
...
...
@@ -488,10 +488,10 @@ TEST(testCase, smlProcess_influx_Test) {
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
taos
,
nullptr
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists
sml
_db"
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists
inflx
_db"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use
sml
_db"
);
pRes
=
taos_query
(
taos
,
"use
inflx
_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
...
...
@@ -501,33 +501,105 @@ TEST(testCase, smlProcess_influx_Test) {
ASSERT_NE
(
info
,
nullptr
);
const
char
*
sql
[]
=
{
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0 145160640
0
000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0,fuel_consumption=25 145160740
0
000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,heading=221,grade=0,fuel_consumption=25 145160840
0
000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0,fuel_consumption=25 145160940
0
000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 145161940
0
000000000"
,
"readings,name=truck_1,fleet=South,driver=Albert,model=F-150,device_version=v1.5 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=72.45258,longitude=68.83761,elevation=255,velocity=0,heading=181,grade=0,fuel_consumption=25 145160640
00
00000000"
,
"readings,name=truck_2,driver=Derek,model=F-150,device_version=v1.5 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=428,velocity=0,heading=304,grade=0,fuel_consumption=25 145160640
0
000000000"
,
"readings,name=truck_2,fleet=North,driver=Derek,model=F-150 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=428,velocity=0,heading=304,grade=0,fuel_consumption=25 145160940
0
000000000"
,
"readings,fleet=South,name=truck_0,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 145162940
0
000000000"
,
"stable,t1=t1,t2=t2,t3=t3 c1=1,c2=2,c3=
3,c4=4 1451629500
000000000"
,
"stable,t2=t2,t1=t1,t3=t3 c1=1,c3=
3,c4=4 1451629600
000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0 145160640
1
000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0,fuel_consumption=25 145160740
2
000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,heading=221,grade=0,fuel_consumption=25 145160840
3
000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0,fuel_consumption=25 145160940
4
000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 145161940
5
000000000"
,
"readings,name=truck_1,fleet=South,driver=Albert,model=F-150,device_version=v1.5 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=72.45258,longitude=68.83761,elevation=255,velocity=0,heading=181,grade=0,fuel_consumption=25 145160640
6
00000000"
,
"readings,name=truck_2,driver=Derek,model=F-150,device_version=v1.5 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=428,velocity=0,heading=304,grade=0,fuel_consumption=25 145160640
7
000000000"
,
"readings,name=truck_2,fleet=North,driver=Derek,model=F-150 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=428,velocity=0,heading=304,grade=0,fuel_consumption=25 145160940
8
000000000"
,
"readings,fleet=South,name=truck_0,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 145162940
9
000000000"
,
"stable,t1=t1,t2=t2,t3=t3 c1=1,c2=2,c3=
\"
kk
\"
,c4=4 1451629501
000000000"
,
"stable,t2=t2,t1=t1,t3=t3 c1=1,c3=
\"\"
,c4=4 1451629602
000000000"
,
};
int
ret
=
smlProcess
(
info
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]));
ASSERT_EQ
(
ret
,
0
);
TAOS_RES
*
res
=
taos_query
(
taos
,
"select * from t_6885c584b98481584ee13dac399e173d"
);
// case 1
TAOS_RES
*
res
=
taos_query
(
taos
,
"select * from t_91e0b182be80332b5c530cbf872f760e"
);
ASSERT_NE
(
res
,
nullptr
);
int
fieldNum
=
taos_field_count
(
res
);
//ASSERT_EQ(fieldNum, 5
);
ASSERT_EQ
(
fieldNum
,
11
);
printf
(
"fieldNum:%d
\n
"
,
fieldNum
);
int
rowNum
=
taos_affected_rows
(
res
);
//ASSERT_EQ(rowNum, 2);
printf
(
"rowNum:%d
\n
"
,
rowNum
);
for
(
int
i
=
0
;
i
<
rowNum
;
++
i
)
{
TAOS_ROW
rows
=
taos_fetch_row
(
res
);
TAOS_ROW
row
=
NULL
;
int32_t
rowIndex
=
0
;
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
int64_t
ts
=
*
(
int64_t
*
)
row
[
0
];
double
load_capacity
=
*
(
double
*
)
row
[
1
];
double
fuel_capacity
=
*
(
double
*
)
row
[
2
];
double
nominal_fuel_consumption
=
*
(
double
*
)
row
[
3
];
double
latitude
=
*
(
double
*
)
row
[
4
];
double
longitude
=
*
(
double
*
)
row
[
5
];
double
elevation
=
*
(
double
*
)
row
[
6
];
double
velocity
=
*
(
double
*
)
row
[
7
];
double
heading
=
*
(
double
*
)
row
[
8
];
double
grade
=
*
(
double
*
)
row
[
9
];
double
fuel_consumption
=
*
(
double
*
)
row
[
10
];
if
(
rowIndex
==
0
){
ASSERT_EQ
(
ts
,
1451606407000
);
ASSERT_EQ
(
load_capacity
,
2000
);
ASSERT_EQ
(
fuel_capacity
,
200
);
ASSERT_EQ
(
nominal_fuel_consumption
,
15
);
ASSERT_EQ
(
latitude
,
24.5208
);
ASSERT_EQ
(
longitude
,
28.09377
);
ASSERT_EQ
(
elevation
,
428
);
ASSERT_EQ
(
velocity
,
0
);
ASSERT_EQ
(
heading
,
304
);
ASSERT_EQ
(
grade
,
0
);
ASSERT_EQ
(
fuel_consumption
,
25
);
}
else
{
ASSERT_FALSE
(
1
);
}
rowIndex
++
;
}
taos_free_result
(
res
);
// case 2
res
=
taos_query
(
taos
,
"select * from t_6885c584b98481584ee13dac399e173d"
);
ASSERT_NE
(
res
,
nullptr
);
fieldNum
=
taos_field_count
(
res
);
ASSERT_EQ
(
fieldNum
,
5
);
printf
(
"fieldNum:%d
\n
"
,
fieldNum
);
rowIndex
=
0
;
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
int
*
length
=
taos_fetch_lengths
(
res
);
int64_t
ts
=
*
(
int64_t
*
)
row
[
0
];
double
c1
=
*
(
double
*
)
row
[
1
];
double
c4
=
*
(
double
*
)
row
[
4
];
if
(
rowIndex
==
0
){
ASSERT_EQ
(
ts
,
1451629501000
);
ASSERT_EQ
(
c1
,
1
);
ASSERT_EQ
(
*
(
double
*
)
row
[
2
],
2
);
ASSERT_EQ
(
length
[
3
],
2
);
ASSERT_EQ
(
memcmp
(
row
[
3
],
"kk"
,
length
[
3
]),
0
);
ASSERT_EQ
(
c4
,
4
);
}
else
if
(
rowIndex
==
1
){
ASSERT_EQ
(
ts
,
1451629602000
);
ASSERT_EQ
(
c1
,
1
);
ASSERT_EQ
(
row
[
2
],
nullptr
);
ASSERT_EQ
(
length
[
3
],
0
);
ASSERT_EQ
(
c4
,
4
);
}
else
{
ASSERT_FALSE
(
1
);
}
rowIndex
++
;
}
taos_free_result
(
res
);
// case 2
res
=
taos_query
(
taos
,
"show tables"
);
ASSERT_NE
(
res
,
nullptr
);
row
=
taos_fetch_row
(
res
);
int
rowNum
=
taos_affected_rows
(
res
);
ASSERT_EQ
(
rowNum
,
5
);
taos_free_result
(
res
);
destroyRequest
(
request
);
smlDestroyInfo
(
info
);
}
...
...
@@ -586,10 +658,10 @@ TEST(testCase, smlProcess_telnet_Test) {
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
taos
,
nullptr
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists
sml
_db"
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists
telnet
_db"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use
sml
_db"
);
pRes
=
taos_query
(
taos
,
"use
telnet
_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
...
...
@@ -607,27 +679,31 @@ TEST(testCase, smlProcess_telnet_Test) {
int
ret
=
smlProcess
(
info
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]));
ASSERT_EQ
(
ret
,
0
);
// TAOS_RES *res = taos_query(taos, "select * from t_8c30283b3c4131a071d1e16cf6d7094a");
// ASSERT_NE(res, nullptr);
// int fieldNum = taos_field_count(res);
// ASSERT_EQ(fieldNum, 2);
// int rowNum = taos_affected_rows(res);
// ASSERT_EQ(rowNum, 1);
// for (int i = 0; i < rowNum; ++i) {
// TAOS_ROW rows = taos_fetch_row(res);
// }
// taos_free_result(res);
// res = taos_query(taos, "select * from t_6931529054e5637ca92c78a1ad441961");
// ASSERT_NE(res, nullptr);
// fieldNum = taos_field_count(res);
// ASSERT_EQ(fieldNum, 2);
// rowNum = taos_affected_rows(res);
// ASSERT_EQ(rowNum, 2);
// for (int i = 0; i < rowNum; ++i) {
// TAOS_ROW rows = taos_fetch_row(res);
// }
// taos_free_result(res);
// case 1
TAOS_RES
*
res
=
taos_query
(
taos
,
"select * from t_8c30283b3c4131a071d1e16cf6d7094a"
);
ASSERT_NE
(
res
,
nullptr
);
int
fieldNum
=
taos_field_count
(
res
);
ASSERT_EQ
(
fieldNum
,
2
);
TAOS_ROW
row
=
taos_fetch_row
(
res
);
int64_t
ts
=
*
(
int64_t
*
)
row
[
0
];
double
c1
=
*
(
double
*
)
row
[
1
];
ASSERT_EQ
(
ts
,
1479496100000
);
ASSERT_EQ
(
c1
,
42
);
int
rowNum
=
taos_affected_rows
(
res
);
ASSERT_EQ
(
rowNum
,
1
);
taos_free_result
(
res
);
// case 2
res
=
taos_query
(
taos
,
"show tables"
);
ASSERT_NE
(
res
,
nullptr
);
row
=
taos_fetch_row
(
res
);
rowNum
=
taos_affected_rows
(
res
);
ASSERT_EQ
(
rowNum
,
3
);
taos_free_result
(
res
);
destroyRequest
(
request
);
smlDestroyInfo
(
info
);
}
...
...
@@ -636,10 +712,10 @@ TEST(testCase, smlProcess_json1_Test) {
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
taos
,
nullptr
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists
sml
_db"
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists
json
_db"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use
sml
_db"
);
pRes
=
taos_query
(
taos
,
"use
json
_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
...
...
@@ -672,16 +748,31 @@ TEST(testCase, smlProcess_json1_Test) {
int
ret
=
smlProcess
(
info
,
(
char
**
)(
&
sql
),
-
1
);
ASSERT_EQ
(
ret
,
0
);
// TAOS_RES *res = taos_query(taos, "select * from t_cb27a7198d637b4f1c6464bd73f756a7");
// ASSERT_NE(res, nullptr);
// int fieldNum = taos_field_count(res);
// ASSERT_EQ(fieldNum, 2);
// int rowNum = taos_affected_rows(res);
// ASSERT_EQ(rowNum, 1);
// for (int i = 0; i < rowNum; ++i) {
// TAOS_ROW rows = taos_fetch_row(res);
// }
// taos_free_result(res);
// case 1
TAOS_RES
*
res
=
taos_query
(
taos
,
"select * from t_cb27a7198d637b4f1c6464bd73f756a7"
);
ASSERT_NE
(
res
,
nullptr
);
int
fieldNum
=
taos_field_count
(
res
);
ASSERT_EQ
(
fieldNum
,
2
);
TAOS_ROW
row
=
taos_fetch_row
(
res
);
int64_t
ts
=
*
(
int64_t
*
)
row
[
0
];
double
c1
=
*
(
double
*
)
row
[
1
];
ASSERT_EQ
(
ts
,
1346846400000
);
ASSERT_EQ
(
c1
,
18
);
int
rowNum
=
taos_affected_rows
(
res
);
ASSERT_EQ
(
rowNum
,
1
);
taos_free_result
(
res
);
// case 2
res
=
taos_query
(
taos
,
"show tables"
);
ASSERT_NE
(
res
,
nullptr
);
row
=
taos_fetch_row
(
res
);
rowNum
=
taos_affected_rows
(
res
);
ASSERT_EQ
(
rowNum
,
2
);
taos_free_result
(
res
);
destroyRequest
(
request
);
smlDestroyInfo
(
info
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录