Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
e19dc2b7
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
未验证
提交
e19dc2b7
编写于
9月 09, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
9月 09, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3446 from taosdata/feature/TD-1370
[TD-1370]<enhance>: support function count(1)
上级
eae082a5
ef4828d8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
8 deletion
+37
-8
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+22
-6
tests/script/general/compute/count.sim
tests/script/general/compute/count.sim
+15
-2
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
e19dc2b7
...
@@ -1597,13 +1597,14 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
...
@@ -1597,13 +1597,14 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
if
(
pItem
->
pNode
->
pParam
!=
NULL
)
{
if
(
pItem
->
pNode
->
pParam
!=
NULL
)
{
SStrToken
*
pToken
=
&
pItem
->
pNode
->
pParam
->
a
[
0
].
pNode
->
colInfo
;
if
(
pToken
->
z
==
NULL
||
pToken
->
n
==
0
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
tSQLExprItem
*
pParamElem
=
&
pItem
->
pNode
->
pParam
->
a
[
0
];
tSQLExprItem
*
pParamElem
=
&
pItem
->
pNode
->
pParam
->
a
[
0
];
if
(
pParamElem
->
pNode
->
nSQLOptr
==
TK_ALL
)
{
SStrToken
*
pToken
=
&
pParamElem
->
pNode
->
colInfo
;
short
sqlOptr
=
pParamElem
->
pNode
->
nSQLOptr
;
if
((
pToken
->
z
==
NULL
||
pToken
->
n
==
0
)
&&
(
TK_INTEGER
!=
sqlOptr
))
/*select count(1) from table*/
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
if
(
sqlOptr
==
TK_ALL
)
{
// select table.*
// select table.*
// check if the table name is valid or not
// check if the table name is valid or not
SStrToken
tmpToken
=
pParamElem
->
pNode
->
colInfo
;
SStrToken
tmpToken
=
pParamElem
->
pNode
->
colInfo
;
...
@@ -1615,6 +1616,21 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
...
@@ -1615,6 +1616,21 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
index
=
(
SColumnIndex
){
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
index
=
(
SColumnIndex
){
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
int32_t
size
=
tDataTypeDesc
[
TSDB_DATA_TYPE_BIGINT
].
nSize
;
int32_t
size
=
tDataTypeDesc
[
TSDB_DATA_TYPE_BIGINT
].
nSize
;
pExpr
=
tscSqlExprAppend
(
pQueryInfo
,
functionID
,
&
index
,
TSDB_DATA_TYPE_BIGINT
,
size
,
size
,
false
);
pExpr
=
tscSqlExprAppend
(
pQueryInfo
,
functionID
,
&
index
,
TSDB_DATA_TYPE_BIGINT
,
size
,
size
,
false
);
}
else
if
(
sqlOptr
==
TK_INTEGER
)
{
// select count(1) from table1
char
buf
[
8
]
=
{
0
};
int64_t
val
=
-
1
;
tVariant
*
pVariant
=
&
pParamElem
->
pNode
->
val
;
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_BIGINT
)
{
tVariantDump
(
pVariant
,
buf
,
TSDB_DATA_TYPE_BIGINT
,
true
);
val
=
GET_INT64_VAL
(
buf
);
}
if
(
val
==
1
)
{
index
=
(
SColumnIndex
){
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
int32_t
size
=
tDataTypeDesc
[
TSDB_DATA_TYPE_BIGINT
].
nSize
;
pExpr
=
tscSqlExprAppend
(
pQueryInfo
,
functionID
,
&
index
,
TSDB_DATA_TYPE_BIGINT
,
size
,
size
,
false
);
}
else
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
else
{
}
else
{
// count the number of meters created according to the super table
// count the number of meters created according to the super table
if
(
getColumnIndexByName
(
pCmd
,
pToken
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
getColumnIndexByName
(
pCmd
,
pToken
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
tests/script/general/compute/count.sim
浏览文件 @
e19dc2b7
...
@@ -52,6 +52,12 @@ if $data00 != $rowNum then
...
@@ -52,6 +52,12 @@ if $data00 != $rowNum then
return -1
return -1
endi
endi
sql select count(1) from $tb
print ===> select count(1) from $tb => $data00
if $data00 != $rowNum then
return -1
endi
sql select count(tbcol) from $tb
sql select count(tbcol) from $tb
print ===> $data00
print ===> $data00
if $data00 != $rowNum then
if $data00 != $rowNum then
...
@@ -102,13 +108,20 @@ if $data00 != $totalNum then
...
@@ -102,13 +108,20 @@ if $data00 != $totalNum then
return -1
return -1
endi
endi
print =============== step8
sql select count(1) from $mt
print ===> $data00
if $data00 != $totalNum then
return -1
endi
sql select count(tbcol) from $mt
sql select count(tbcol) from $mt
print ===> $data00
print ===> $data00
if $data00 != $totalNum then
if $data00 != $totalNum then
return -1
return -1
endi
endi
print =============== step
8
print =============== step
10
sql select count(tbcol) as c from $mt where ts < now + 4m
sql select count(tbcol) as c from $mt where ts < now + 4m
print ===> $data00
print ===> $data00
if $data00 != 50 then
if $data00 != 50 then
...
@@ -171,4 +184,4 @@ if $rows != 0 then
...
@@ -171,4 +184,4 @@ if $rows != 0 then
return -1
return -1
endi
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录