Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
84765ff6
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
84765ff6
编写于
2月 22, 2023
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor code
上级
9102c7a4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
24 deletion
+23
-24
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+2
-2
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+21
-22
未找到文件。
source/libs/function/src/builtins.c
浏览文件 @
84765ff6
...
@@ -517,14 +517,14 @@ static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
...
@@ -517,14 +517,14 @@ static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
return
invaildFuncParaValueErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaValueErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
uint8_t
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
i
))
->
resType
.
type
;
uint8_t
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
i
))
->
resType
.
type
;
if
(
!
IS_
SIGNED_NUMERIC_TYPE
(
paraType
)
&&
!
IS_UNSIGNED_
NUMERIC_TYPE
(
paraType
))
{
if
(
!
IS_NUMERIC_TYPE
(
paraType
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
}
}
// set result type
// set result type
if
(
numOfParams
>
2
)
{
if
(
numOfParams
>
2
)
{
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
128
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
};
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
512
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
};
}
else
{
}
else
{
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
,
.
type
=
TSDB_DATA_TYPE_DOUBLE
};
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
,
.
type
=
TSDB_DATA_TYPE_DOUBLE
};
}
}
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
84765ff6
...
@@ -1661,63 +1661,62 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) {
...
@@ -1661,63 +1661,62 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) {
}
}
int32_t
percentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
int32_t
percentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
if
(
pCtx
->
numOfParams
>
2
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SPercentileInfo
*
ppInfo
=
(
SPercentileInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
)
;
int32_t
code
=
0
;
SPercentileInfo
*
ppInfo
=
(
SPercentileInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
)
;
double
v
=
0
;
tMemBucket
*
pMemBucket
=
ppInfo
->
pMemBucket
;
tMemBucket
*
pMemBucket
=
ppInfo
->
pMemBucket
;
if
(
pMemBucket
==
NULL
||
pMemBucket
->
total
==
0
)
{
// check for null
if
(
pMemBucket
==
NULL
||
pMemBucket
->
total
==
0
)
{
// check for null
return
TSDB_CODE_FAILED
;
code
=
TSDB_CODE_FAILED
;
}
goto
_fin_error
;
}
if
(
pCtx
->
numOfParams
>
2
)
{
char
buf
[
512
]
=
{
0
};
char
buf
[
512
]
=
{
0
};
size_t
len
=
0
;
size_t
len
=
0
;
for
(
int32_t
i
=
1
;
i
<
pCtx
->
numOfParams
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<
pCtx
->
numOfParams
;
++
i
)
{
SVariant
*
pVal
=
&
pCtx
->
param
[
i
].
param
;
SVariant
*
pVal
=
&
pCtx
->
param
[
i
].
param
;
double
v
=
0
;
GET_TYPED_DATA
(
v
,
double
,
pVal
->
nType
,
&
pVal
->
i
);
GET_TYPED_DATA
(
v
,
double
,
pVal
->
nType
,
&
pVal
->
i
);
int32_t
code
=
getPercentile
(
pMemBucket
,
v
,
&
ppInfo
->
result
);
int32_t
code
=
getPercentile
(
pMemBucket
,
v
,
&
ppInfo
->
result
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
goto
_fin_error
;
}
}
len
+=
snprintf
(
varDataVal
(
buf
)
+
len
,
sizeof
(
buf
)
-
VARSTR_HEADER_SIZE
-
len
,
"%.6lf; "
,
ppInfo
->
result
);
len
+=
snprintf
(
varDataVal
(
buf
)
+
len
,
sizeof
(
buf
)
-
VARSTR_HEADER_SIZE
-
len
,
"%.6lf; "
,
ppInfo
->
result
);
}
}
tMemBucketDestroy
(
pMemBucket
);
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
varDataSetLen
(
buf
,
len
);
varDataSetLen
(
buf
,
len
);
colDataAppend
(
pCol
,
pBlock
->
info
.
rows
,
buf
,
false
);
colDataAppend
(
pCol
,
pBlock
->
info
.
rows
,
buf
,
false
);
tMemBucketDestroy
(
pMemBucket
);
return
pResInfo
->
numOfRes
;
return
pResInfo
->
numOfRes
;
}
else
{
}
else
{
SVariant
*
pVal
=
&
pCtx
->
param
[
1
].
param
;
SVariant
*
pVal
=
&
pCtx
->
param
[
1
].
param
;
int32_t
code
=
0
;
double
v
=
0
;
GET_TYPED_DATA
(
v
,
double
,
pVal
->
nType
,
&
pVal
->
i
);
GET_TYPED_DATA
(
v
,
double
,
pVal
->
nType
,
&
pVal
->
i
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
code
=
getPercentile
(
pMemBucket
,
v
,
&
ppInfo
->
result
);
SPercentileInfo
*
ppInfo
=
(
SPercentileInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_fin_error
;
tMemBucket
*
pMemBucket
=
ppInfo
->
pMemBucket
;
if
(
pMemBucket
!=
NULL
&&
pMemBucket
->
total
>
0
)
{
// check for null
code
=
getPercentile
(
pMemBucket
,
v
,
&
ppInfo
->
result
);
}
}
tMemBucketDestroy
(
pMemBucket
);
tMemBucketDestroy
(
pMemBucket
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
return
functionFinalize
(
pCtx
,
pBlock
);
return
functionFinalize
(
pCtx
,
pBlock
);
}
}
_fin_error:
tMemBucketDestroy
(
pMemBucket
);
return
code
;
}
}
bool
getApercentileFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
bool
getApercentileFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录