Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
55d11618
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看板
提交
55d11618
编写于
5月 09, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): fix float value min/max query error.
上级
ea18b8a7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
75 addition
and
40 deletion
+75
-40
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+73
-39
tests/script/tsim/insert/basic0.sim
tests/script/tsim/insert/basic0.sim
+2
-1
未找到文件。
source/libs/function/src/builtinsimpl.c
浏览文件 @
55d11618
...
...
@@ -703,7 +703,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pInput
->
colDataAggIsSet
)
{
numOfElems
=
pInput
->
numOfRows
-
pAgg
->
numOfNull
;
ASSERT
(
pInput
->
numOfRows
==
pInput
->
totalRows
&&
numOfElems
>=
0
);
if
(
numOfElems
==
0
)
{
return
numOfElems
;
}
...
...
@@ -722,48 +721,79 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
// the index is the original position, not the relative position
TSKEY
key
=
(
pCtx
->
ptsList
!=
NULL
)
?
pCtx
->
ptsList
[
index
]
:
TSKEY_INITIAL_VAL
;
if
(
!
pBuf
->
assign
)
{
pBuf
->
v
=
*
(
int64_t
*
)
tval
;
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
else
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
int64_t
prev
=
0
;
GET_TYPED_DATA
(
prev
,
int64_t
,
type
,
pBuf
->
v
);
GET_TYPED_DATA
(
prev
,
int64_t
,
type
,
&
pBuf
->
v
);
int64_t
val
=
GET_INT64_VAL
(
tval
);
if
((
prev
<
val
)
^
isMinFunc
)
{
pBuf
->
v
=
val
;
for
(
int32_t
i
=
0
;
i
<
(
pCtx
)
->
subsidiaries
.
num
;
++
i
)
{
SqlFunctionCtx
*
__ctx
=
pCtx
->
subsidiaries
.
pCtx
[
i
];
if
(
__ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
// TODO refactor
__ctx
->
tag
.
i
=
key
;
__ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
}
__ctx
->
fpSet
.
process
(
__ctx
);
}
//
for (int32_t i = 0; i < (pCtx)->subsidiaries.num; ++i) {
//
SqlFunctionCtx* __ctx = pCtx->subsidiaries.pCtx[i];
//
if (__ctx->functionId == FUNCTION_TS_DUMMY) { // TODO refactor
//
__ctx->tag.i = key;
//
__ctx->tag.nType = TSDB_DATA_TYPE_BIGINT;
//
}
//
//
__ctx->fpSet.process(__ctx);
//
}
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
uint64_t
prev
=
0
;
GET_TYPED_DATA
(
prev
,
uint64_t
,
type
,
pBuf
->
v
);
GET_TYPED_DATA
(
prev
,
uint64_t
,
type
,
&
pBuf
->
v
);
uint64_t
val
=
GET_UINT64_VAL
(
tval
);
if
((
prev
<
val
)
^
isMinFunc
)
{
pBuf
->
v
=
val
;
for
(
int32_t
i
=
0
;
i
<
(
pCtx
)
->
subsidiaries
.
num
;
++
i
)
{
SqlFunctionCtx
*
__ctx
=
pCtx
->
subsidiaries
.
pCtx
[
i
];
if
(
__ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
// TODO refactor
__ctx
->
tag
.
i
=
key
;
__ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
}
__ctx
->
fpSet
.
process
(
__ctx
);
// for (int32_t i = 0; i < (pCtx)->subsidiaries.num; ++i) {
// SqlFunctionCtx* __ctx = pCtx->subsidiaries.pCtx[i];
// if (__ctx->functionId == FUNCTION_TS_DUMMY) { // TODO refactor
// __ctx->tag.i = key;
// __ctx->tag.nType = TSDB_DATA_TYPE_BIGINT;
// }
//
// __ctx->fpSet.process(__ctx);
// }
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
prev
=
0
;
GET_TYPED_DATA
(
prev
,
int64_t
,
type
,
&
pBuf
->
v
);
double
val
=
GET_DOUBLE_VAL
(
tval
);
UPDATE_DATA
(
pCtx
,
*
(
double
*
)
&
pBuf
->
v
,
val
,
numOfElems
,
isMinFunc
,
key
);
if
((
prev
<
val
)
^
isMinFunc
)
{
pBuf
->
v
=
val
;
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
else
if
(
type
==
TSDB_DATA_TYPE_FLOAT
)
{
double
prev
=
0
;
GET_TYPED_DATA
(
prev
,
int64_t
,
type
,
&
pBuf
->
v
);
double
val
=
GET_DOUBLE_VAL
(
tval
);
UPDATE_DATA
(
pCtx
,
*
(
float
*
)
&
pBuf
->
v
,
val
,
numOfElems
,
isMinFunc
,
key
);
if
((
prev
<
val
)
^
isMinFunc
)
{
pBuf
->
v
=
val
;
}
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
pBuf
->
assign
=
true
;
...
...
@@ -1058,7 +1088,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
}
}
else
if
(
type
==
TSDB_DATA_TYPE_FLOAT
)
{
float
*
pData
=
(
float
*
)
pCol
->
pData
;
float
*
val
=
(
float
*
)
&
pBuf
->
v
;
double
*
val
=
(
double
*
)
&
pBuf
->
v
;
for
(
int32_t
i
=
start
;
i
<
start
+
numOfRows
;
++
i
)
{
if
((
pCol
->
hasNull
)
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
...
...
@@ -1119,10 +1149,14 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
// todo assign the tag value
int32_t
currentRow
=
pBlock
->
info
.
rows
;
if
(
type
)
if
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_FLOAT
)
{
float
v
=
*
(
double
*
)
&
pRes
->
v
;
colDataAppend
(
pCol
,
currentRow
,
(
const
char
*
)
&
v
,
false
);
}
else
{
colDataAppend
(
pCol
,
currentRow
,
(
const
char
*
)
&
pRes
->
v
,
false
);
setSelectivityValue
(
pCtx
,
pBlock
,
&
pRes
->
tuplePos
,
currentRow
);
}
setSelectivityValue
(
pCtx
,
pBlock
,
&
pRes
->
tuplePos
,
currentRow
);
return
pEntryInfo
->
numOfRes
;
}
...
...
tests/script/tsim/insert/basic0.sim
浏览文件 @
55d11618
...
...
@@ -141,6 +141,7 @@ if $data00 != -13 then
return -1
endi
if $data01 != -2.30000 then
print expect -2.30000, actual: $data01
return -1
endi
if $data02 != -3.300000000 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录