Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e8eb77b8
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
e8eb77b8
编写于
3月 05, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support having
上级
ffcd5d92
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
43 deletion
+49
-43
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+48
-42
未找到文件。
src/client/src/tscLocalMerge.c
浏览文件 @
e8eb77b8
...
...
@@ -1291,7 +1291,7 @@ int32_t doHavingFilter(SQueryInfo* pQueryInfo, tFilePage* pOutput, bool* notSkip
char
*
pInput
=
pOutput
->
data
+
pOutput
->
num
*
pExpr
->
offset
;
doFilterFieldData
(
pQueryInfo
,
pInput
,
pOutput
,
pFieldFilters
,
type
,
notSkipped
);
if
(
!
notSkipped
)
{
if
(
*
notSkipped
==
false
)
{
return
TSDB_CODE_SUCCESS
;
}
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
e8eb77b8
...
...
@@ -6912,27 +6912,29 @@ int32_t getHavingExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr* pExpr, in
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
pLeft
->
pParam
==
NULL
||
pLeft
->
pParam
->
nExpr
<
1
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
//
if (pLeft->pParam == NULL || pLeft->pParam->nExpr < 1) {
//
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
//
}
for
(
int32_t
i
=
0
;
i
<
pLeft
->
pParam
->
nExpr
;
i
++
)
{
tSqlExprItem
*
pParamElem
=
&
(
pLeft
->
pParam
->
a
[
i
]);
if
(
pParamElem
->
pNode
->
nSQLOptr
!=
TK_ALL
&&
pParamElem
->
pNode
->
nSQLOptr
!=
TK_ID
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
if
((
getColumnIndexByName
(
pCmd
,
&
pParamElem
->
pNode
->
colInfo
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
index
.
columnIndex
<=
0
||
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
if
(
pLeft
->
pParam
)
{
for
(
int32_t
i
=
0
;
i
<
pLeft
->
pParam
->
nExpr
;
i
++
)
{
tSqlExprItem
*
pParamElem
=
&
(
pLeft
->
pParam
->
a
[
i
]);
if
(
pParamElem
->
pNode
->
nSQLOptr
!=
TK_ALL
&&
pParamElem
->
pNode
->
nSQLOptr
!=
TK_ID
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
if
((
getColumnIndexByName
(
pCmd
,
&
pParamElem
->
pNode
->
colInfo
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
index
.
columnIndex
<=
0
||
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
}
...
...
@@ -6941,23 +6943,10 @@ int32_t getHavingExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr* pExpr, in
int32_t
parseHavingClause
(
SQueryInfo
*
pQueryInfo
,
tSQLExpr
*
pExpr
,
SSqlCmd
*
pCmd
)
{
int32_t
parseHavingClause
(
SQueryInfo
*
pQueryInfo
,
tSQLExpr
*
pExpr
,
SSqlCmd
*
pCmd
,
bool
isSTable
,
int32_t
joinQuery
,
int32_t
intervalQuery
)
{
const
char
*
msg1
=
"having only works with group by"
;
//const char* msg2 = "invalid column name in having clause";
//const char* msg3 = "columns from one table allowed as having columns";
//const char* msg4 = "no tag allowed in having clause";
const
char
*
msg5
=
"invalid expression in having clause"
;
/*
const char* msg1 = "too many columns in group by clause";
const char* msg4 = "join query does not support group by";
const char* msg7 = "not support group by expression";
const char* msg8 = "not allowed column type for group by";
const char* msg9 = "tags not allowed for table query";
*/
// todo : handle two tables situation
//STableMetaInfo* pTableMetaInfo = NULL;
const
char
*
msg2
=
"functions can not be mixed up"
;
const
char
*
msg3
=
"invalid expression in having clause"
;
if
(
pExpr
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -6968,7 +6957,7 @@ int32_t parseHavingClause(SQueryInfo* pQueryInfo, tSQLExpr* pExpr, SSqlCmd* pCmd
}
if
(
pExpr
->
pLeft
==
NULL
||
pExpr
->
pRight
==
NULL
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
5
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
3
);
}
if
(
pQueryInfo
->
colList
==
NULL
)
{
...
...
@@ -6981,6 +6970,23 @@ int32_t parseHavingClause(SQueryInfo* pQueryInfo, tSQLExpr* pExpr, SSqlCmd* pCmd
return
ret
;
}
//REDO function check
if
(
!
functionCompatibleCheck
(
pQueryInfo
,
joinQuery
,
intervalQuery
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
/*
* transfer sql functions that need secondary merge into another format
* in dealing with super table queries such as: count/first/last
*/
if
(
isSTable
)
{
tscTansformFuncForSTableQuery
(
pQueryInfo
);
if
(
hasUnsupportFunctionsForSTableQuery
(
pCmd
,
pQueryInfo
))
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -7114,11 +7120,6 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
return
TSDB_CODE_TSC_INVALID_SQL
;
}
// parse the having clause in the first place
if
(
parseHavingClause
(
pQueryInfo
,
pQuerySql
->
pHaving
,
pCmd
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
// set where info
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
...
...
@@ -7161,6 +7162,11 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
}
}
// parse the having clause in the first place
if
(
parseHavingClause
(
pQueryInfo
,
pQuerySql
->
pHaving
,
pCmd
,
isSTable
,
joinQuery
,
intervalQuery
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
// no result due to invalid query time range
if
(
pQueryInfo
->
window
.
skey
>
pQueryInfo
->
window
.
ekey
)
{
pQueryInfo
->
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录