Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
5ae38f32
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
提交
5ae38f32
编写于
4月 08, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support stable udf
上级
e06dce48
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
1142 addition
and
51 deletion
+1142
-51
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-2
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+3
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+16
-3
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+2
-2
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+15
-6
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+7
-3
tests/script/general/parser/udf_dll.sim
tests/script/general/parser/udf_dll.sim
+1
-26
tests/script/general/parser/udf_dll_stable.sim
tests/script/general/parser/udf_dll_stable.sim
+1078
-0
tests/script/sh/sum_double.c
tests/script/sh/sum_double.c
+17
-7
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
5ae38f32
...
...
@@ -128,7 +128,7 @@ int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, i
*/
bool
tscIsPointInterpQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsTWAQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsSecondStageQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsSecondStageQuery
(
S
SqlCmd
*
pCmd
,
S
QueryInfo
*
pQueryInfo
);
bool
tscGroupbyColumn
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsTopbotQuery
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscGetTopbotQueryParam
(
SQueryInfo
*
pQueryInfo
);
...
...
@@ -137,7 +137,7 @@ bool tscNonOrderedProjectionQueryOnSTable(SSqlCmd *pCmd, SQueryInfo *pQueryInfo,
bool
tscOrderedProjectionQueryOnSTable
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscIsProjectionQueryOnSTable
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscIsProjectionQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsProjectionQuery
(
S
SqlCmd
*
pCmd
,
S
QueryInfo
*
pQueryInfo
);
bool
tscIsTwoStageSTableQuery
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscQueryTags
(
SQueryInfo
*
pQueryInfo
);
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
5ae38f32
...
...
@@ -121,6 +121,8 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalMerger *pReducer, tOrderDescr
if
(
pExpr
->
functionId
==
TSDB_FUNC_TAG_DUMMY
||
pExpr
->
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
tagLen
+=
pExpr
->
resBytes
;
pTagCtx
[
n
++
]
=
&
pReducer
->
pCtx
[
i
];
}
else
if
(
pExpr
->
functionId
<
0
)
{
continue
;
}
else
if
((
aAggs
[
pExpr
->
functionId
].
status
&
TSDB_FUNCSTATE_SELECTIVITY
)
!=
0
)
{
pCtx
=
&
pReducer
->
pCtx
[
i
];
}
...
...
@@ -1321,7 +1323,7 @@ bool genFinalResults(SSqlObj *pSql, SLocalMerger *pLocalMerge, bool noMoreCurren
tColModelCompact
(
pModel
,
pResBuf
,
pModel
->
capacity
);
if
(
tscIsSecondStageQuery
(
pQueryInfo
))
{
if
(
tscIsSecondStageQuery
(
p
Cmd
,
p
QueryInfo
))
{
doArithmeticCalculate
(
pQueryInfo
,
pResBuf
,
pModel
->
rowSize
,
pLocalMerge
->
finalModel
->
rowSize
);
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
5ae38f32
...
...
@@ -3112,6 +3112,10 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo)
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
int32_t
functionId
=
tscSqlExprGet
(
pQueryInfo
,
i
)
->
functionId
;
if
(
functionId
<
0
)
{
continue
;
}
if
((
aAggs
[
functionId
].
status
&
TSDB_FUNCSTATE_STABLE
)
==
0
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
return
true
;
...
...
@@ -6462,7 +6466,7 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
}
// projection query on super table does not compatible with "group by" syntax
if
(
tsc
NonOrderedProjectionQueryOnSTable
(
pCmd
,
pQueryInfo
,
0
))
{
if
(
tsc
IsProjectionQuery
(
pCmd
,
pQueryInfo
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
...
...
@@ -6641,8 +6645,17 @@ void tscPrintSelectClause(SSqlObj* pSql, int32_t subClauseIndex) {
char
tmpBuf
[
1024
]
=
{
0
};
int32_t
tmpLen
=
0
;
char
*
name
=
NULL
;
if
(
pExpr
->
functionId
<
0
)
{
SUdfInfo
*
pUdfInfo
=
taosArrayGet
(
pSql
->
cmd
.
pUdfInfo
,
-
1
*
pExpr
->
functionId
-
1
);
name
=
pUdfInfo
->
name
;
}
else
{
name
=
aAggs
[
pExpr
->
functionId
].
name
;
}
tmpLen
=
sprintf
(
tmpBuf
,
"%s(uid:%"
PRId64
", %d)"
,
aAggs
[
pExpr
->
functionId
].
name
,
pExpr
->
uid
,
pExpr
->
colInfo
.
colId
);
sprintf
(
tmpBuf
,
"%s(uid:%"
PRId64
", %d)"
,
name
,
pExpr
->
uid
,
pExpr
->
colInfo
.
colId
);
if
(
tmpLen
+
offset
>=
totalBufSize
-
1
)
break
;
...
...
@@ -6988,7 +7001,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
if
(
!
tscIsProjectionQuery
(
pQueryInfo
)
&&
pQueryInfo
->
interval
.
interval
==
0
)
{
if
(
!
tscIsProjectionQuery
(
p
Cmd
,
p
QueryInfo
)
&&
pQueryInfo
->
interval
.
interval
==
0
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
}
...
...
src/client/src/tscServer.c
浏览文件 @
5ae38f32
...
...
@@ -888,7 +888,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
size_t
output
=
tscNumOfFields
(
pQueryInfo
);
if
(
tscIsSecondStageQuery
(
pQueryInfo
))
{
if
(
tscIsSecondStageQuery
(
p
Cmd
,
p
QueryInfo
))
{
pQueryMsg
->
secondStageOutput
=
htonl
((
int32_t
)
output
);
SSqlFuncMsg
*
pSqlFuncExpr1
=
(
SSqlFuncMsg
*
)
pMsg
;
...
...
src/client/src/tscSubquery.c
浏览文件 @
5ae38f32
...
...
@@ -633,7 +633,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
if
((
pExpr
->
colInfo
.
colId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
||
(
funcId
!=
TSDB_FUNC_TS
&&
funcId
!=
TSDB_FUNC_TS_DUMMY
&&
funcId
!=
TSDB_FUNC_PRJ
))
{
int16_t
functionId
=
tscIsProjectionQuery
(
pQueryInfo
)
?
TSDB_FUNC_PRJ
:
TSDB_FUNC_TS
;
int16_t
functionId
=
tscIsProjectionQuery
(
&
pNew
->
cmd
,
pQueryInfo
)
?
TSDB_FUNC_PRJ
:
TSDB_FUNC_TS
;
tscAddFuncInSelectClause
(
pQueryInfo
,
0
,
functionId
,
&
index
,
s
,
TSDB_COL_NORMAL
);
tscPrintSelectClause
(
pNew
,
0
);
...
...
@@ -3486,7 +3486,7 @@ static UNUSED_FUNC bool tscHasRemainDataInSubqueryResultSet(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo1
=
tscGetQueryInfoDetail
(
&
pSql
->
pSubs
[
i
]
->
cmd
,
0
);
if
((
pRes1
->
row
>=
pRes1
->
numOfRows
&&
tscHasReachLimitation
(
pQueryInfo1
,
pRes1
)
&&
tscIsProjectionQuery
(
pQueryInfo1
))
||
(
pRes1
->
numOfRows
==
0
))
{
tscIsProjectionQuery
(
&
pSql
->
pSubs
[
i
]
->
cmd
,
pQueryInfo1
))
||
(
pRes1
->
numOfRows
==
0
))
{
hasData
=
false
;
break
;
}
...
...
src/client/src/tscUtil.c
浏览文件 @
5ae38f32
...
...
@@ -198,12 +198,21 @@ bool tscOrderedProjectionQueryOnSTable(SSqlCmd *pCmd, SQueryInfo* pQueryInfo, in
return
pQueryInfo
->
order
.
orderColId
>=
0
;
}
bool
tscIsProjectionQuery
(
SQueryInfo
*
pQueryInfo
)
{
bool
tscIsProjectionQuery
(
S
SqlCmd
*
pCmd
,
S
QueryInfo
*
pQueryInfo
)
{
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
int32_t
functionId
=
tscSqlExprGet
(
pQueryInfo
,
i
)
->
functionId
;
if
(
functionId
<
0
)
{
SUdfInfo
*
pUdfInfo
=
taosArrayGet
(
pCmd
->
pUdfInfo
,
-
1
*
functionId
-
1
);
if
(
pUdfInfo
->
funcType
==
TSDB_UDF_TYPE_AGGREGATE
)
{
return
false
;
}
continue
;
}
if
(
functionId
!=
TSDB_FUNC_PRJ
&&
functionId
!=
TSDB_FUNC_TAGPRJ
&&
functionId
!=
TSDB_FUNC_TAG
&&
functionId
!=
TSDB_FUNC_TS
&&
functionId
!=
TSDB_FUNC_ARITHM
)
{
return
false
;
...
...
@@ -232,11 +241,7 @@ bool tscIsPointInterpQuery(SQueryInfo* pQueryInfo) {
return
true
;
}
bool
tscIsSecondStageQuery
(
SQueryInfo
*
pQueryInfo
)
{
if
(
tscIsProjectionQuery
(
pQueryInfo
))
{
return
false
;
}
bool
tscIsSecondStageQuery
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
)
{
size_t
numOfOutput
=
tscNumOfFields
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SExprInfo
*
pExprInfo
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
i
)
->
pArithExprInfo
;
...
...
@@ -245,6 +250,10 @@ bool tscIsSecondStageQuery(SQueryInfo* pQueryInfo) {
}
}
if
(
tscIsProjectionQuery
(
pCmd
,
pQueryInfo
))
{
return
false
;
}
return
false
;
}
...
...
src/query/src/qExecutor.c
浏览文件 @
5ae38f32
...
...
@@ -784,9 +784,13 @@ static void doInvokeUdf(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx *pCtx, int
(
*
(
udfNormalFunc
)
pUdfInfo
->
funcs
[
TSDB_UDF_FUNC_NORMAL
])((
char
*
)
pCtx
->
pInput
+
idx
*
pCtx
->
inputType
,
pCtx
->
inputType
,
pCtx
->
inputBytes
,
pCtx
->
size
,
pCtx
->
ptsList
,
pCtx
->
pOutput
,
(
char
*
)
pCtx
->
ptsOutputBuf
,
&
output
,
pCtx
->
outputType
,
pCtx
->
outputBytes
,
&
pUdfInfo
->
init
);
// set the output value exist
pCtx
->
resultInfo
->
numOfRes
+=
output
;
if
(
output
>
0
)
{
if
(
pUdfInfo
->
funcType
==
TSDB_UDF_TYPE_AGGREGATE
)
{
pCtx
->
resultInfo
->
numOfRes
=
output
;
}
else
{
pCtx
->
resultInfo
->
numOfRes
+=
output
;
}
if
(
pCtx
->
resultInfo
->
numOfRes
>
0
)
{
pCtx
->
resultInfo
->
hasResult
=
DATA_SET_FLAG
;
}
...
...
tests/script/general/parser/udf_dll.sim
浏览文件 @
5ae38f32
...
...
@@ -393,32 +393,7 @@ if $rows != 28 then
return -1
endi
sql select add_one(f1) from tb1 group by f1;
if $rows != 7 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 3 then
return -1
endi
if $data20 != 4 then
return -1
endi
if $data30 != 5 then
return -1
endi
if $data40 != 6 then
return -1
endi
if $data50 != 7 then
return -1
endi
if $data60 != 8 then
return -1
endi
sql_error select add_one(f1) from tb1 group by f1;
sql select sum_double(f1) from tb1 group by f1;
if $rows != 7 then
...
...
tests/script/general/parser/udf_dll_stable.sim
0 → 100644
浏览文件 @
5ae38f32
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1
system sh/exec.sh -n dnode1 -s start
system sh/prepare_udf.sh
sleep 100
sql connect
print ======================== dnode1 start
sql create function add_one as '/tmp/add_one.so' outputtype int;
sql create aggregate function sum_double as '/tmp/sum_double.so' outputtype int;
sql show functions;
if $rows != 2 then
return -1
endi
sql create database db;
sql use db;
sql create stable stb1 (ts timestamp, f1 int, f2 bool, f3 binary(10)) tags(id1 int);
sql create table tb1 using stb1 tags(1);
sql insert into tb1 values ('2021-03-23 17:17:19.660', 1, true, 'tb1-1');
sql insert into tb1 values ('2021-03-23 19:23:28.595', 2, false, 'tb1-2');
sql insert into tb1 values ('2021-03-23 19:33:39.070', 3, true, 'tb1-3');
sql insert into tb1 values ('2021-03-23 19:34:37.670', 4, false, 'tb1-4');
sql insert into tb1 values ('2021-03-24 19:08:06.609', 5, true, 'tb1-5');
sql insert into tb1 values ('2021-03-24 19:26:38.231', 6, false, 'tb1-6');
sql insert into tb1 values ('2021-03-25 10:03:17.688', 7, true, 'tb1-7');
sql create table tb2 using stb1 tags(2);
sql create table tb3 using stb1 tags(3);
sql create table tb4 using stb1 tags(4);
sql create table tb5 using stb1 tags(5);
sql create table tb6 using stb1 tags(6);
sql create table tb7 using stb1 tags(7);
sql create table tb8 using stb1 tags(8);
sql create table tb9 using stb1 tags(9);
sql insert into tb2 values ('2021-03-03 17:17:19.660', 1, true, 'tb2-1');
sql insert into tb2 values ('2021-03-13 19:23:28.595', 2, false, 'tb2-2');
sql insert into tb3 values ('2021-03-23 19:33:39.070', 3, true, 'tb3-1');
sql insert into tb3 values ('2021-03-24 19:34:37.670', 4, false, 'tb3-2');
sql insert into tb5 values ('2021-03-25 19:08:06.609', 1, true, 'tb5-1');
sql insert into tb5 values ('2021-04-01 19:26:38.231', 2, false, 'tb5-2');
sql insert into tb5 values ('2021-04-08 10:03:17.688', 3, true, 'tb5-3');
sql insert into tb6 values ('2021-04-08 11:03:17.688', 1, true, 'tb6-1');
sql insert into tb6 values ('2021-04-08 12:03:17.688', 2, true, 'tb6-2');
sql insert into tb9 values ('2021-04-08 16:03:17.688', 4, true, 'tb9-1');
sql select add_one(f1) from tb1;
if $rows != 7 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 3 then
return -1
endi
if $data20 != 4 then
return -1
endi
if $data30 != 5 then
return -1
endi
if $data40 != 6 then
return -1
endi
if $data50 != 7 then
return -1
endi
if $data60 != 8 then
return -1
endi
sql select sum_double(f1) from tb1;
if $rows != 1 then
return -1
endi
if $data00 != 56 then
return -1
endi
sql select ts,add_one(f1),f1 from tb1;
if $rows != 7 then
return -1
endi
if $data00 != @21-03-23 17:17:19.660@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data10 != @21-03-23 19:23:28.595@ then
return -1
endi
if $data11 != 3 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data20 != @21-03-23 19:33:39.070@ then
return -1
endi
if $data21 != 4 then
return -1
endi
if $data22 != 3 then
return -1
endi
if $data30 != @21-03-23 19:34:37.670@ then
return -1
endi
if $data31 != 5 then
return -1
endi
if $data32 != 4 then
return -1
endi
if $data40 != @21-03-24 19:08:06.609@ then
return -1
endi
if $data41 != 6 then
return -1
endi
if $data42 != 5 then
return -1
endi
if $data50 != @21-03-24 19:26:38.231@ then
return -1
endi
if $data51 != 7 then
return -1
endi
if $data52 != 6 then
return -1
endi
if $data60 != @21-03-25 10:03:17.688@ then
return -1
endi
if $data61 != 8 then
return -1
endi
if $data62 != 7 then
return -1
endi
sql select add_one(f1),add_one(f1) from tb1;
if $rows != 7 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != 3 then
return -1
endi
if $data11 != 3 then
return -1
endi
if $data20 != 4 then
return -1
endi
if $data21 != 4 then
return -1
endi
if $data30 != 5 then
return -1
endi
if $data31 != 5 then
return -1
endi
if $data40 != 6 then
return -1
endi
if $data41 != 6 then
return -1
endi
if $data50 != 7 then
return -1
endi
if $data51 != 7 then
return -1
endi
if $data60 != 8 then
return -1
endi
if $data61 != 8 then
return -1
endi
sql select add_one(f1)+1 from tb1;
if $rows != 7 then
return -1
endi
if $data00 != 3.000000000 then
return -1
endi
if $data10 != 4.000000000 then
return -1
endi
if $data20 != 5.000000000 then
return -1
endi
if $data30 != 6.000000000 then
return -1
endi
if $data40 != 7.000000000 then
return -1
endi
if $data50 != 8.000000000 then
return -1
endi
if $data60 != 9.000000000 then
return -1
endi
sql select sum_double(f1)+1 from tb1;
if $rows != 1 then
return -1
endi
if $data00 != 57.000000000 then
return -1
endi
sql select add_one(f1)+1,f1 from tb1;
if $rows != 7 then
return -1
endi
if $data00 != 3.000000000 then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data10 != 4.000000000 then
return -1
endi
if $data11 != 2 then
return -1
endi
if $data20 != 5.000000000 then
return -1
endi
if $data21 != 3 then
return -1
endi
if $data30 != 6.000000000 then
return -1
endi
if $data31 != 4 then
return -1
endi
if $data40 != 7.000000000 then
return -1
endi
if $data41 != 5 then
return -1
endi
if $data50 != 8.000000000 then
return -1
endi
if $data51 != 6 then
return -1
endi
if $data60 != 9.000000000 then
return -1
endi
if $data61 != 7 then
return -1
endi
sql select sum_double(f1) from tb1 interval (10a);
if $rows != 7 then
return -1
endi
if $data00 != @21-03-23 17:17:19.660@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != @21-03-23 19:23:28.590@ then
return -1
endi
if $data11 != 4 then
return -1
endi
if $data20 != @21-03-23 19:33:39.070@ then
return -1
endi
if $data21 != 6 then
return -1
endi
if $data30 != @21-03-23 19:34:37.670@ then
return -1
endi
if $data31 != 8 then
return -1
endi
if $data40 != @21-03-24 19:08:06.600@ then
return -1
endi
if $data41 != 10 then
return -1
endi
if $data50 != @21-03-24 19:26:38.230@ then
return -1
endi
if $data51 != 12 then
return -1
endi
if $data60 != @21-03-25 10:03:17.680@ then
return -1
endi
if $data61 != 14 then
return -1
endi
sql select ts,add_one(f1) from tb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000";
if $rows != 6 then
return -1
endi
if $data00 != @21-03-23 17:17:19.660@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != @21-03-23 19:23:28.595@ then
return -1
endi
if $data11 != 3 then
return -1
endi
if $data20 != @21-03-23 19:33:39.070@ then
return -1
endi
if $data21 != 4 then
return -1
endi
if $data30 != @21-03-23 19:34:37.670@ then
return -1
endi
if $data31 != 5 then
return -1
endi
if $data40 != @21-03-24 19:08:06.609@ then
return -1
endi
if $data41 != 6 then
return -1
endi
if $data50 != @21-03-24 19:26:38.231@ then
return -1
endi
if $data51 != 7 then
return -1
endi
sql select sum_double(f1) from tb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h);
if $rows != 3 then
return -1
endi
if $data00 != @21-03-23 17:00:00.000@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != @21-03-23 19:00:00.000@ then
return -1
endi
if $data11 != 18 then
return -1
endi
if $data20 != @21-03-24 19:00:00.000@ then
return -1
endi
if $data21 != 22 then
return -1
endi
sql select sum_double(f1) from tb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h) fill(value,999);
if $rows != 28 then
return -1
endi
sql_error select add_one(f1) from tb1 group by f1;
sql select sum_double(f1) from tb1 group by f1;
if $rows != 7 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 4 then
return -1
endi
if $data20 != 6 then
return -1
endi
if $data30 != 8 then
return -1
endi
if $data40 != 10 then
return -1
endi
if $data50 != 12 then
return -1
endi
if $data60 != 14 then
return -1
endi
sql select sum_double(f1) from tb1 interval (1h) order by ts desc;
if $rows != 4 then
return -1
endi
if $data00 != @21-03-25 10:00:00.000@ then
return -1
endi
if $data01 != 14 then
return -1
endi
if $data10 != @21-03-24 19:00:00.000@ then
return -1
endi
if $data11 != 22 then
return -1
endi
if $data20 != @21-03-23 19:00:00.000@ then
return -1
endi
if $data21 != 18 then
return -1
endi
if $data30 != @21-03-23 17:00:00.000@ then
return -1
endi
if $data31 != 2 then
return -1
endi
sql select add_one(f1) from tb1 limit 2;
if $rows != 2 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 3 then
return -1
endi
sql select sum_double(f1) from tb1 interval (1d) limit 2;
if $rows != 2 then
return -1
endi
if $data00 != @21-03-23 00:00:00.000@ then
return -1
endi
if $data01 != 20 then
return -1
endi
if $data10 != @21-03-24 00:00:00.000@ then
return -1
endi
if $data11 != 22 then
return -1
endi
sql_error select ts,sum_double(f1),f1 from tb1;
sql_error select add_one(f1),count(f1) from tb1;
sql_error select sum_double(f1),count(f1) from tb1;
sql_error select add_one(f1),top(f1,3) from tb1;
sql_error select add_one(f1) from tb1 interval(10a);
sql select add_one(f1) from stb1;
if $rows != 17 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 3 then
return -1
endi
if $data20 != 4 then
return -1
endi
if $data30 != 5 then
return -1
endi
if $data40 != 6 then
return -1
endi
if $data50 != 7 then
return -1
endi
if $data60 != 8 then
return -1
endi
if $data70 != 2 then
return -1
endi
if $data80 != 3 then
return -1
endi
if $data90 != 4 then
return -1
endi
sql select sum_double(f1) from stb1;
if $rows != 1 then
return -1
endi
if $data00 != 102 then
return -1
endi
sql select ts,add_one(f1),f1 from stb1;
if $rows != 17 then
return -1
endi
if $data00 != @21-03-23 17:17:19.660@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data10 != @21-03-23 19:23:28.595@ then
return -1
endi
if $data11 != 3 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data20 != @21-03-23 19:33:39.070@ then
return -1
endi
if $data21 != 4 then
return -1
endi
if $data22 != 3 then
return -1
endi
if $data30 != @21-03-23 19:34:37.670@ then
return -1
endi
if $data31 != 5 then
return -1
endi
if $data32 != 4 then
return -1
endi
if $data40 != @21-03-24 19:08:06.609@ then
return -1
endi
if $data41 != 6 then
return -1
endi
if $data42 != 5 then
return -1
endi
if $data50 != @21-03-24 19:26:38.231@ then
return -1
endi
if $data51 != 7 then
return -1
endi
if $data52 != 6 then
return -1
endi
if $data60 != @21-03-25 10:03:17.688@ then
return -1
endi
if $data61 != 8 then
return -1
endi
if $data62 != 7 then
return -1
endi
sql select add_one(f1),add_one(f1) from stb1;
if $rows != 17 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != 3 then
return -1
endi
if $data11 != 3 then
return -1
endi
if $data20 != 4 then
return -1
endi
if $data21 != 4 then
return -1
endi
if $data30 != 5 then
return -1
endi
if $data31 != 5 then
return -1
endi
if $data40 != 6 then
return -1
endi
if $data41 != 6 then
return -1
endi
if $data50 != 7 then
return -1
endi
if $data51 != 7 then
return -1
endi
if $data60 != 8 then
return -1
endi
if $data61 != 8 then
return -1
endi
sql select add_one(f1)+1 from stb1;
if $rows != 17 then
return -1
endi
if $data00 != 3.000000000 then
return -1
endi
if $data10 != 4.000000000 then
return -1
endi
if $data20 != 5.000000000 then
return -1
endi
if $data30 != 6.000000000 then
return -1
endi
if $data40 != 7.000000000 then
return -1
endi
if $data50 != 8.000000000 then
return -1
endi
if $data60 != 9.000000000 then
return -1
endi
sql select sum_double(f1)+1 from stb1;
if $rows != 1 then
return -1
endi
if $data00 != 103.000000000 then
return -1
endi
sql select add_one(f1)+1,f1 from stb1;
if $rows != 17 then
return -1
endi
if $data00 != 3.000000000 then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data10 != 4.000000000 then
return -1
endi
if $data11 != 2 then
return -1
endi
if $data20 != 5.000000000 then
return -1
endi
if $data21 != 3 then
return -1
endi
if $data30 != 6.000000000 then
return -1
endi
if $data31 != 4 then
return -1
endi
if $data40 != 7.000000000 then
return -1
endi
if $data41 != 5 then
return -1
endi
if $data50 != 8.000000000 then
return -1
endi
if $data51 != 6 then
return -1
endi
if $data60 != 9.000000000 then
return -1
endi
if $data61 != 7 then
return -1
endi
sql select sum_double(f1) from stb1 interval (10a);
if $rows != 16 then
return -1
endi
if $data00 != @21-03-03 17:17:19.660@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != @21-03-13 19:23:28.590@ then
return -1
endi
if $data11 != 4 then
return -1
endi
if $data20 != @21-03-23 17:17:19.660@ then
return -1
endi
if $data21 != 2 then
return -1
endi
if $data30 != @21-03-23 19:23:28.590@ then
return -1
endi
if $data31 != 4 then
return -1
endi
if $data40 != @21-03-23 19:33:39.070@ then
return -1
endi
if $data41 != 12 then
return -1
endi
if $data50 != @21-03-23 19:34:37.670@ then
return -1
endi
if $data51 != 8 then
return -1
endi
if $data60 != @21-03-24 19:08:06.600@ then
return -1
endi
if $data61 != 10 then
return -1
endi
if $data70 != @21-03-24 19:26:38.230@ then
return -1
endi
if $data71 != 12 then
return -1
endi
if $data80 != @21-03-24 19:34:37.670@ then
return -1
endi
if $data81 != 8 then
return -1
endi
if $data90 != @21-03-25 10:03:17.680@ then
return -1
endi
if $data91 != 14 then
return -1
endi
sql select ts,add_one(f1) from stb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000";
if $rows != 8 then
return -1
endi
if $data00 != @21-03-23 17:17:19.660@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != @21-03-23 19:23:28.595@ then
return -1
endi
if $data11 != 3 then
return -1
endi
if $data20 != @21-03-23 19:33:39.070@ then
return -1
endi
if $data21 != 4 then
return -1
endi
if $data30 != @21-03-23 19:34:37.670@ then
return -1
endi
if $data31 != 5 then
return -1
endi
if $data40 != @21-03-24 19:08:06.609@ then
return -1
endi
if $data41 != 6 then
return -1
endi
if $data50 != @21-03-24 19:26:38.231@ then
return -1
endi
if $data51 != 7 then
return -1
endi
if $data60 != @21-03-23 19:33:39.070@ then
return -1
endi
if $data61 != 4 then
return -1
endi
if $data70 != @21-03-24 19:34:37.670@ then
return -1
endi
if $data71 != 5 then
return -1
endi
sql select sum_double(f1) from stb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h);
if $rows != 3 then
return -1
endi
if $data00 != @21-03-23 17:00:00.000@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != @21-03-23 19:00:00.000@ then
return -1
endi
if $data11 != 24 then
return -1
endi
if $data20 != @21-03-24 19:00:00.000@ then
return -1
endi
if $data21 != 30 then
return -1
endi
sql select sum_double(f1) from stb1 where ts>="2021-03-23 17:00:00.000" and ts<="2021-03-24 20:00:00.000" interval (1h) fill(value,999);
if $rows != 28 then
return -1
endi
if $data00 != @21-03-23 17:00:00.000@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != @21-03-23 18:00:00.000@ then
return -1
endi
if $data11 != 999 then
return -1
endi
if $data20 != @21-03-23 19:00:00.000@ then
return -1
endi
if $data21 != 24 then
return -1
endi
sql_error select add_one(f1) from stb1 group by f1;
sql select sum_double(f1) from stb1 group by f1;
if $rows != 7 then
return -1
endi
if $data00 != 8 then
return -1
endi
if $data10 != 16 then
return -1
endi
if $data20 != 18 then
return -1
endi
if $data30 != 24 then
return -1
endi
if $data40 != 10 then
return -1
endi
if $data50 != 12 then
return -1
endi
if $data60 != 14 then
return -1
endi
sql select sum_double(f1) from stb1 interval (1h) order by ts desc;
if $rows != 12 then
return -1
endi
if $data00 != @21-04-08 16:00:00.000@ then
return -1
endi
if $data01 != 8 then
return -1
endi
if $data10 != @21-04-08 12:00:00.000@ then
return -1
endi
if $data11 != 4 then
return -1
endi
if $data20 != @21-04-08 11:00:00.000@ then
return -1
endi
if $data21 != 2 then
return -1
endi
if $data30 != @21-04-08 10:00:00.000@ then
return -1
endi
if $data31 != 6 then
return -1
endi
if $data40 != @21-04-01 19:00:00.000@ then
return -1
endi
if $data41 != 4 then
return -1
endi
if $data50 != @21-03-25 19:00:00.000@ then
return -1
endi
if $data51 != 2 then
return -1
endi
if $data60 != @21-03-25 10:00:00.000@ then
return -1
endi
if $data61 != 14 then
return -1
endi
if $data70 != @21-03-24 19:00:00.000@ then
return -1
endi
if $data71 != 30 then
return -1
endi
if $data80 != @21-03-23 19:00:00.000@ then
return -1
endi
if $data81 != 24 then
return -1
endi
if $data90 != @21-03-23 17:00:00.000@ then
return -1
endi
if $data91 != 2 then
return -1
endi
sql select add_one(f1) from stb1 limit 2;
if $rows != 2 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 3 then
return -1
endi
sql select sum_double(f1) from stb1 interval (1d) limit 2;
if $rows != 2 then
return -1
endi
if $data00 != @21-03-03 00:00:00.000@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != @21-03-13 00:00:00.000@ then
return -1
endi
if $data11 != 4 then
return -1
endi
sql_error select ts,sum_double(f1),f1 from stb1;
sql_error select add_one(f1),count(f1) from stb1;
sql_error select sum_double(f1),count(f1) from stb1;
sql_error select add_one(f1),top(f1,3) from stb1;
sql_error select add_one(f1) from stb1 interval(10a);
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/sh/sum_double.c
浏览文件 @
5ae38f32
...
...
@@ -10,6 +10,9 @@ typedef struct SUdfInit{
int
const_item
;
/* 0 if result is independent of arguments */
}
SUdfInit
;
#define TSDB_DATA_INT_NULL 0x80000000L
void
sum_double
(
char
*
data
,
short
itype
,
short
ibytes
,
int
numOfRows
,
long
long
*
ts
,
char
*
dataOutput
,
char
*
tsOutput
,
int
*
numOfOutput
,
short
otype
,
short
obytes
,
SUdfInit
*
buf
)
{
int
i
;
...
...
@@ -17,14 +20,17 @@ void sum_double(char* data, short itype, short ibytes, int numOfRows, long long*
printf
(
"sum_double input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p
\n
"
,
data
,
itype
,
numOfRows
,
ts
,
*
ts
,
dataOutput
,
tsOutput
,
numOfOutput
,
buf
);
if
(
itype
==
4
)
{
r
=*
(
int
*
)
dataOutput
;
*
numOfOutput
=
0
;
for
(
i
=
0
;
i
<
numOfRows
;
++
i
)
{
r
+=*
((
int
*
)
data
+
i
);
if
(
tsOutput
)
{
*
(
long
long
*
)
tsOutput
=
1000000
;
if
(
*
((
int
*
)
data
+
i
)
==
TSDB_DATA_INT_NULL
)
{
continue
;
}
*
numOfOutput
=
1
;
r
+=*
((
int
*
)
data
+
i
);
*
(
int
*
)
dataOutput
=
r
;
}
*
(
int
*
)
dataOutput
=
r
;
*
numOfOutput
=
1
;
printf
(
"sum_double out, dataoutput:%d, numOfOutput:%d
\n
"
,
*
(
int
*
)
dataOutput
,
*
numOfOutput
);
}
...
...
@@ -46,14 +52,18 @@ void sum_double_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t*
int
r
=
0
;
int
sum
=
0
;
printf
(
"sum_double_merge
dataoutput:%p, numOfOutput:%d, buf:%p
\n
"
,
dataOutput
,
*
numOf
Output
,
buf
);
printf
(
"sum_double_merge
numOfRows:%d, dataoutput:%p, buf:%p
\n
"
,
numOfRows
,
data
Output
,
buf
);
for
(
int
i
=
0
;
i
<
numOfRows
;
++
i
)
{
printf
(
"sum_double_merge %d - %d
\n
"
,
i
,
*
((
int
*
)
data
+
i
));
sum
+=*
((
int
*
)
data
+
i
);
}
*
(
int
*
)
dataOutput
+=
sum
;
*
numOfOutput
=
1
;
if
(
numOfRows
>
0
)
{
*
numOfOutput
=
1
;
}
else
{
*
numOfOutput
=
0
;
}
printf
(
"sum_double_merge, dataoutput:%d, numOfOutput:%d
\n
"
,
*
(
int
*
)
dataOutput
,
*
numOfOutput
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录