Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c3d26dc7
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
c3d26dc7
编写于
6月 28, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(query): enable selectivity with first/last for stable
上级
d91443ce
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
9 deletion
+23
-9
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+19
-5
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+4
-4
未找到文件。
source/libs/function/src/builtinsimpl.c
浏览文件 @
c3d26dc7
...
...
@@ -2409,11 +2409,11 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
return
TSDB_CODE_SUCCESS
;
}
int32_t
getFirstLastInfoSize
(
int32_t
resBytes
)
{
return
sizeof
(
SFirstLastRes
)
+
resBytes
+
sizeof
(
int64_t
);
}
int32_t
getFirstLastInfoSize
(
int32_t
resBytes
)
{
return
sizeof
(
SFirstLastRes
)
+
resBytes
+
sizeof
(
int64_t
)
+
sizeof
(
STuplePos
)
;
}
bool
getFirstLastFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
SColumnNode
*
pNode
=
(
SColumnNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
pEnv
->
calcMemSize
=
sizeof
(
SFirstLastRes
)
+
pNode
->
node
.
resType
.
bytes
+
sizeof
(
int64_t
)
+
sizeof
(
STuplePo
s
);
pEnv
->
calcMemSize
=
getFirstLastInfoSize
(
pNode
->
node
.
resType
.
byte
s
);
return
true
;
}
...
...
@@ -2642,7 +2642,10 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
return
TSDB_CODE_SUCCESS
;
}
static
void
firstLastTransferInfo
(
SFirstLastRes
*
pInput
,
SFirstLastRes
*
pOutput
,
bool
isFirst
)
{
static
void
firstLastTransferInfo
(
SqlFunctionCtx
*
pCtx
,
SFirstLastRes
*
pInput
,
SFirstLastRes
*
pOutput
,
bool
isFirst
)
{
SInputColumnInfoData
*
pColInfo
=
&
pCtx
->
input
;
int32_t
start
=
pColInfo
->
startRowIndex
;
pOutput
->
bytes
=
pInput
->
bytes
;
TSKEY
*
tsIn
=
(
TSKEY
*
)(
pInput
->
buf
+
pInput
->
bytes
);
TSKEY
*
tsOut
=
(
TSKEY
*
)(
pOutput
->
buf
+
pInput
->
bytes
);
...
...
@@ -2659,7 +2662,14 @@ static void firstLastTransferInfo(SFirstLastRes* pInput, SFirstLastRes* pOutput,
}
*
tsOut
=
*
tsIn
;
memcpy
(
pOutput
->
buf
,
pInput
->
buf
,
pOutput
->
bytes
);
pOutput
->
hasResult
=
true
;
//handle selectivity
STuplePos
*
pTuplePos
=
(
STuplePos
*
)(
pOutput
->
buf
+
pOutput
->
bytes
+
sizeof
(
TSKEY
));
if
(
!
pOutput
->
hasResult
)
{
saveTupleData
(
pCtx
,
start
,
pCtx
->
pSrcBlock
,
pTuplePos
);
pOutput
->
hasResult
=
true
;
}
else
{
copyTupleData
(
pCtx
,
start
,
pCtx
->
pSrcBlock
,
pTuplePos
);
}
return
;
}
...
...
@@ -2674,7 +2684,7 @@ static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuer
char
*
data
=
colDataGetData
(
pCol
,
start
);
SFirstLastRes
*
pInputInfo
=
(
SFirstLastRes
*
)
varDataVal
(
data
);
firstLastTransferInfo
(
pInputInfo
,
pInfo
,
isFirstQuery
);
firstLastTransferInfo
(
p
Ctx
,
p
InputInfo
,
pInfo
,
isFirstQuery
);
int32_t
numOfElems
=
pInputInfo
->
hasResult
?
1
:
0
;
...
...
@@ -2696,6 +2706,7 @@ int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SFirstLastRes
*
pRes
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
colDataAppend
(
pCol
,
pBlock
->
info
.
rows
,
pRes
->
buf
,
pResInfo
->
isNullRes
);
//handle selectivity
STuplePos
*
pTuplePos
=
(
STuplePos
*
)(
pRes
->
buf
+
pRes
->
bytes
+
sizeof
(
TSKEY
));
setSelectivityValue
(
pCtx
,
pBlock
,
pTuplePos
,
pBlock
->
info
.
rows
);
...
...
@@ -2716,6 +2727,9 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
colDataAppend
(
pCol
,
pBlock
->
info
.
rows
,
res
,
false
);
//handle selectivity
STuplePos
*
pTuplePos
=
(
STuplePos
*
)(
pRes
->
buf
+
pRes
->
bytes
+
sizeof
(
TSKEY
));
setSelectivityValue
(
pCtx
,
pBlock
,
pTuplePos
,
pBlock
->
info
.
rows
);
taosMemoryFree
(
res
);
return
1
;
...
...
tests/system-test/2-query/json_tag.py
浏览文件 @
c3d26dc7
...
...
@@ -562,7 +562,7 @@ class TDTestCase:
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select round(dataint) from jsons1 where jtag->'tag1'>1"
)
tdSql
.
checkRows
(
3
)
#math function
tdSql
.
query
(
"select sin(dataint) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
checkRows
(
3
)
...
...
@@ -606,7 +606,7 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select twa(dataint) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
checkRows
(
1
)
# function not ready
# tdSql.query("select tail(dataint,1) from jsons1 where jtag->'tag1'>1;")
# tdSql.checkRows(3)
...
...
@@ -616,7 +616,7 @@ class TDTestCase:
# tdSql.checkRows(3)
# tdSql.query("select irate(dataint) from jsons1 where jtag->'tag1'>1;")
# tdSql.checkRows(1)
#str function
tdSql
.
query
(
"select upper(dataStr) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
checkRows
(
3
)
...
...
@@ -658,7 +658,7 @@ class TDTestCase:
tdSql
.
checkRows
(
3
)
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')"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录