Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f80ddebd
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f80ddebd
编写于
1月 07, 2021
作者:
H
haojun Liao
提交者:
GitHub
1月 07, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4849 from taosdata/feature/query
Feature/query
上级
204f50d6
2a141587
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
99 addition
and
53 deletion
+99
-53
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+29
-0
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+5
-3
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+1
-1
src/util/src/hash.c
src/util/src/hash.c
+0
-2
tests/script/general/parser/first_last_query.sim
tests/script/general/parser/first_last_query.sim
+1
-0
tests/script/general/parser/function.sim
tests/script/general/parser/function.sim
+12
-0
tests/script/general/parser/groupby.sim
tests/script/general/parser/groupby.sim
+4
-0
tests/script/general/parser/testSuite.sim
tests/script/general/parser/testSuite.sim
+47
-47
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
f80ddebd
...
@@ -5833,14 +5833,43 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
...
@@ -5833,14 +5833,43 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
doTagFunctionCheck
(
SQueryInfo
*
pQueryInfo
)
{
bool
tagProjection
=
false
;
bool
tableCounting
=
false
;
int32_t
numOfCols
=
(
int32_t
)
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
int32_t
functionId
=
pExpr
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TAGPRJ
)
{
tagProjection
=
true
;
continue
;
}
if
(
functionId
==
TSDB_FUNC_COUNT
)
{
assert
(
pExpr
->
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
);
tableCounting
=
true
;
}
}
return
(
tableCounting
&&
tagProjection
)
?
-
1
:
0
;
}
int32_t
doFunctionsCompatibleCheck
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
)
{
int32_t
doFunctionsCompatibleCheck
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
)
{
const
char
*
msg1
=
"functions/columns not allowed in group by query"
;
const
char
*
msg1
=
"functions/columns not allowed in group by query"
;
const
char
*
msg2
=
"projection query on columns not allowed"
;
const
char
*
msg2
=
"projection query on columns not allowed"
;
const
char
*
msg3
=
"group by not allowed on projection query"
;
const
char
*
msg3
=
"group by not allowed on projection query"
;
const
char
*
msg4
=
"retrieve tags not compatible with group by or interval query"
;
const
char
*
msg4
=
"retrieve tags not compatible with group by or interval query"
;
const
char
*
msg5
=
"functions can not be mixed up"
;
// only retrieve tags, group by is not supportted
// only retrieve tags, group by is not supportted
if
(
tscQueryTags
(
pQueryInfo
))
{
if
(
tscQueryTags
(
pQueryInfo
))
{
if
(
doTagFunctionCheck
(
pQueryInfo
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
}
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
>
0
||
pQueryInfo
->
interval
.
interval
>
0
)
{
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
>
0
||
pQueryInfo
->
interval
.
interval
>
0
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
else
{
}
else
{
...
...
src/query/src/qAggMain.c
浏览文件 @
f80ddebd
...
@@ -1268,12 +1268,14 @@ static void min_function_f(SQLFunctionCtx *pCtx, int32_t index) {
...
@@ -1268,12 +1268,14 @@ static void min_function_f(SQLFunctionCtx *pCtx, int32_t index) {
}
}
static
void
stddev_function
(
SQLFunctionCtx
*
pCtx
)
{
static
void
stddev_function
(
SQLFunctionCtx
*
pCtx
)
{
// the second stage to calculate standard deviation
SStddevInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SStddevInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
if
(
pStd
->
stage
==
0
)
{
// the first stage is to calculate average value
if
(
pStd
->
stage
==
0
)
{
// the first stage is to calculate average value
avg_function
(
pCtx
);
avg_function
(
pCtx
);
}
else
{
}
else
if
(
pStd
->
num
>
0
)
{
// the second stage to calculate standard deviation
// if pStd->num == 0, there are no numbers in the first round check. No need to do the second round
double
*
retVal
=
&
pStd
->
res
;
double
*
retVal
=
&
pStd
->
res
;
double
avg
=
pStd
->
avg
;
double
avg
=
pStd
->
avg
;
...
...
src/query/src/qExecutor.c
浏览文件 @
f80ddebd
...
@@ -548,7 +548,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo *pWindowResInfo, int64_t t
...
@@ -548,7 +548,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo *pWindowResInfo, int64_t t
if
(
pWindowResInfo
->
curIndex
==
-
1
)
{
// the first window, from the previous stored value
if
(
pWindowResInfo
->
curIndex
==
-
1
)
{
// the first window, from the previous stored value
w
.
skey
=
pWindowResInfo
->
prevSKey
;
w
.
skey
=
pWindowResInfo
->
prevSKey
;
if
(
pQuery
->
interval
.
intervalUnit
==
'n'
||
pQuery
->
interval
.
intervalUnit
==
'y'
)
{
if
(
pQuery
->
interval
.
intervalUnit
==
'n'
||
pQuery
->
interval
.
intervalUnit
==
'y'
)
{
w
.
ekey
=
taosTimeAdd
(
w
.
skey
,
pQuery
->
interval
.
interval
,
pQuery
->
interval
.
intervalUnit
,
pQuery
->
precision
);
w
.
ekey
=
taosTimeAdd
(
w
.
skey
,
pQuery
->
interval
.
interval
,
pQuery
->
interval
.
intervalUnit
,
pQuery
->
precision
)
-
1
;
}
else
{
}
else
{
w
.
ekey
=
w
.
skey
+
pQuery
->
interval
.
interval
-
1
;
w
.
ekey
=
w
.
skey
+
pQuery
->
interval
.
interval
-
1
;
}
}
...
...
src/util/src/hash.c
浏览文件 @
f80ddebd
...
@@ -477,8 +477,6 @@ void taosHashEmpty(SHashObj *pHashObj) {
...
@@ -477,8 +477,6 @@ void taosHashEmpty(SHashObj *pHashObj) {
return
;
return
;
}
}
uDebug
(
"hash:%p cleanup hash table"
,
pHashObj
);
SHashNode
*
pNode
,
*
pNext
;
SHashNode
*
pNode
,
*
pNext
;
__wr_lock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
__wr_lock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
...
...
tests/script/general/parser/first_last_query.sim
浏览文件 @
f80ddebd
...
@@ -37,6 +37,7 @@ if $data02 != 0 then
...
@@ -37,6 +37,7 @@ if $data02 != 0 then
endi
endi
print data03 = $data03
print data03 = $data03
if $data03 != 0.00000 then
if $data03 != 0.00000 then
print expect 0.00000, actual: $data03
return -1
return -1
endi
endi
if $data04 != 0.000000000 then
if $data04 != 0.000000000 then
...
...
tests/script/general/parser/function.sim
浏览文件 @
f80ddebd
...
@@ -361,3 +361,15 @@ endi
...
@@ -361,3 +361,15 @@ endi
if $data10 != @20-07-30 17:43:59.000@ then
if $data10 != @20-07-30 17:43:59.000@ then
return -1
return -1
endi
endi
print =================>td-2610
sql select stddev(k) from tm2 where ts='2020-12-29 18:46:19.109'
if $rows != 0 then
print expect 0, actual:$rows
return -1
endi
sql select twa(k) from tm2 where ts='2020-12-29 18:46:19.109'
if $rows != 0 then
return -1
endi
tests/script/general/parser/groupby.sim
浏览文件 @
f80ddebd
...
@@ -606,6 +606,10 @@ sql insert into t1 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.00
...
@@ -606,6 +606,10 @@ sql insert into t1 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.00
sql insert into t2 values ('2020-03-27 04:11:16.000', 1)('2020-03-27 04:11:17.000', 2) ('2020-03-27 04:11:18.000', 3) ('2020-03-27 04:11:19.000', 4) ;
sql insert into t2 values ('2020-03-27 04:11:16.000', 1)('2020-03-27 04:11:17.000', 2) ('2020-03-27 04:11:18.000', 3) ('2020-03-27 04:11:19.000', 4) ;
sql insert into t2 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.000', 2) ('2020-03-27 04:51:18.000', 3) ('2020-03-27 05:10:19.000', 4) ;
sql insert into t2 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.000', 2) ('2020-03-27 04:51:18.000', 3) ('2020-03-27 05:10:19.000', 4) ;
print =================>TD-2665
sql_error create table txx as select avg(c) as t from st;
sql_error create table txx1 as select avg(c) as t from t1;
print =================>TD-2236
print =================>TD-2236
sql select first(ts),last(ts) from t1 group by c;
sql select first(ts),last(ts) from t1 group by c;
if $rows != 4 then
if $rows != 4 then
...
...
tests/script/general/parser/testSuite.sim
浏览文件 @
f80ddebd
run general/parser/alter.sim
#
run general/parser/alter.sim
sleep 500
#
sleep 500
run general/parser/alter1.sim
#
run general/parser/alter1.sim
sleep 500
#
sleep 500
run general/parser/alter_stable.sim
#
run general/parser/alter_stable.sim
sleep 500
#
sleep 500
run general/parser/auto_create_tb.sim
#
run general/parser/auto_create_tb.sim
sleep 500
#
sleep 500
run general/parser/auto_create_tb_drop_tb.sim
#
run general/parser/auto_create_tb_drop_tb.sim
sleep 500
#
sleep 500
run general/parser/col_arithmetic_operation.sim
#
run general/parser/col_arithmetic_operation.sim
sleep 500
#
sleep 500
run general/parser/columnValue.sim
#
run general/parser/columnValue.sim
sleep 500
#
sleep 500
run general/parser/commit.sim
#
run general/parser/commit.sim
sleep 500
#
sleep 500
run general/parser/create_db.sim
#
run general/parser/create_db.sim
sleep 500
#
sleep 500
run general/parser/create_mt.sim
#
run general/parser/create_mt.sim
sleep 500
#
sleep 500
run general/parser/create_tb.sim
#
run general/parser/create_tb.sim
sleep 500
#
sleep 500
run general/parser/dbtbnameValidate.sim
#
run general/parser/dbtbnameValidate.sim
sleep 500
#
sleep 500
run general/parser/fill.sim
#
run general/parser/fill.sim
sleep 500
#
sleep 500
run general/parser/fill_stb.sim
#
run general/parser/fill_stb.sim
sleep 500
#
sleep 500
#run general/parser/fill_us.sim #
#
#
run general/parser/fill_us.sim #
sleep 500
#
sleep 500
run general/parser/first_last.sim
#
run general/parser/first_last.sim
sleep 500
#
sleep 500
run general/parser/import_commit1.sim
#
run general/parser/import_commit1.sim
sleep 500
#
sleep 500
run general/parser/import_commit2.sim
#
run general/parser/import_commit2.sim
sleep 500
#
sleep 500
run general/parser/import_commit3.sim
#
run general/parser/import_commit3.sim
sleep 500
#
sleep 500
#run general/parser/import_file.sim
#
#
run general/parser/import_file.sim
sleep 500
#
sleep 500
run general/parser/insert_tb.sim
#
run general/parser/insert_tb.sim
sleep 500
#
sleep 500
run general/parser/tags_dynamically_specifiy.sim
#
run general/parser/tags_dynamically_specifiy.sim
sleep 500
#
sleep 500
run general/parser/interp.sim
#
run general/parser/interp.sim
sleep 500
#
sleep 500
run general/parser/lastrow.sim
#
run general/parser/lastrow.sim
sleep 500
sleep 500
run general/parser/limit.sim
run general/parser/limit.sim
sleep 500
sleep 500
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录