Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b62d3759
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看板
提交
b62d3759
编写于
3月 10, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix error in subquery order by ts
上级
a7920d00
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
40 addition
and
10 deletion
+40
-10
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+6
-0
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+3
-3
tests/develop-test/2-query/function_state.py
tests/develop-test/2-query/function_state.py
+2
-7
tests/develop-test/2-query/function_tail.py
tests/develop-test/2-query/function_tail.py
+14
-0
tests/develop-test/2-query/function_unique.py
tests/develop-test/2-query/function_unique.py
+14
-0
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+1
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
b62d3759
...
...
@@ -2696,6 +2696,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
const
char
*
msg28
=
"the second paramter of diff should be 0 or 1"
;
const
char
*
msg29
=
"key timestamp column cannot be used to unique/mode/tail function"
;
const
char
*
msg30
=
"offset is out of range [0, 100]"
;
const
char
*
msg31
=
"state function can not be used in subquery"
;
switch
(
functionId
)
{
case
TSDB_FUNC_COUNT
:
{
...
...
@@ -2848,6 +2849,11 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
}
}
if
((
functionId
==
TSDB_FUNC_STATE_COUNT
||
functionId
==
TSDB_FUNC_STATE_DURATION
)
&&
pQueryInfo
->
pUpstream
!=
NULL
&&
taosArrayGetSize
(
pQueryInfo
->
pUpstream
)
>
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg31
);
}
STableComInfo
info
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
// functions can not be applied to tags
...
...
src/query/src/qAggMain.c
浏览文件 @
b62d3759
...
...
@@ -2631,7 +2631,7 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) {
tValuePair
**
tvp
=
pRes
->
res
;
// user specify the order of output by sort the result according to timestamp
if
(
pCtx
->
param
[
2
].
i64
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
pCtx
->
param
[
2
].
i64
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
||
pCtx
->
param
[
2
].
i64
==
TSDB_RES_COL_ID
)
{
__compar_fn_t
comparator
=
(
pCtx
->
param
[
3
].
i64
==
TSDB_ORDER_ASC
)
?
resAscComparFn
:
resDescComparFn
;
qsort
(
tvp
,
(
size_t
)
pResInfo
->
numOfRes
,
POINTER_BYTES
,
comparator
);
}
else
/*if (pCtx->param[2].i64 > PRIMARYKEY_TIMESTAMP_COL_INDEX)*/
{
...
...
@@ -5402,7 +5402,7 @@ static void unique_func_finalizer(SQLFunctionCtx *pCtx) {
}
SortSupporter
support
=
{
0
};
// user specify the order of output by sort the result according to timestamp
if
(
pCtx
->
param
[
2
].
i64
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
pCtx
->
param
[
2
].
i64
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
||
pCtx
->
param
[
2
].
i64
==
TSDB_RES_COL_ID
)
{
support
.
dataOffset
=
0
;
support
.
comparFn
=
compareInt64Val
;
}
else
{
...
...
@@ -5701,7 +5701,7 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) {
SortSupporter
support
=
{
0
};
// user specify the order of output by sort the result according to timestamp
if
(
pCtx
->
param
[
2
].
i64
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
pCtx
->
param
[
2
].
i64
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
&&
pCtx
->
param
[
2
].
i64
!=
TSDB_RES_COL_ID
)
{
support
.
dataOffset
=
sizeof
(
int64_t
);
support
.
comparFn
=
getComparFunc
(
type
,
0
);
taosqsort
(
data
,
(
size_t
)
GET_RES_INFO
(
pCtx
)
->
numOfRes
,
size
,
&
support
,
sortCompareFn
);
...
...
tests/develop-test/2-query/function_state.py
浏览文件 @
b62d3759
...
...
@@ -32,7 +32,7 @@ class TDTestCase:
def
run
(
self
):
print
(
"running {}"
.
format
(
__file__
))
tdSql
.
execute
(
"drop database if exists statef"
)
tdSql
.
execute
(
"create database if not exists statef"
)
tdSql
.
execute
(
"create database if not exists statef
PRECISION 'ns'
"
)
tdSql
.
execute
(
'use statef'
)
tdSql
.
execute
(
'create table sstatef (ts timestamp, dbig bigint, dsmall smallint, dbool bool, dtiny tinyint unsigned, dfloat float, ddouble double, dnchar nchar(4093), dbinary binary(64), dtime timestamp) tags (tbinary nchar(4093), tint int)'
)
...
...
@@ -221,12 +221,7 @@ class TDTestCase:
tdSql
.
query
(
'select stateDuration(dtiny,ne,9.0,1s) from sstatef group by tbname having stateDuration(dtiny,ne,9.0,1s) > 0'
)
#subquery
tdSql
.
query
(
'select stateDuration(dfloat,Ge,3.32323) from (select ts,dfloat from statef2)'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
2
,
0
)
tdSql
.
checkData
(
1
,
2
,
172798
)
tdSql
.
checkData
(
2
,
2
,
None
)
tdSql
.
checkData
(
3
,
2
,
-
1
)
tdSql
.
error
(
'select stateDuration(dfloat,Ge,3.32323) from (select ts,dfloat from statef2)'
)
#union
tdSql
.
query
(
'select stateCount(dfloat,Ge,3.32323) from statef1 union all select stateCount(dfloat,Ge,3.32323) from statef2'
)
...
...
tests/develop-test/2-query/function_tail.py
浏览文件 @
b62d3759
...
...
@@ -321,6 +321,20 @@ class TDTestCase:
tdSql
.
checkData
(
1
,
0
,
"2022-01-01 08:00:07"
)
tdSql
.
checkData
(
1
,
1
,
"试试"
)
tdSql
.
query
(
'select tail(dbig, 3) from (select * from stail) order by ts'
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
"2022-01-01 08:00:06"
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
1
,
0
,
"2022-01-01 08:00:07"
)
tdSql
.
checkData
(
1
,
1
,
9
)
tdSql
.
query
(
'select tail(dbig, 3) from (select * from stail) order by ts desc'
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
"2022-01-24 00:31:32"
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
0
,
"2022-01-01 08:00:07"
)
tdSql
.
checkData
(
1
,
1
,
9
)
#union
tdSql
.
query
(
'select tail(dtiny,2) from tail1 union all select tail(dtiny,2) from tail2'
)
tdSql
.
checkRows
(
4
)
...
...
tests/develop-test/2-query/function_unique.py
浏览文件 @
b62d3759
...
...
@@ -256,6 +256,20 @@ class TDTestCase:
tdSql
.
query
(
'select unique(num) from (select * from unique where voltage > 1)'
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
'select unique(num) from (select * from unique) order by ts'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
"2021-10-15 00:00:01"
)
tdSql
.
checkData
(
0
,
1
,
2
)
tdSql
.
checkData
(
1
,
0
,
"2021-12-25 01:31:31"
)
tdSql
.
checkData
(
1
,
1
,
4
)
tdSql
.
query
(
'select unique(num) from (select * from unique) order by ts desc'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
"2021-12-25 01:31:31"
)
tdSql
.
checkData
(
0
,
1
,
4
)
tdSql
.
checkData
(
1
,
0
,
"2021-10-15 00:00:01"
)
tdSql
.
checkData
(
1
,
1
,
2
)
#union
tdSql
.
query
(
'select unique(voltage) from d002 union all select unique(voltage) from d003'
)
tdSql
.
checkRows
(
5
)
...
...
tests/parallel_test/cases.task
浏览文件 @
b62d3759
...
...
@@ -790,4 +790,5 @@
3,,script,./test.sh -f general/compute/scalar_str_concat_len.sim
3,,develop-test,python3 ./test.py -f 2-query/function_tail.py
2,,develop-test,python3 ./test.py -f 2-query/function_unique.py
1,,develop-test,python3 ./test.py -f 2-query/function_state.py
1,,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录