Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
022dacb5
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
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看板
未验证
提交
022dacb5
编写于
5月 07, 2022
作者:
G
Ganlin Zhao
提交者:
GitHub
5月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12199 from taosdata/feature/3.0_glzhao
feat(query): add histogram normalized processing
上级
500461cf
5763b248
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
1 deletion
+18
-1
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+17
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-0
未找到文件。
source/libs/function/src/builtinsimpl.c
浏览文件 @
022dacb5
...
@@ -1964,6 +1964,9 @@ bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultIn
...
@@ -1964,6 +1964,9 @@ bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultIn
}
}
char
*
binDesc
=
varDataVal
(
pCtx
->
param
[
2
].
param
.
pz
);
char
*
binDesc
=
varDataVal
(
pCtx
->
param
[
2
].
param
.
pz
);
int64_t
normalized
=
pCtx
->
param
[
3
].
param
.
i
;
int64_t
normalized
=
pCtx
->
param
[
3
].
param
.
i
;
if
(
normalized
!=
0
&&
normalized
!=
1
)
{
return
false
;
}
if
(
!
getHistogramBinDesc
(
pInfo
,
binDesc
,
binType
,
(
bool
)
normalized
))
{
if
(
!
getHistogramBinDesc
(
pInfo
,
binDesc
,
binType
,
(
bool
)
normalized
))
{
return
false
;
return
false
;
}
}
...
@@ -1972,7 +1975,6 @@ bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultIn
...
@@ -1972,7 +1975,6 @@ bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultIn
}
}
int32_t
histogramFunction
(
SqlFunctionCtx
*
pCtx
)
{
int32_t
histogramFunction
(
SqlFunctionCtx
*
pCtx
)
{
int32_t
numOfElems
=
0
;
SHistoFuncInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SHistoFuncInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
...
@@ -1983,6 +1985,8 @@ int32_t histogramFunction(SqlFunctionCtx *pCtx) {
...
@@ -1983,6 +1985,8 @@ int32_t histogramFunction(SqlFunctionCtx *pCtx) {
int32_t
start
=
pInput
->
startRowIndex
;
int32_t
start
=
pInput
->
startRowIndex
;
int32_t
numOfRows
=
pInput
->
numOfRows
;
int32_t
numOfRows
=
pInput
->
numOfRows
;
int32_t
numOfElems
=
0
;
int32_t
totalElems
=
0
;
for
(
int32_t
i
=
start
;
i
<
numOfRows
+
start
;
++
i
)
{
for
(
int32_t
i
=
start
;
i
<
numOfRows
+
start
;
++
i
)
{
if
(
pCol
->
hasNull
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
if
(
pCol
->
hasNull
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
...
@@ -1997,9 +2001,21 @@ int32_t histogramFunction(SqlFunctionCtx *pCtx) {
...
@@ -1997,9 +2001,21 @@ int32_t histogramFunction(SqlFunctionCtx *pCtx) {
for
(
int32_t
k
=
0
;
k
<
pInfo
->
numOfBins
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
pInfo
->
numOfBins
;
++
k
)
{
if
(
v
>
pInfo
->
bins
[
k
].
lower
&&
v
<=
pInfo
->
bins
[
k
].
upper
)
{
if
(
v
>
pInfo
->
bins
[
k
].
lower
&&
v
<=
pInfo
->
bins
[
k
].
upper
)
{
pInfo
->
bins
[
k
].
count
++
;
pInfo
->
bins
[
k
].
count
++
;
totalElems
++
;
break
;
break
;
}
}
}
}
}
if
(
pInfo
->
normalized
)
{
for
(
int32_t
k
=
0
;
k
<
pInfo
->
numOfBins
;
++
k
)
{
if
(
totalElems
!=
0
)
{
pInfo
->
bins
[
k
].
percentage
=
pInfo
->
bins
[
k
].
count
/
(
double
)
totalElems
;
}
else
{
pInfo
->
bins
[
k
].
percentage
=
0
;
}
}
}
}
SET_VAL
(
GET_RES_INFO
(
pCtx
),
numOfElems
,
pInfo
->
numOfBins
);
SET_VAL
(
GET_RES_INFO
(
pCtx
),
numOfElems
,
pInfo
->
numOfBins
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
022dacb5
...
@@ -481,6 +481,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
...
@@ -481,6 +481,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
TSDB_CODE_SUCCESS
)
{
TSDB_CODE_SUCCESS
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
}
*
(
int64_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
}
else
{
}
else
{
switch
(
pVal
->
node
.
resType
.
type
)
{
switch
(
pVal
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_NULL
:
case
TSDB_DATA_TYPE_NULL
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录