Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6215c460
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6215c460
编写于
6月 30, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:error in limit offset
上级
06552626
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
15 deletion
+57
-15
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+32
-3
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+25
-12
未找到文件。
source/common/src/tdatablock.c
浏览文件 @
6215c460
...
...
@@ -1437,10 +1437,39 @@ static void doShiftBitmap(char* nullBitmap, size_t n, size_t total) {
}
}
static
int32_t
colDataMoveVarData
(
SColumnInfoData
*
pColInfoData
,
size_t
start
,
size_t
end
){
int32_t
dataOffset
=
-
1
;
int32_t
dataLen
=
0
;
int32_t
beigin
=
start
;
while
(
beigin
<
end
){
int32_t
offset
=
pColInfoData
->
varmeta
.
offset
[
beigin
];
if
(
offset
==
-
1
)
{
beigin
++
;
continue
;
}
if
(
start
!=
0
)
{
pColInfoData
->
varmeta
.
offset
[
beigin
]
=
dataLen
;
}
char
*
data
=
pColInfoData
->
pData
+
offset
;
if
(
dataOffset
==
-
1
)
dataOffset
=
offset
;
// mark the begin of data
int32_t
type
=
pColInfoData
->
info
.
type
;
if
(
type
==
TSDB_DATA_TYPE_JSON
)
{
dataLen
+=
getJsonValueLen
(
data
);
}
else
{
dataLen
+=
varDataTLen
(
data
);
}
beigin
++
;
}
if
(
dataOffset
>
0
){
memmove
(
pColInfoData
->
pData
,
pColInfoData
->
pData
+
dataOffset
,
dataLen
);
memmove
(
pColInfoData
->
varmeta
.
offset
,
&
pColInfoData
->
varmeta
.
offset
[
start
],
(
end
-
start
)
*
sizeof
(
int32_t
));
}
return
dataLen
;
}
static
void
colDataTrimFirstNRows
(
SColumnInfoData
*
pColInfoData
,
size_t
n
,
size_t
total
)
{
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
pColInfoData
->
varmeta
.
length
-=
pColInfoData
->
varmeta
.
offset
[
n
];
memmove
(
pColInfoData
->
varmeta
.
offset
,
&
pColInfoData
->
varmeta
.
offset
[
n
],
(
total
-
n
)
*
sizeof
(
int32_t
));
pColInfoData
->
varmeta
.
length
=
colDataMoveVarData
(
pColInfoData
,
n
,
total
);
memset
(
&
pColInfoData
->
varmeta
.
offset
[
total
-
n
],
0
,
n
);
}
else
{
int32_t
bytes
=
pColInfoData
->
info
.
bytes
;
...
...
@@ -1470,7 +1499,7 @@ int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n) {
static
void
colDataKeepFirstNRows
(
SColumnInfoData
*
pColInfoData
,
size_t
n
,
size_t
total
)
{
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
pColInfoData
->
varmeta
.
length
=
pColInfoData
->
varmeta
.
offset
[
n
]
-
pColInfoData
->
varmeta
.
offset
[
0
]
;
pColInfoData
->
varmeta
.
length
=
colDataMoveVarData
(
pColInfoData
,
0
,
n
)
;
memset
(
&
pColInfoData
->
varmeta
.
offset
[
n
],
0
,
total
-
n
);
}
}
...
...
tests/system-test/2-query/json_tag.py
浏览文件 @
6215c460
...
...
@@ -59,6 +59,22 @@ class TDTestCase:
tdSql
.
query
(
"select jtag from jsons1_8"
)
tdSql
.
checkData
(
0
,
0
,
'{" ":90,"1tag$":2,"tag1":null}'
)
tdSql
.
query
(
"select ts,jtag from jsons1 order by ts limit 2,3"
)
tdSql
.
checkData
(
0
,
0
,
'2020-06-02 09:17:08.000'
)
tdSql
.
checkData
(
0
,
1
,
'{"tag1":5,"tag2":"beijing"}'
)
tdSql
.
checkData
(
1
,
0
,
'2020-06-02 09:17:48.000'
)
tdSql
.
checkData
(
1
,
1
,
'{"tag1":false,"tag2":"beijing"}'
)
tdSql
.
checkData
(
2
,
0
,
'2020-06-02 09:18:48.000'
)
tdSql
.
checkData
(
2
,
1
,
'{"tag1":null,"tag2":"shanghai","tag3":"hello"}'
)
tdSql
.
query
(
"select ts,jtag->'tag1' from jsons1 order by ts limit 2,3"
)
tdSql
.
checkData
(
0
,
0
,
'2020-06-02 09:17:08.000'
)
tdSql
.
checkData
(
0
,
1
,
'5.000000000'
)
tdSql
.
checkData
(
1
,
0
,
'2020-06-02 09:17:48.000'
)
tdSql
.
checkData
(
1
,
1
,
'false'
)
tdSql
.
checkData
(
2
,
0
,
'2020-06-02 09:18:48.000'
)
tdSql
.
checkData
(
2
,
1
,
'null'
)
# test empty json string, save as jtag is NULL
tdSql
.
execute
(
"insert into jsons1_9 using jsons1 tags('
\t
') values (1591062328000, 24, NULL, '你就会', '2sdw')"
)
tdSql
.
execute
(
"CREATE TABLE if not exists jsons1_10 using jsons1 tags('')"
)
...
...
@@ -452,10 +468,6 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
1
,
"11.000000000"
)
tdSql
.
checkData
(
5
,
0
,
1
)
tdSql
.
checkData
(
5
,
1
,
"false"
)
tdSql
.
checkData
(
6
,
0
,
1
)
tdSql
.
checkData
(
6
,
1
,
"null"
)
tdSql
.
checkData
(
7
,
0
,
2
)
tdSql
.
checkData
(
7
,
1
,
None
)
tdSql
.
query
(
"select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc"
)
tdSql
.
checkRows
(
8
)
...
...
@@ -533,9 +545,10 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select avg(dataint) from jsons1 where jtag is not null"
)
tdSql
.
checkData
(
0
,
0
,
5.3
)
# tdSql.query("select twa(dataint) from jsons1 where jtag is not null")
# tdSql.checkData(0, 0, 36)
# tdSql.error("select irate(dataint) from jsons1 where jtag is not null")
tdSql
.
query
(
"select twa(dataint) from jsons1 where jtag is not null"
)
tdSql
.
checkData
(
0
,
0
,
28.386363636363637
)
tdSql
.
query
(
"select irate(dataint) from jsons1 where jtag is not null"
)
tdSql
.
query
(
"select sum(dataint) from jsons1 where jtag->'tag1' is not null"
)
tdSql
.
checkData
(
0
,
0
,
45
)
tdSql
.
query
(
"select stddev(dataint) from jsons1 where jtag->'tag1'>1"
)
...
...
@@ -563,9 +576,9 @@ class TDTestCase:
#test calculation function:diff/derivative/spread/ceil/floor/round/
tdSql
.
query
(
"select diff(dataint) from jsons1 where jtag->'tag1'>1"
)
#
tdSql.checkRows(2)
#
tdSql.checkData(0, 0, -1)
#
tdSql.checkData(1, 0, 10)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
-
1
)
tdSql
.
checkData
(
1
,
0
,
10
)
tdSql
.
query
(
"select derivative(dataint, 10m, 0) from jsons1 where jtag->'tag1'>1"
)
tdSql
.
checkData
(
0
,
0
,
-
2
)
tdSql
.
query
(
"select spread(dataint) from jsons1 where jtag->'tag1'>1"
)
...
...
@@ -673,12 +686,12 @@ class TDTestCase:
tdSql
.
query
(
"select ELAPSED(ts,1h) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
checkRows
(
1
)
#
# #test TD-12077
# tdSql.execute("insert into jsons1_16 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":-2.111}') values(1591062628000, 2, NULL, '你就会', 'dws')")
# tdSql.query("select jtag->'tag3' from jsons1_16")
# tdSql.checkData(0, 0, '-2.111000000')
#
# # test TD-12452
# tdSql.execute("ALTER TABLE jsons1_1 SET TAG jtag=NULL")
# tdSql.query("select jtag from jsons1_1")
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录