Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
20e9a1fb
T
TDengine
项目概览
loser646
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
20e9a1fb
编写于
6月 10, 2021
作者:
H
haojun Liao
提交者:
GitHub
6月 10, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6450 from taosdata/feature/query
[td-4673]<fix>: fix bug in derivative.
上级
1970a31b
1cde4253
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
81 addition
and
12 deletion
+81
-12
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+6
-6
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+5
-2
src/query/inc/qTableMeta.h
src/query/inc/qTableMeta.h
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+1
-1
tests/script/general/parser/function.sim
tests/script/general/parser/function.sim
+68
-2
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
20e9a1fb
...
...
@@ -6477,13 +6477,13 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char*
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
int32_t
f
unctId
=
pExpr
->
base
.
functionId
;
int32_t
f
=
pExpr
->
base
.
functionId
;
/*
* group by normal columns.
* Check if the column projection is identical to the group by column or not
*/
if
(
f
unctId
==
TSDB_FUNC_PRJ
&&
pExpr
->
base
.
colInfo
.
colId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
f
==
TSDB_FUNC_PRJ
&&
pExpr
->
base
.
colInfo
.
colId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
bool
qualified
=
false
;
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
j
)
{
SColIndex
*
pColIndex
=
taosArrayGet
(
pQueryInfo
->
groupbyExpr
.
columnInfo
,
j
);
...
...
@@ -6498,12 +6498,12 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char*
}
}
if
(
IS_MULTIOUTPUT
(
aAggs
[
f
unctId
].
status
)
&&
functId
!=
TSDB_FUNC_TOP
&&
functId
!=
TSDB_FUNC_BOTTOM
&&
f
unctId
!=
TSDB_FUNC_DIFF
&&
functId
!=
TSDB_FUNC_TAGPRJ
&&
functId
!=
TSDB_FUNC_PRJ
)
{
if
(
IS_MULTIOUTPUT
(
aAggs
[
f
].
status
)
&&
f
!=
TSDB_FUNC_TOP
&&
f
!=
TSDB_FUNC_BOTTOM
&&
f
!=
TSDB_FUNC_DIFF
&&
f
!=
TSDB_FUNC_DERIVATIVE
&&
f
!=
TSDB_FUNC_TAGPRJ
&&
f
!=
TSDB_FUNC_PRJ
)
{
return
invalidOperationMsg
(
msg
,
msg1
);
}
if
(
f
unctId
==
TSDB_FUNC_COUNT
&&
pExpr
->
base
.
colInfo
.
colIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
f
==
TSDB_FUNC_COUNT
&&
pExpr
->
base
.
colInfo
.
colIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
return
invalidOperationMsg
(
msg
,
msg1
);
}
}
...
...
@@ -7953,7 +7953,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
pQueryInfo
->
arithmeticOnAgg
=
tsIsArithmeticQueryOnAggResult
(
pQueryInfo
);
pQueryInfo
->
orderProjectQuery
=
tscOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
);
pQueryInfo
->
diffQuery
=
tscIsDiffQuery
(
pQueryInfo
);
//
pQueryInfo->diffQuery = tscIsDiffQuery(pQueryInfo);
SExprInfo
**
p
=
NULL
;
int32_t
numOfExpr
=
0
;
...
...
src/client/src/tscUtil.c
浏览文件 @
20e9a1fb
...
...
@@ -223,6 +223,7 @@ bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex) {
functionId
!=
TSDB_FUNC_ARITHM
&&
functionId
!=
TSDB_FUNC_TS_COMP
&&
functionId
!=
TSDB_FUNC_DIFF
&&
functionId
!=
TSDB_FUNC_DERIVATIVE
&&
functionId
!=
TSDB_FUNC_TS_DUMMY
&&
functionId
!=
TSDB_FUNC_TID_TAG
)
{
return
false
;
...
...
@@ -463,11 +464,13 @@ bool tscIsDiffQuery(SQueryInfo* pQueryInfo) {
size_t
num
=
tscNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
==
NULL
||
pExpr
->
base
.
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
int32_t
f
=
pExpr
->
base
.
functionId
;
if
(
pExpr
==
NULL
||
f
==
TSDB_FUNC_TS_DUMMY
)
{
continue
;
}
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_DIFF
)
{
if
(
f
==
TSDB_FUNC_DIFF
||
f
==
TSDB_FUNC_DERIVATIVE
)
{
return
true
;
}
}
...
...
src/query/inc/qTableMeta.h
浏览文件 @
20e9a1fb
...
...
@@ -138,7 +138,7 @@ typedef struct SQueryInfo {
bool
hasFilter
;
bool
onlyTagQuery
;
bool
orderProjectQuery
;
bool
diffQuery
;
//
bool diffQuery;
bool
stateWindow
;
}
SQueryInfo
;
...
...
src/query/src/qExecutor.c
浏览文件 @
20e9a1fb
...
...
@@ -3157,7 +3157,7 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf
// re-estabilish output buffer pointer.
int32_t
functionId
=
pBInfo
->
pCtx
[
i
].
functionId
;
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
)
{
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
||
functionId
==
TSDB_FUNC_DERIVATIVE
)
{
pBInfo
->
pCtx
[
i
].
ptsOutputBuf
=
pBInfo
->
pCtx
[
0
].
pOutput
;
}
}
...
...
tests/script/general/parser/function.sim
浏览文件 @
20e9a1fb
...
...
@@ -935,9 +935,10 @@ endi
print ===========================> derivative
sql drop table t1
sql drop table tx;
sql drop table m1;
sql drop table
if exists
m1;
sql drop table if exists tm0;
sql drop table if exists tm1;
sql create table tm0(ts timestamp, k double)
sql insert into tm0 values('2015-08-18T00:00:00Z', 2.064) ('2015-08-18T00:06:00Z', 2.116) ('2015-08-18T00:12:00Z', 2.028)
sql insert into tm0 values('2015-08-18T00:18:00Z', 2.126) ('2015-08-18T00:24:00Z', 2.041) ('2015-08-18T00:30:00Z', 2.051)
...
...
@@ -1053,4 +1054,69 @@ endi
sql_error select derivative(k, 6m, 1) from tm0 interval(1s);
sql_error select derivative(k, 6m, 1) from tm0 session(ts, 1s);
sql_error select derivative(k, 6m, 1) from tm0 group by k;
sql_error select derivative(k, 6m, 1) from
\ No newline at end of file
sql drop table if exists tm0
sql drop table if exists m1
sql create table m1 (ts timestamp, k double ) tags(a int);
sql create table if not exists t0 using m1 tags(1);
sql create table if not exists t1 using m1 tags(2);
sql insert into t0 values('2020-1-1 1:1:1', 1);
sql insert into t0 values('2020-1-1 1:1:3', 3);
sql insert into t0 values('2020-1-1 1:2:4', 4);
sql insert into t0 values('2020-1-1 1:2:5', 5);
sql insert into t0 values('2020-1-1 1:2:6', 6);
sql insert into t0 values('2020-1-1 1:3:7', 7);
sql insert into t0 values('2020-1-1 1:3:8', 8);
sql insert into t0 values('2020-1-1 1:3:9', 9);
sql insert into t0 values('2020-1-1 1:4:10', 10);
sql insert into t1 values('2020-1-1 1:1:2', 2);
sql insert into t1 values('2020-1-1 1:1:4', 20);
sql insert into t1 values('2020-1-1 1:1:6', 200);
sql insert into t1 values('2020-1-1 1:1:8', 2000);
sql insert into t1 values('2020-1-1 1:1:10', 20000);
sql_error select derivative(k, 1s, 0) from m1;
sql_error select derivative(k, 1s, 0) from m1 group by a;
sql select derivative(k, 1s, 0) from m1 group by tbname
if $rows != 12 then
return -1
endi
if $data00 != @20-01-01 01:01:03.000@ then
return -1
endi
if $data01 != 1.000000000 then
return -1
endi
if $data02 != @t0@ then
return -1
endi
if $data10 != @20-01-01 01:02:04.000@ then
return -1
endi
if $data11 != 0.016393443 then
return -1
endi
if $data12 != t0 then
return -1
endi
if $data90 != @20-01-01 01:01:06.000@ then
return -1
endi
if $data91 != 90.000000000 then
return -1
endi
if $data92 != t1 then
return -1
endi
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录