Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
18c1fba0
T
TDengine
项目概览
loser646
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
18c1fba0
编写于
8月 16, 2021
作者:
X
xywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2573]<feature>: enhanced ceil, floor and round functions
上级
b005dad8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
148 addition
and
77 deletion
+148
-77
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+23
-6
src/query/inc/qAggMain.h
src/query/inc/qAggMain.h
+8
-8
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+6
-60
tests/script/general/compute/ceil.sim
tests/script/general/compute/ceil.sim
+37
-1
tests/script/general/compute/floor.sim
tests/script/general/compute/floor.sim
+37
-1
tests/script/general/compute/round.sim
tests/script/general/compute/round.sim
+37
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
18c1fba0
...
...
@@ -3483,6 +3483,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool
int32_t
scalarUdf
=
0
;
int32_t
prjNum
=
0
;
int32_t
aggNum
=
0
;
int32_t
scalNum
=
0
;
size_t
numOfExpr
=
tscNumOfExprs
(
pQueryInfo
);
assert
(
numOfExpr
>
0
);
...
...
@@ -3514,6 +3515,10 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool
++
prjNum
;
}
if
(
functionId
==
TSDB_FUNC_CEIL
||
functionId
==
TSDB_FUNC_FLOOR
||
functionId
==
TSDB_FUNC_ROUND
)
{
++
scalNum
;
}
if
(
functionId
==
TSDB_FUNC_PRJ
&&
(
pExpr1
->
base
.
colInfo
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
||
TSDB_COL_IS_UD_COL
(
pExpr1
->
base
.
colInfo
.
flag
)))
{
continue
;
}
...
...
@@ -3535,15 +3540,19 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool
}
}
aggNum
=
(
int32_t
)
size
-
prjNum
-
aggUdf
-
scalarUdf
;
aggNum
=
(
int32_t
)
size
-
prjNum
-
scalNum
-
aggUdf
-
scalarUdf
;
assert
(
aggNum
>=
0
);
if
(
aggUdf
>
0
&&
(
prjNum
>
0
||
aggNum
>
0
||
scalarUdf
>
0
))
{
if
(
aggUdf
>
0
&&
(
prjNum
>
0
||
aggNum
>
0
||
scal
Num
>
0
||
scal
arUdf
>
0
))
{
return
false
;
}
if
(
scalarUdf
>
0
&&
aggNum
>
0
)
{
if
(
scalarUdf
>
0
&&
(
aggNum
>
0
||
scalNum
>
0
))
{
return
false
;
}
if
(
aggNum
>
0
&&
scalNum
>
0
)
{
return
false
;
}
...
...
@@ -6818,13 +6827,21 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) {
* if numOfSelectivity equals to 0, it is a super table projection query
*/
if
(
numOfSelectivity
==
1
||
numOfScalar
==
1
)
{
if
(
numOfSelectivity
==
numOfScalar
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
doUpdateSqlFunctionForTagPrj
(
pQueryInfo
);
int32_t
code
=
doUpdateSqlFunctionForColPrj
(
pQueryInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
numOfSelectivity
==
1
&&
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
else
if
(
numOfSelectivity
>
1
||
numOfScalar
>
1
)
{
if
(
numOfSelectivity
>
1
&&
numOfScalar
>
1
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
/*
* If more than one selectivity functions exist, all the selectivity functions must be last_row.
* Otherwise, return with error code.
...
...
@@ -6846,7 +6863,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) {
doUpdateSqlFunctionForTagPrj
(
pQueryInfo
);
int32_t
code
=
doUpdateSqlFunctionForColPrj
(
pQueryInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
numOfSelectivity
==
1
&&
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
...
...
@@ -6856,7 +6873,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) {
return
invalidOperationMsg
(
msg
,
msg2
);
}
if
(
numOfAggregation
>
0
||
numOfS
calar
>
0
||
numOfS
electivity
>
0
)
{
if
(
numOfAggregation
>
0
||
numOfSelectivity
>
0
)
{
// clear the projection type flag
pQueryInfo
->
type
&=
(
~
TSDB_QUERY_TYPE_PROJECTION_QUERY
);
int32_t
code
=
doUpdateSqlFunctionForColPrj
(
pQueryInfo
);
...
...
src/query/inc/qAggMain.h
浏览文件 @
18c1fba0
...
...
@@ -70,14 +70,14 @@ extern "C" {
#define TSDB_FUNC_DERIVATIVE 32
#define TSDB_FUNC_BLKINFO 33
#define TSDB_FUNC_
HISTOGRAM 34
#define TSDB_FUNC_
HLL 35
#define TSDB_FUNC_MODE 36
#define TSDB_FUNC_
SAMPLE
37
#define TSDB_FUNC_
CEIL
38
#define TSDB_FUNC_
FLOOR
39
#define TSDB_FUNC_
ROUND
40
#define TSDB_FUNC_CEIL 34
#define TSDB_FUNC_
FLOOR 35
#define TSDB_FUNC_
ROUND 36
#define TSDB_FUNC_
HISTOGRAM
37
#define TSDB_FUNC_
HLL
38
#define TSDB_FUNC_
MODE
39
#define TSDB_FUNC_
SAMPLE
40
#define TSDB_FUNC_MAVG 41
#define TSDB_FUNC_CSUM 42
...
...
src/query/src/qAggMain.c
浏览文件 @
18c1fba0
...
...
@@ -413,13 +413,7 @@ int32_t isValidFunction(const char* name, int32_t len) {
continue
;
}
if
(
strncasecmp
(
aAggs
[
i
].
name
,
name
,
len
)
==
0
&&
aAggs
[
i
].
init
!=
NULL
&&
aAggs
[
i
].
xFunction
!=
NULL
&&
aAggs
[
i
].
xFinalize
!=
NULL
&&
aAggs
[
i
].
mergeFunc
!=
NULL
&&
aAggs
[
i
].
dataReqFunc
!=
NULL
)
{
if
(
strncasecmp
(
aAggs
[
i
].
name
,
name
,
len
)
==
0
)
{
return
i
;
}
}
...
...
@@ -4613,8 +4607,8 @@ int32_t functionCompatList[] = {
4
,
-
1
,
-
1
,
1
,
1
,
1
,
1
,
1
,
1
,
-
1
,
// tag, colprj, tagprj, arithmetic, diff, first_dist, last_dist, stddev_dst, interp rate irate
1
,
1
,
1
,
1
,
-
1
,
1
,
1
,
1
,
5
,
1
,
1
,
// tid_tag, derivative, blk_info
6
,
8
,
7
,
// tid_tag, derivative, blk_info
, histogram,hll, mode, sample, ceil, floor, round
6
,
8
,
7
,
-
1
,
-
1
,
-
1
,
-
1
,
1
,
1
,
1
};
SAggFunctionInfo
aAggs
[]
=
{{
...
...
@@ -5029,55 +5023,7 @@ SAggFunctionInfo aAggs[] = {{
dataBlockRequired
,
},
{
// TODO 34
"histogram"
,
TSDB_FUNC_HISTOGRAM
,
TSDB_FUNC_HISTOGRAM
,
TSDB_FUNCSTATE_MO
|
TSDB_FUNCSTATE_STABLE
|
TSDB_FUNCSTATE_NEED_TS
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
},
{
// TODO 35
"hll"
,
TSDB_FUNC_HLL
,
TSDB_FUNC_HLL
,
TSDB_FUNCSTATE_MO
|
TSDB_FUNCSTATE_STABLE
|
TSDB_FUNCSTATE_NEED_TS
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
},
{
// TODO 36
"mode"
,
TSDB_FUNC_MODE
,
TSDB_FUNC_MODE
,
TSDB_FUNCSTATE_MO
|
TSDB_FUNCSTATE_STABLE
|
TSDB_FUNCSTATE_NEED_TS
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
},
{
// TODO 37
"sample"
,
TSDB_FUNC_SAMPLE
,
TSDB_FUNC_SAMPLE
,
TSDB_FUNCSTATE_MO
|
TSDB_FUNCSTATE_STABLE
|
TSDB_FUNCSTATE_NEED_TS
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
},
{
// 38
// 34
"ceil"
,
TSDB_FUNC_CEIL
,
TSDB_FUNC_CEIL
,
...
...
@@ -5089,7 +5035,7 @@ SAggFunctionInfo aAggs[] = {{
dataBlockRequired
},
{
// 3
9
// 3
5
"floor"
,
TSDB_FUNC_FLOOR
,
TSDB_FUNC_FLOOR
,
...
...
@@ -5101,7 +5047,7 @@ SAggFunctionInfo aAggs[] = {{
dataBlockRequired
},
{
//
40
//
36
"round"
,
TSDB_FUNC_ROUND
,
TSDB_FUNC_ROUND
,
...
...
tests/script/general/compute/ceil.sim
浏览文件 @
18c1fba0
...
...
@@ -162,8 +162,44 @@ print ===> $data10
if $data10 != 0 then
return -1
endi
sql select ts, ceil(c2) from $tb
sql select c2, ceil(c2) from $tb
sql select c2, c3, ceil(c2) from $tb
sql select ts, c2, c3, ceil(c2) from $tb
sql select ceil(c2), ceil(c6) from $tb
sql select ceil(c2) from $mt
sql select ts, ceil(c2), ceil(c6) from $tb
sql select c2, ceil(c2), ceil(c6) from $tb
sql select c2, c3, ceil(c2), ceil(c6) from $tb
sql select ts, c2, c3, ceil(c2), ceil(c6) from $tb
sql select ceil(c2), floor(c2), round(c2) from $tb
sql select ts, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, ceil(c2) from $mt
sql select c2, ceil(c2) from $mt
sql select c2, c3, ceil(c2) from $mt
sql select ts, c2, c3, ceil(c2) from $mt
sql select ceil(c2), ceil(c6) from $mt
sql select ts, ceil(c2), ceil(c6) from $mt
sql select c2, ceil(c2), ceil(c6) from $mt
sql select c2, c3, ceil(c2), ceil(c6) from $mt
sql select ts, c2, c3, ceil(c2), ceil(c6) from $mt
sql select ceil(c2), ceil(c2), round(c2) from $mt
sql select ts, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql_error select ceil(c7) from $tb
sql_error select ceil(c8) from $tb
sql_error select ceil(c9) from $tb
...
...
tests/script/general/compute/floor.sim
浏览文件 @
18c1fba0
...
...
@@ -162,8 +162,44 @@ print ===> $data10
if $data10 != 0 then
return -1
endi
sql select ts, floor(c2) from $tb
sql select c2, floor(c2) from $tb
sql select c2, c3, floor(c2) from $tb
sql select ts, c2, c3, floor(c2) from $tb
sql select floor(c2), floor(c6) from $tb
sql select floor(c2) from $mt
sql select ts, floor(c2), floor(c6) from $tb
sql select c2, floor(c2), floor(c6) from $tb
sql select c2, c3, floor(c2), floor(c6) from $tb
sql select ts, c2, c3, floor(c2), floor(c6) from $tb
sql select ceil(c2), floor(c2), round(c2) from $tb
sql select ts, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, floor(c2) from $mt
sql select c2, floor(c2) from $mt
sql select c2, c3, floor(c2) from $mt
sql select ts, c2, c3, floor(c2) from $mt
sql select floor(c2), floor(c6) from $mt
sql select ts, floor(c2), floor(c6) from $mt
sql select c2, floor(c2), floor(c6) from $mt
sql select c2, c3, floor(c2), floor(c6) from $mt
sql select ts, c2, c3, floor(c2), floor(c6) from $mt
sql select ceil(c2), floor(c2), round(c2) from $mt
sql select ts, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql_error select floor(c7) from $tb
sql_error select floor(c8) from $tb
sql_error select floor(c9) from $tb
...
...
tests/script/general/compute/round.sim
浏览文件 @
18c1fba0
...
...
@@ -162,8 +162,44 @@ print ===> $data10
if $data10 != 0 then
return -1
endi
sql select ts, round(c2) from $tb
sql select c2, round(c2) from $tb
sql select c2, c3, round(c2) from $tb
sql select ts, c2, c3, round(c2) from $tb
sql select round(c2), round(c6) from $tb
sql select round(c2) from $mt
sql select ts, round(c2), round(c6) from $tb
sql select c2, round(c2), round(c6) from $tb
sql select c2, c3, round(c2), round(c6) from $tb
sql select ts, c2, c3, round(c2), round(c6) from $tb
sql select ceil(c2), floor(c2), round(c2) from $tb
sql select ts, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, round(c2) from $mt
sql select c2, round(c2) from $mt
sql select c2, c3, round(c2) from $mt
sql select ts, c2, c3, round(c2) from $mt
sql select round(c2), round(c6) from $mt
sql select ts, round(c2), round(c6) from $mt
sql select c2, round(c2), round(c6) from $mt
sql select c2, c3, round(c2), round(c6) from $mt
sql select ts, c2, c3, round(c2), round(c6) from $mt
sql select ceil(c2), floor(c2), round(c2) from $mt
sql select ts, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql_error select round(c7) from $tb
sql_error select round(c8) from $tb
sql_error select round(c9) from $tb
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录