Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
55d11618
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
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) {
...
@@ -703,7 +703,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pInput
->
colDataAggIsSet
)
{
if
(
pInput
->
colDataAggIsSet
)
{
numOfElems
=
pInput
->
numOfRows
-
pAgg
->
numOfNull
;
numOfElems
=
pInput
->
numOfRows
-
pAgg
->
numOfNull
;
ASSERT
(
pInput
->
numOfRows
==
pInput
->
totalRows
&&
numOfElems
>=
0
);
ASSERT
(
pInput
->
numOfRows
==
pInput
->
totalRows
&&
numOfElems
>=
0
);
if
(
numOfElems
==
0
)
{
if
(
numOfElems
==
0
)
{
return
numOfElems
;
return
numOfElems
;
}
}
...
@@ -722,48 +721,79 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -722,48 +721,79 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
// the index is the original position, not the relative position
// the index is the original position, not the relative position
TSKEY
key
=
(
pCtx
->
ptsList
!=
NULL
)
?
pCtx
->
ptsList
[
index
]
:
TSKEY_INITIAL_VAL
;
TSKEY
key
=
(
pCtx
->
ptsList
!=
NULL
)
?
pCtx
->
ptsList
[
index
]
:
TSKEY_INITIAL_VAL
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
if
(
!
pBuf
->
assign
)
{
int64_t
prev
=
0
;
pBuf
->
v
=
*
(
int64_t
*
)
tval
;
GET_TYPED_DATA
(
prev
,
int64_t
,
type
,
pBuf
->
v
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
int64_t
val
=
GET_INT64_VAL
(
tval
);
}
if
((
prev
<
val
)
^
isMinFunc
)
{
}
else
{
pBuf
->
v
=
val
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
for
(
int32_t
i
=
0
;
i
<
(
pCtx
)
->
subsidiaries
.
num
;
++
i
)
{
int64_t
prev
=
0
;
SqlFunctionCtx
*
__ctx
=
pCtx
->
subsidiaries
.
pCtx
[
i
];
GET_TYPED_DATA
(
prev
,
int64_t
,
type
,
&
pBuf
->
v
);
if
(
__ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
// TODO refactor
__ctx
->
tag
.
i
=
key
;
int64_t
val
=
GET_INT64_VAL
(
tval
);
__ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
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);
// }
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
__ctx
->
fpSet
.
process
(
__ctx
);
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
uint64_t
prev
=
0
;
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);
// }
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
);
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
double
val
=
GET_DOUBLE_VAL
(
tval
);
}
if
((
prev
<
val
)
^
isMinFunc
)
{
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
pBuf
->
v
=
val
;
uint64_t
prev
=
0
;
GET_TYPED_DATA
(
prev
,
uint64_t
,
type
,
pBuf
->
v
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
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
;
}
}
}
}
else
if
(
type
==
TSDB_DATA_TYPE_FLOAT
)
{
double
prev
=
0
;
GET_TYPED_DATA
(
prev
,
int64_t
,
type
,
&
pBuf
->
v
);
__ctx
->
fpSet
.
process
(
__ctx
);
double
val
=
GET_DOUBLE_VAL
(
tval
);
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_DOUBLE
)
{
double
val
=
GET_DOUBLE_VAL
(
tval
);
UPDATE_DATA
(
pCtx
,
*
(
double
*
)
&
pBuf
->
v
,
val
,
numOfElems
,
isMinFunc
,
key
);
}
else
if
(
type
==
TSDB_DATA_TYPE_FLOAT
)
{
double
val
=
GET_DOUBLE_VAL
(
tval
);
UPDATE_DATA
(
pCtx
,
*
(
float
*
)
&
pBuf
->
v
,
val
,
numOfElems
,
isMinFunc
,
key
);
}
}
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
...
@@ -1058,7 +1088,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1058,7 +1088,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
}
}
}
else
if
(
type
==
TSDB_DATA_TYPE_FLOAT
)
{
}
else
if
(
type
==
TSDB_DATA_TYPE_FLOAT
)
{
float
*
pData
=
(
float
*
)
pCol
->
pData
;
float
*
pData
=
(
float
*
)
pCol
->
pData
;
float
*
val
=
(
float
*
)
&
pBuf
->
v
;
double
*
val
=
(
double
*
)
&
pBuf
->
v
;
for
(
int32_t
i
=
start
;
i
<
start
+
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
start
;
i
<
start
+
numOfRows
;
++
i
)
{
if
((
pCol
->
hasNull
)
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
if
((
pCol
->
hasNull
)
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
...
@@ -1119,10 +1149,14 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
...
@@ -1119,10 +1149,14 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
// todo assign the tag value
// todo assign the tag value
int32_t
currentRow
=
pBlock
->
info
.
rows
;
int32_t
currentRow
=
pBlock
->
info
.
rows
;
if
(
type
)
if
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_FLOAT
)
{
colDataAppend
(
pCol
,
currentRow
,
(
const
char
*
)
&
pRes
->
v
,
false
);
float
v
=
*
(
double
*
)
&
pRes
->
v
;
setSelectivityValue
(
pCtx
,
pBlock
,
&
pRes
->
tuplePos
,
currentRow
);
colDataAppend
(
pCol
,
currentRow
,
(
const
char
*
)
&
v
,
false
);
}
else
{
colDataAppend
(
pCol
,
currentRow
,
(
const
char
*
)
&
pRes
->
v
,
false
);
}
setSelectivityValue
(
pCtx
,
pBlock
,
&
pRes
->
tuplePos
,
currentRow
);
return
pEntryInfo
->
numOfRes
;
return
pEntryInfo
->
numOfRes
;
}
}
...
...
tests/script/tsim/insert/basic0.sim
浏览文件 @
55d11618
...
@@ -140,7 +140,8 @@ endi
...
@@ -140,7 +140,8 @@ endi
if $data00 != -13 then
if $data00 != -13 then
return -1
return -1
endi
endi
if $data01 != -2.30000 then
if $data01 != -2.30000 then
print expect -2.30000, actual: $data01
return -1
return -1
endi
endi
if $data02 != -3.300000000 then
if $data02 != -3.300000000 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录