Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
946d72e5
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
946d72e5
编写于
11月 24, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix group by json tag format [change json type with qid return logic]
上级
7ab46991
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
18 addition
and
15 deletion
+18
-15
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+18
-15
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
946d72e5
...
@@ -3748,6 +3748,7 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd
...
@@ -3748,6 +3748,7 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd
const
char
*
msg8
=
"normal column can only locate at the end of group by clause"
;
const
char
*
msg8
=
"normal column can only locate at the end of group by clause"
;
const
char
*
msg9
=
"json tag must be use ->'key'"
;
const
char
*
msg9
=
"json tag must be use ->'key'"
;
const
char
*
msg10
=
"non json column can not use ->'key'"
;
const
char
*
msg10
=
"non json column can not use ->'key'"
;
const
char
*
msg11
=
"group by json->'key' is too long"
;
// todo : handle two tables situation
// todo : handle two tables situation
STableMetaInfo
*
pTableMetaInfo
=
NULL
;
STableMetaInfo
*
pTableMetaInfo
=
NULL
;
...
@@ -3839,8 +3840,10 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd
...
@@ -3839,8 +3840,10 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd
SColIndex
colIndex
=
{
.
colIndex
=
relIndex
,
.
flag
=
TSDB_COL_TAG
,
.
colId
=
pSchema
->
colId
,
};
SColIndex
colIndex
=
{
.
colIndex
=
relIndex
,
.
flag
=
TSDB_COL_TAG
,
.
colId
=
pSchema
->
colId
,
};
if
(
pItem
->
isJsonExp
)
{
if
(
pItem
->
isJsonExp
)
{
tstrncpy
(
colIndex
.
name
,
pItem
->
jsonExp
->
exprToken
.
z
,
if
(
pItem
->
jsonExp
->
exprToken
.
n
>=
tListLen
(
colIndex
.
name
)){
pItem
->
jsonExp
->
exprToken
.
n
+
1
>
tListLen
(
colIndex
.
name
)
?
tListLen
(
colIndex
.
name
)
:
pItem
->
jsonExp
->
exprToken
.
n
+
1
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg11
);
}
tstrncpy
(
colIndex
.
name
,
pItem
->
jsonExp
->
exprToken
.
z
,
pItem
->
jsonExp
->
exprToken
.
n
+
1
);
}
else
{
}
else
{
tstrncpy
(
colIndex
.
name
,
pSchema
->
name
,
tListLen
(
colIndex
.
name
));
tstrncpy
(
colIndex
.
name
,
pSchema
->
name
,
tListLen
(
colIndex
.
name
));
}
}
...
@@ -7518,26 +7521,26 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
...
@@ -7518,26 +7521,26 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
SColumnIndex
index
=
{.
tableIndex
=
pQueryInfo
->
groupbyExpr
.
tableIndex
,
.
columnIndex
=
colIndex
};
SColumnIndex
index
=
{.
tableIndex
=
pQueryInfo
->
groupbyExpr
.
tableIndex
,
.
columnIndex
=
colIndex
};
SExprInfo
*
pExpr
=
tscExprInsert
(
pQueryInfo
,
pos
,
f
,
&
index
,
s
->
type
,
s
->
bytes
,
getNewResColId
(
pCmd
),
s
->
bytes
,
true
);
SExprInfo
*
pExpr
=
tscExprInsert
(
pQueryInfo
,
pos
,
f
,
&
index
,
s
->
type
,
s
->
bytes
,
getNewResColId
(
pCmd
),
s
->
bytes
,
true
);
// if json->key is more than TSDB_COL_NAME_LEN + TSDB_DB_NAME_LEN, truncature it, maybe case error, can encode name by md5.
// NOTE: tag column does not add to source column list
SColumnList
ids
=
createColumnList
(
1
,
0
,
pColIndex
->
colIndex
);
insertResultField
(
pQueryInfo
,
pos
,
&
ids
,
s
->
bytes
,
(
int8_t
)
s
->
type
,
pColIndex
->
name
,
pExpr
);
pExpr
->
base
.
colInfo
.
flag
=
TSDB_COL_TAG
;
memset
(
pExpr
->
base
.
aliasName
,
0
,
sizeof
(
pExpr
->
base
.
aliasName
));
if
(
s
->
type
==
TSDB_DATA_TYPE_JSON
){
if
(
s
->
type
==
TSDB_DATA_TYPE_JSON
){
SStrToken
t0
=
{.
z
=
pColIndex
->
name
};
SStrToken
t0
=
{.
z
=
pColIndex
->
name
};
getJsonKey
(
&
t0
);
getJsonKey
(
&
t0
);
tVariantCreateFromBinary
(
&
(
pExpr
->
base
.
param
[
pExpr
->
base
.
numOfParams
]),
t0
.
z
,
tVariantCreateFromBinary
(
&
(
pExpr
->
base
.
param
[
pExpr
->
base
.
numOfParams
]),
t0
.
z
,
t0
.
n
,
TSDB_DATA_TYPE_BINARY
);
t0
.
n
,
TSDB_DATA_TYPE_BINARY
);
pExpr
->
base
.
numOfParams
++
;
pExpr
->
base
.
numOfParams
++
;
}
char
keyMd5
[
TSDB_MAX_JSON_KEY_MD5_LEN
+
1
]
=
{
0
};
char
keyMd5
[
TSDB_MAX_JSON_KEY_MD5_LEN
+
1
]
=
{
0
};
jsonKeyMd5
(
pColIndex
->
name
,
strlen
(
pColIndex
->
name
),
keyMd5
);
jsonKeyMd5
(
pColIndex
->
name
,
strlen
(
pColIndex
->
name
),
keyMd5
);
memset
(
pExpr
->
base
.
aliasName
,
0
,
sizeof
(
pExpr
->
base
.
aliasName
));
tstrncpy
(
pExpr
->
base
.
aliasName
,
keyMd5
,
sizeof
(
pExpr
->
base
.
aliasName
));
tstrncpy
(
pExpr
->
base
.
aliasName
,
keyMd5
,
sizeof
(
pExpr
->
base
.
aliasName
));
tstrncpy
(
pExpr
->
base
.
token
,
keyMd5
,
sizeof
(
pExpr
->
base
.
token
));
tstrncpy
(
pExpr
->
base
.
token
,
keyMd5
,
sizeof
(
pExpr
->
base
.
token
));
tstrncpy
(
pColIndex
->
name
,
t0
.
z
,
t0
.
n
+
1
);
pExpr
->
base
.
colInfo
.
flag
=
TSDB_COL_TAG
;
}
else
{
tstrncpy
(
pExpr
->
base
.
aliasName
,
s
->
name
,
sizeof
(
pExpr
->
base
.
aliasName
));
// NOTE: tag column does not add to source column list
tstrncpy
(
pExpr
->
base
.
token
,
s
->
name
,
sizeof
(
pExpr
->
base
.
aliasName
));
SColumnList
ids
=
createColumnList
(
1
,
0
,
pColIndex
->
colIndex
);
}
insertResultField
(
pQueryInfo
,
pos
,
&
ids
,
s
->
bytes
,
(
int8_t
)
s
->
type
,
pColIndex
->
name
,
pExpr
);
}
else
{
}
else
{
// if this query is "group by" normal column, time window query is not allowed
// if this query is "group by" normal column, time window query is not allowed
if
(
isTimeWindowQuery
(
pQueryInfo
))
{
if
(
isTimeWindowQuery
(
pQueryInfo
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录