Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7ddbf619
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7ddbf619
编写于
4月 24, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-187] support group by on normal columns.
上级
102cf898
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
13 deletion
+31
-13
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+5
-1
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+26
-12
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
7ddbf619
...
...
@@ -2477,6 +2477,10 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
return
TSDB_CODE_SUCCESS
;
}
if
(
pQueryInfo
->
colList
==
NULL
)
{
pQueryInfo
->
colList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
}
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
=
pList
->
nExpr
;
if
(
pList
->
nExpr
>
TSDB_MAX_TAGS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
...
...
@@ -4915,7 +4919,7 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) {
list
.
num
=
1
;
list
.
ids
[
0
]
=
colIndex
;
insertResultField
(
pQueryInfo
,
size
-
1
,
&
list
,
pSchema
->
bytes
,
pSchema
->
type
,
pSchema
->
name
,
pExpr
);
insertResultField
(
pQueryInfo
,
size
,
&
list
,
pSchema
->
bytes
,
pSchema
->
type
,
pSchema
->
name
,
pExpr
);
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
size
-
1
);
pInfo
->
visible
=
false
;
}
...
...
src/query/src/queryExecutor.c
浏览文件 @
7ddbf619
...
...
@@ -990,9 +990,7 @@ static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, char *pDat
return
TSDB_CODE_SUCCESS
;
}
static
UNUSED_FUNC
char
*
getGroupbyColumnData
(
SQuery
*
pQuery
,
SData
**
data
,
int16_t
*
type
,
int16_t
*
bytes
)
{
char
*
groupbyColumnData
=
NULL
;
static
char
*
getGroupbyColumnData
(
SQuery
*
pQuery
,
int16_t
*
type
,
int16_t
*
bytes
,
SArray
*
pDataBlock
)
{
SSqlGroupbyExpr
*
pGroupbyExpr
=
pQuery
->
pGroupbyExpr
;
for
(
int32_t
k
=
0
;
k
<
pGroupbyExpr
->
numOfGroupCols
;
++
k
)
{
...
...
@@ -1015,12 +1013,22 @@ static UNUSED_FUNC char *getGroupbyColumnData(SQuery *pQuery, SData **data, int1
*
type
=
pQuery
->
colList
[
colIndex
].
type
;
*
bytes
=
pQuery
->
colList
[
colIndex
].
bytes
;
// groupbyColumnData = doGetDataBlocks(pQuery, data, pQuery->colList[colIndex].inf);
break
;
/*
* the colIndex is acquired from the first meter of all qualified meters in this vnode during query prepare
* stage, the remain meter may not have the required column in cache actually. So, the validation of required
* column in cache with the corresponding meter schema is reinforced.
*/
int32_t
numOfCols
=
taosArrayGetSize
(
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
p
=
taosArrayGet
(
pDataBlock
,
i
);
if
(
pColIndex
->
colId
==
p
->
info
.
colId
)
{
return
p
->
pData
;
}
}
}
return
groupbyColumnData
;
return
NULL
;
}
static
int32_t
doTSJoinFilter
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
offset
)
{
...
...
@@ -1091,8 +1099,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
char
*
groupbyColumnData
=
NULL
;
if
(
groupbyStateValue
)
{
assert
(
0
);
// groupbyColumnData = getGroupbyColumnData(pQuery, data, &type, &bytes);
groupbyColumnData
=
getGroupbyColumnData
(
pQuery
,
&
type
,
&
bytes
,
pDataBlock
);
}
for
(
int32_t
k
=
0
;
k
<
pQuery
->
numOfOutput
;
++
k
)
{
...
...
@@ -6088,9 +6095,16 @@ int32_t qCreateQueryInfo(void *tsdb, SQueryTableMsg *pQueryMsg, qinfo_t *pQInfo)
STableId
*
id
=
taosArrayGet
(
pTableIdList
,
0
);
id
->
uid
=
-
1
;
// todo fix me
// group by normal column, do not pass the group by condition to tsdb to group table into different group
int32_t
numOfGroupByCols
=
pQueryMsg
->
numOfGroupCols
;
if
(
pQueryMsg
->
numOfGroupCols
==
1
&&
!
TSDB_COL_IS_TAG
(
pGroupColIndex
->
flag
))
{
numOfGroupByCols
=
0
;
}
// todo handle the error
/*int32_t ret =*/
tsdbQueryByTagsCond
(
tsdb
,
id
->
uid
,
tagCond
,
pQueryMsg
->
tagCondLen
,
&
groupInfo
,
pGroupColIndex
,
pQueryMsg
->
numOfGroup
Cols
);
numOfGroupBy
Cols
);
if
(
groupInfo
.
numOfTables
==
0
)
{
// no qualified tables no need to do query
code
=
TSDB_CODE_SUCCESS
;
goto
_query_over
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录