Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
b0b119
TDengine
提交
d8545b50
TDengine
项目概览
b0b119
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d8545b50
编写于
7月 15, 2021
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pass test for tag id key as child table name and timestamp ns/us/ms/s
上级
3b477f6c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
19 deletion
+59
-19
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+38
-13
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+6
-0
tests/pytest/insert/line_insert.py
tests/pytest/insert/line_insert.py
+15
-6
未找到文件。
src/client/src/tscParseLineProtocol.c
浏览文件 @
d8545b50
...
...
@@ -1365,23 +1365,23 @@ int32_t tscGetTimeStampValue(char *value, uint16_t len, SMLTimeStampType type, i
}
switch
(
type
)
{
case
SML_TIME_STAMP_NOW
:
{
time_t
now
=
time
(
NULL
);
*
ts
=
SECONDS_TO_MICRO
((
int64_t
)
now
);
*
ts
=
taosGetTimestampNs
();
break
;
}
case
SML_TIME_STAMP_SECONDS
:
{
*
ts
=
(
int64_t
)(
*
ts
*
1e9
);
break
;
}
case
SML_TIME_STAMP_MILLI_SECONDS
:
{
*
ts
=
SECONDS_TO_MILLI
(
*
ts
);
*
ts
=
convertTimePrecision
(
*
ts
,
TSDB_TIME_PRECISION_MILLI
,
TSDB_TIME_PRECISION_NANO
);
break
;
}
case
SML_TIME_STAMP_MICRO_SECONDS
:
{
*
ts
=
SECONDS_TO_MICRO
(
*
ts
);
*
ts
=
convertTimePrecision
(
*
ts
,
TSDB_TIME_PRECISION_MICRO
,
TSDB_TIME_PRECISION_NANO
);
break
;
}
case
SML_TIME_STAMP_NANO_SECONDS
:
{
*
ts
=
SECONDS_TO_NANO
(
*
ts
)
;
*
ts
=
*
ts
*
1
;
break
;
}
default:
{
...
...
@@ -1405,7 +1405,7 @@ int32_t taos_sml_timestamp_convert(TAOS_SML_KV *pVal, char *value, uint16_t len)
if
(
ret
)
{
return
ret
;
}
printf
(
"Timestamp after conversion:%l
l
d
\n
"
,
tsVal
);
printf
(
"Timestamp after conversion:%ld
\n
"
,
tsVal
);
pVal
->
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
...
...
@@ -1592,12 +1592,14 @@ int32_t taos_sml_parse_measurement(TAOS_SML_DATA_POINT *pSml, const char **index
pSml
->
stableName
=
calloc
(
TSDB_TABLE_NAME_LEN
,
1
);
if
(
*
cur
==
'_'
)
{
printf
(
"Measurement field cannnot start with
\'
_
\'\n
"
);
free
(
pSml
->
stableName
);
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
while
(
*
cur
!=
'\0'
)
{
if
(
len
>
TSDB_TABLE_NAME_LEN
)
{
printf
(
"Measurement field cannot exceeds 193 characters"
);
free
(
pSml
->
stableName
);
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
//first unescaped comma or space identifies measurement
...
...
@@ -1635,7 +1637,7 @@ bool tscGetChildTableName(TAOS_SML_DATA_POINT *pData) {
for
(
int
i
=
0
;
i
<
tagNum
;
++
i
)
{
//use tag value as child table name if key is "ID"
//tag value has to be binary for now
if
(
!
strcmp
(
pTags
->
key
,
"ID"
)
&&
pTags
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
if
(
!
strc
asec
mp
(
pTags
->
key
,
"ID"
)
&&
pTags
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
memcpy
(
childTableName
,
pTags
->
value
,
pTags
->
length
);
return
true
;
}
...
...
@@ -1654,8 +1656,6 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* sml_data) {
ret
=
taos_sml_parse_measurement
(
sml_data
,
&
index
,
&
has_tags
);
if
(
ret
)
{
printf
(
"Unable to parse measurement
\n
"
);
free
(
sml_data
->
stableName
);
free
(
sml_data
);
return
ret
;
}
printf
(
"============Parse measurement finished, has_tags:%d===============
\n
"
,
has_tags
);
...
...
@@ -1671,11 +1671,36 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* sml_data) {
sml_data
->
childTableName
=
calloc
(
TSDB_TABLE_NAME_LEN
,
1
);
if
(
!
tscGetChildTableName
(
sml_data
))
{
free
(
sml_data
->
childTableName
);
sml_data
->
childTableName
=
NULL
;
printf
(
"no table name
\n
"
);
}
else
{
printf
(
"Child table name:%02x:%02x:%02x:%02x
\n
"
,
sml_data
->
childTableName
[
0
],
sml_data
->
childTableName
[
1
],
sml_data
->
childTableName
[
2
],
sml_data
->
childTableName
[
3
]);
}
TAOS_SML_KV
*
destTags
=
calloc
(
sml_data
->
tagNum
,
sizeof
(
TAOS_SML_KV
));
TAOS_SML_KV
*
srcTags
=
sml_data
->
tags
;
int
numDestTags
=
0
;
for
(
int32_t
i
=
0
;
i
<
sml_data
->
tagNum
;
++
i
)
{
TAOS_SML_KV
*
srcTag
=
srcTags
+
i
;
if
(
strcasecmp
(
srcTag
->
key
,
"ID"
)
==
0
)
{
continue
;
}
else
{
TAOS_SML_KV
*
destTag
=
destTags
+
numDestTags
;
memcpy
(
destTag
,
srcTag
,
sizeof
(
TAOS_SML_KV
));
destTag
->
key
=
calloc
(
1
,
strlen
(
srcTag
->
key
)
+
1
);
memcpy
(
destTag
->
key
,
srcTag
->
key
,
strlen
(
srcTag
->
key
)
+
1
);
destTag
->
value
=
calloc
(
1
,
srcTag
->
length
);
memcpy
(
destTag
->
value
,
srcTag
->
value
,
srcTag
->
length
);
numDestTags
++
;
}
free
(
srcTag
->
key
);
free
(
srcTag
->
value
);
}
printf
(
"Child table name:%02x:%02x:%02x:%02x
\n
"
,
sml_data
->
childTableName
[
0
],
sml_data
->
childTableName
[
1
],
sml_data
->
childTableName
[
2
],
sml_data
->
childTableName
[
3
]
);
sml_data
->
tags
=
destTags
;
sml_data
->
tagNum
=
numDestTags
;
free
(
srcTags
);
}
else
{
//no tags given
}
...
...
tests/examples/c/apitest.c
浏览文件 @
d8545b50
...
...
@@ -984,6 +984,11 @@ int32_t verify_schema_less(TAOS* taos) {
code
=
taos_insert_lines
(
taos
,
&
lines2
[
0
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines2
[
1
],
1
);
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"
};
code
=
taos_insert_lines
(
taos
,
lines3
,
2
);
return
code
;
}
...
...
@@ -1007,6 +1012,7 @@ int main(int argc, char *argv[]) {
printf
(
"************ verify shemaless *************
\n
"
);
verify_schema_less
(
taos
);
printf
(
"************ verify query *************
\n
"
);
verify_query
(
taos
);
...
...
tests/pytest/insert/line_insert.py
浏览文件 @
d8545b50
...
...
@@ -55,24 +55,33 @@ class TDTestCase:
self
.
_conn
.
insertLines
([
lines2
[
1
]
])
print
(
"insertLines result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from st"
)
;
tdSql
.
query
(
"select * from st"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select * from ste"
)
;
tdSql
.
query
(
"select * from ste"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select * from stf"
)
;
tdSql
.
query
(
"select * from stf"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from stg"
)
;
tdSql
.
query
(
"select * from stg"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"show tables"
)
;
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
8
)
tdSql
.
query
(
"describe stf"
)
;
tdSql
.
query
(
"describe stf"
)
tdSql
.
checkData
(
2
,
2
,
14
)
self
.
_conn
.
insertLines
([
"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"
])
tdSql
.
query
(
'select tbname, * from sth'
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
'select tbname, * from childtable'
)
tdSql
.
checkRows
(
1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录