Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
0bca0444
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看板
提交
0bca0444
编写于
1月 14, 2021
作者:
Y
yihaoDeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-2571
上级
87e45c79
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
35 addition
and
4 deletion
+35
-4
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-0
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+2
-2
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+31
-2
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
0bca0444
...
@@ -223,6 +223,8 @@ typedef struct SQueryInfo {
...
@@ -223,6 +223,8 @@ typedef struct SQueryInfo {
int32_t
udColumnId
;
// current user-defined constant output field column id, monotonically decreases from TSDB_UD_COLUMN_INDEX
int32_t
udColumnId
;
// current user-defined constant output field column id, monotonically decreases from TSDB_UD_COLUMN_INDEX
int16_t
resColumnId
;
// result column id
int16_t
resColumnId
;
// result column id
bool
distinctTag
;
// distinct tag or not
}
SQueryInfo
;
}
SQueryInfo
;
typedef
struct
{
typedef
struct
{
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
0bca0444
...
@@ -1102,7 +1102,7 @@ static int64_t getNumOfResultLocal(SQueryInfo *pQueryInfo, SQLFunctionCtx *pCtx)
...
@@ -1102,7 +1102,7 @@ static int64_t getNumOfResultLocal(SQueryInfo *pQueryInfo, SQLFunctionCtx *pCtx)
* the number of output result is decided by main output
* the number of output result is decided by main output
*/
*/
int32_t
functionId
=
pCtx
[
j
].
functionId
;
int32_t
functionId
=
pCtx
[
j
].
functionId
;
if
(
functionId
==
TSDB_FUNC_TS
||
functionId
==
TSDB_FUNC_TAG
||
functionId
==
TSDB_FUNC_TAGPRJ
)
{
if
(
functionId
==
TSDB_FUNC_TS
||
functionId
==
TSDB_FUNC_TAG
)
{
continue
;
continue
;
}
}
...
@@ -1184,7 +1184,7 @@ bool needToMerge(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer, tFilePage
...
@@ -1184,7 +1184,7 @@ bool needToMerge(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer, tFilePage
int16_t
functionId
=
pLocalReducer
->
pCtx
[
0
].
functionId
;
int16_t
functionId
=
pLocalReducer
->
pCtx
[
0
].
functionId
;
// todo opt performance
// todo opt performance
if
((
/*functionId == TSDB_FUNC_PRJ || */
functionId
==
TSDB_FUNC_ARITHM
)
||
(
tscIsProjectionQueryOnSTable
(
pQueryInfo
,
0
)))
{
// column projection query
if
((
/*functionId == TSDB_FUNC_PRJ || */
functionId
==
TSDB_FUNC_ARITHM
)
||
(
tscIsProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
pQueryInfo
->
distinctTag
==
false
))
{
// column projection query
ret
=
1
;
// disable merge procedure
ret
=
1
;
// disable merge procedure
}
else
{
}
else
{
tOrderDescriptor
*
pDesc
=
pLocalReducer
->
pDesc
;
tOrderDescriptor
*
pDesc
=
pLocalReducer
->
pDesc
;
...
...
src/client/src/tscSQLParser.c
浏览文件 @
0bca0444
...
@@ -1476,23 +1476,39 @@ static void addPrimaryTsColIntoResult(SQueryInfo* pQueryInfo) {
...
@@ -1476,23 +1476,39 @@ static void addPrimaryTsColIntoResult(SQueryInfo* pQueryInfo) {
pQueryInfo
->
type
|=
TSDB_QUERY_TYPE_PROJECTION_QUERY
;
pQueryInfo
->
type
|=
TSDB_QUERY_TYPE_PROJECTION_QUERY
;
}
}
bool
isValidDistinctSql
(
SQueryInfo
*
pQueryInfo
)
{
if
(
pQueryInfo
==
NULL
)
{
return
false
;
}
if
((
pQueryInfo
->
type
&
TSDB_QUERY_TYPE_STABLE_QUERY
)
!=
TSDB_QUERY_TYPE_STABLE_QUERY
)
{
return
false
;
}
if
(
tscQueryTags
(
pQueryInfo
)
&&
tscSqlExprNumOfExprs
(
pQueryInfo
)
==
1
){
return
true
;
}
return
false
;
}
int32_t
parseSelectClause
(
SSqlCmd
*
pCmd
,
int32_t
clauseIndex
,
tSQLExprList
*
pSelection
,
bool
isSTable
,
bool
joinQuery
,
bool
intervalQuery
)
{
int32_t
parseSelectClause
(
SSqlCmd
*
pCmd
,
int32_t
clauseIndex
,
tSQLExprList
*
pSelection
,
bool
isSTable
,
bool
joinQuery
,
bool
intervalQuery
)
{
assert
(
pSelection
!=
NULL
&&
pCmd
!=
NULL
);
assert
(
pSelection
!=
NULL
&&
pCmd
!=
NULL
);
const
char
*
msg2
=
"functions can not be mixed up"
;
const
char
*
msg2
=
"functions can not be mixed up"
;
const
char
*
msg3
=
"not support query expression"
;
const
char
*
msg3
=
"not support query expression"
;
const
char
*
msg5
=
"invalid function name"
;
const
char
*
msg5
=
"invalid function name"
;
const
char
*
msg6
=
"only support distinct one tag"
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
clauseIndex
);
if
(
pQueryInfo
->
colList
==
NULL
)
{
if
(
pQueryInfo
->
colList
==
NULL
)
{
pQueryInfo
->
colList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pQueryInfo
->
colList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
}
}
bool
hasDistinct
=
false
;
for
(
int32_t
i
=
0
;
i
<
pSelection
->
nExpr
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSelection
->
nExpr
;
++
i
)
{
int32_t
outputIndex
=
(
int32_t
)
tscSqlExprNumOfExprs
(
pQueryInfo
);
int32_t
outputIndex
=
(
int32_t
)
tscSqlExprNumOfExprs
(
pQueryInfo
);
tSqlExprItem
*
pItem
=
&
pSelection
->
a
[
i
];
tSqlExprItem
*
pItem
=
&
pSelection
->
a
[
i
];
if
(
hasDistinct
==
false
)
{
hasDistinct
=
(
pItem
->
distinct
==
true
);
}
// project on all fields
// project on all fields
int32_t
optr
=
pItem
->
pNode
->
nSQLOptr
;
int32_t
optr
=
pItem
->
pNode
->
nSQLOptr
;
...
@@ -1526,6 +1542,13 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
...
@@ -1526,6 +1542,13 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
}
}
}
}
if
(
hasDistinct
==
true
)
{
if
(
!
isValidDistinctSql
(
pQueryInfo
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
pQueryInfo
->
distinctTag
=
true
;
}
// there is only one user-defined column in the final result field, add the timestamp column.
// there is only one user-defined column in the final result field, add the timestamp column.
size_t
numOfSrcCols
=
taosArrayGetSize
(
pQueryInfo
->
colList
);
size_t
numOfSrcCols
=
taosArrayGetSize
(
pQueryInfo
->
colList
);
if
(
numOfSrcCols
<=
0
&&
!
tscQueryTags
(
pQueryInfo
))
{
if
(
numOfSrcCols
<=
0
&&
!
tscQueryTags
(
pQueryInfo
))
{
...
@@ -4605,6 +4628,12 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
...
@@ -4605,6 +4628,12 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
setDefaultOrderInfo
(
pQueryInfo
);
setDefaultOrderInfo
(
pQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
if
(
pQueryInfo
->
distinctTag
==
true
)
{
pQueryInfo
->
order
.
order
=
TSDB_ORDER_ASC
;
pQueryInfo
->
order
.
orderColId
=
0
;
return
TSDB_CODE_SUCCESS
;
}
if
(
pQuerySql
->
pSortOrder
==
NULL
)
{
if
(
pQuerySql
->
pSortOrder
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录