Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ef975798
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看板
提交
ef975798
编写于
6月 28, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: refactor the plan implementation of unique function
上级
77206e3a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
72 addition
and
28 deletion
+72
-28
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+43
-9
source/libs/planner/test/planBasicTest.cpp
source/libs/planner/test/planBasicTest.cpp
+10
-0
tests/system-test/0-others/udfTest.py
tests/system-test/0-others/udfTest.py
+6
-6
tests/system-test/0-others/udf_create.py
tests/system-test/0-others/udf_create.py
+6
-6
tests/system-test/0-others/udf_restart_taosd.py
tests/system-test/0-others/udf_restart_taosd.py
+6
-6
tools/taos-tools
tools/taos-tools
+1
-1
未找到文件。
source/libs/planner/src/planOptimizer.c
浏览文件 @
ef975798
...
...
@@ -1034,12 +1034,30 @@ static SNodeList* partTagsGetPartKeys(SLogicNode* pNode) {
}
}
static
SNodeList
*
partTagsGetFuncs
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
))
{
return
NULL
;
}
else
{
return
((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
;
}
}
static
bool
partTagsOptAreSupportedFuncs
(
SNodeList
*
pFuncs
)
{
SNode
*
pFunc
=
NULL
;
FOREACH
(
pFunc
,
pFuncs
)
{
if
(
fmIsIndefiniteRowsFunc
(((
SFunctionNode
*
)
pFunc
)
->
funcId
)
&&
!
fmIsSelectFunc
(((
SFunctionNode
*
)
pFunc
)
->
funcId
))
{
return
false
;
}
}
return
true
;
}
static
bool
partTagsOptMayBeOptimized
(
SLogicNode
*
pNode
)
{
if
(
!
partTagsIsOptimizableNode
(
pNode
))
{
return
false
;
}
return
!
partTagsOptHasCol
(
partTagsGetPartKeys
(
pNode
));
return
!
partTagsOptHasCol
(
partTagsGetPartKeys
(
pNode
))
&&
partTagsOptAreSupportedFuncs
(
partTagsGetFuncs
(
pNode
))
;
}
static
EDealRes
partTagsOptRebuildTbanmeImpl
(
SNode
**
pNode
,
void
*
pContext
)
{
...
...
@@ -1065,13 +1083,13 @@ static int32_t partTagsOptRebuildTbanme(SNodeList* pPartKeys) {
return
code
;
}
static
SNode
*
partTagsCreate
GroupKeyFunc
(
SNode
*
pNode
)
{
static
SNode
*
partTagsCreate
WrapperFunc
(
const
char
*
pFuncName
,
SNode
*
pNode
)
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
return
NULL
;
}
strcpy
(
pFunc
->
functionName
,
"_group_key"
);
strcpy
(
pFunc
->
functionName
,
pFuncName
);
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
snprintf
(
pFunc
->
node
.
aliasName
,
sizeof
(
pFunc
->
node
.
aliasName
),
"%s.%s"
,
pCol
->
tableAlias
,
pCol
->
colName
);
...
...
@@ -1091,15 +1109,31 @@ static SNode* partTagsCreateGroupKeyFunc(SNode* pNode) {
return
(
SNode
*
)
pFunc
;
}
static
int32_t
partTagsRewriteGroupTagsToGroupKeyFuncs
(
SNodeList
*
pGroupTags
,
SNodeList
*
pAggFuncs
)
{
SNode
*
pNode
=
NULL
;
static
bool
partTagsHasIndefRowsSelectFunc
(
SNodeList
*
pFuncs
)
{
SNode
*
pFunc
=
NULL
;
FOREACH
(
pFunc
,
pFuncs
)
{
if
(
fmIsIndefiniteRowsFunc
(((
SFunctionNode
*
)
pFunc
)
->
funcId
))
{
return
true
;
}
}
return
false
;
}
static
int32_t
partTagsRewriteGroupTagsToFuncs
(
SNodeList
*
pGroupTags
,
SNodeList
*
pAggFuncs
)
{
bool
hasIndefRowsSelectFunc
=
partTagsHasIndefRowsSelectFunc
(
pAggFuncs
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pGroupTags
)
{
int32_t
code
=
nodesListStrictAppend
(
pAggFuncs
,
partTagsCreateGroupKeyFunc
(
pNode
));
if
(
hasIndefRowsSelectFunc
)
{
code
=
nodesListStrictAppend
(
pAggFuncs
,
partTagsCreateWrapperFunc
(
"_select_value"
,
pNode
));
}
else
{
code
=
nodesListStrictAppend
(
pAggFuncs
,
partTagsCreateWrapperFunc
(
"_group_key"
,
pNode
));
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
break
;
}
}
return
TSDB_CODE_SUCCESS
;
return
code
;
}
static
int32_t
partTagsOptimize
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
)
{
...
...
@@ -1128,7 +1162,7 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
}
}
NODES_DESTORY_LIST
(
pAgg
->
pGroupKeys
);
code
=
partTagsRewriteGroupTagsTo
GroupKey
Funcs
(
pScan
->
pGroupTags
,
pAgg
->
pAggFuncs
);
code
=
partTagsRewriteGroupTagsToFuncs
(
pScan
->
pGroupTags
,
pAgg
->
pAggFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
partTagsOptRebuildTbanme
(
pScan
->
pGroupTags
);
...
...
source/libs/planner/test/planBasicTest.cpp
浏览文件 @
ef975798
...
...
@@ -99,6 +99,16 @@ TEST_F(PlanBasicTest, lastRowFunc) {
run
(
"SELECT LAST_ROW(c1) FROM st1"
);
}
TEST_F
(
PlanBasicTest
,
sampleFunc
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT SAMPLE(c1, 10) FROM t1"
);
run
(
"SELECT SAMPLE(c1, 10) FROM st1"
);
run
(
"SELECT SAMPLE(c1, 10) FROM st1 PARTITION BY TBNAME"
);
}
TEST_F
(
PlanBasicTest
,
withoutFrom
)
{
useDb
(
"root"
,
"test"
);
...
...
tests/system-test/0-others/udfTest.py
浏览文件 @
ef975798
...
...
@@ -301,13 +301,13 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select ceil(num1) , min(num1) from tb;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
error
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , top(num1,1) from tb;"
)
tdSql
.
checkRows
(
1
)
...
...
@@ -327,9 +327,9 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select floor(c1) , min(c1) from stb1;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
error
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , top(c1 ,1) from stb1;"
)
tdSql
.
checkRows
(
1
)
...
...
tests/system-test/0-others/udf_create.py
浏览文件 @
ef975798
...
...
@@ -303,13 +303,13 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select ceil(num1) , min(num1) from tb;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
error
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , top(num1,1) from tb;"
)
tdSql
.
checkRows
(
1
)
...
...
@@ -329,9 +329,9 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select floor(c1) , min(c1) from stb1;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
error
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , top(c1 ,1) from stb1;"
)
tdSql
.
checkRows
(
1
)
...
...
tests/system-test/0-others/udf_restart_taosd.py
浏览文件 @
ef975798
...
...
@@ -300,13 +300,13 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select ceil(num1) , min(num1) from tb;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
error
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , top(num1,1) from tb;"
)
tdSql
.
checkRows
(
1
)
...
...
@@ -326,9 +326,9 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select floor(c1) , min(c1) from stb1;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
error
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , top(c1 ,1) from stb1;"
)
tdSql
.
checkRows
(
1
)
...
...
taos-tools
@
28a49b44
比较
a875a057
...
28a49b44
Subproject commit
a875a057d1225d85c6323b9edaccc2b1a9641987
Subproject commit
28a49b447f71c4f014ebbac858b7215b897d57fd
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录