Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0170c3bb
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看板
提交
0170c3bb
编写于
11月 04, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add json tag support for group by
上级
bf8cb8fd
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
34 addition
and
15 deletion
+34
-15
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+32
-14
src/query/src/qExtbuffer.c
src/query/src/qExtbuffer.c
+2
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
0170c3bb
...
...
@@ -5922,15 +5922,25 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
return
invalidOperationMsg
(
pMsgBuf
,
msg10
);
}
SStrToken
columnName
=
{
0
};
CommonItem
*
pItem
=
taosArrayGet
(
pSortOrder
,
0
);
if
(
pItem
->
isJsonExp
){
assert
(
pItem
->
jsonExp
->
tokenId
==
TK_ARROW
);
columnName
=
pItem
->
jsonExp
->
pLeft
->
columnName
;
}
else
{
// handle the first part of order by
tVariant
*
pVar
=
&
((
CommonItem
*
)
taosArrayGet
(
pSortOrder
,
0
))
->
pVar
;
tVariant
*
pVar
=
&
pItem
->
pVar
;
// e.g., order by 1 asc, return directly with out further check.
if
(
pVar
->
nType
>=
TSDB_DATA_TYPE_TINYINT
&&
pVar
->
nType
<=
TSDB_DATA_TYPE_BIGINT
)
{
return
TSDB_CODE_SUCCESS
;
}
SStrToken
columnName
=
{
pVar
->
nLen
,
pVar
->
nType
,
pVar
->
pz
};
columnName
.
n
=
pVar
->
nLen
;
columnName
.
type
=
pVar
->
nType
;
columnName
.
z
=
pVar
->
pz
;
}
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
bool
udf
=
false
;
...
...
@@ -6048,7 +6058,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
}
}
}
else
{
CommonItem
*
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
if
(
orderByTags
)
{
pQueryInfo
->
groupbyExpr
.
orderIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
pQueryInfo
->
groupbyExpr
.
orderType
=
pItem
->
sortOrder
;
...
...
@@ -6066,9 +6076,18 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
}
}
SStrToken
cname
=
{
0
};
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
1
);
tVariant
*
pVar2
=
&
pItem
->
pVar
;
SStrToken
cname
=
{
pVar2
->
nLen
,
pVar2
->
nType
,
pVar2
->
pz
};
if
(
pItem
->
isJsonExp
){
assert
(
pItem
->
jsonExp
->
tokenId
==
TK_ARROW
);
cname
=
pItem
->
jsonExp
->
pLeft
->
columnName
;
}
else
{
tVariant
*
pVar
=
&
pItem
->
pVar
;
cname
.
n
=
pVar
->
nLen
;
cname
.
type
=
pVar
->
nType
;
cname
.
z
=
pVar
->
pz
;
}
if
(
getColumnIndexByName
(
&
cname
,
pQueryInfo
,
&
index
,
tscGetErrorMsgPayload
(
pCmd
))
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg1
);
}
...
...
@@ -6076,8 +6095,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
if
(
index
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg6
);
}
else
{
CommonItem
*
p1
=
taosArrayGet
(
pSortOrder
,
1
);
pQueryInfo
->
order
.
order
=
p1
->
sortOrder
;
pQueryInfo
->
order
.
order
=
pItem
->
sortOrder
;
pQueryInfo
->
order
.
orderColId
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
;
}
}
...
...
@@ -6133,7 +6151,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
}
}
CommonItem
*
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
order
.
order
=
pItem
->
sortOrder
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
.
columnIndex
].
colId
;
...
...
@@ -6144,7 +6162,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
return
invalidOperationMsg
(
pMsgBuf
,
msg11
);
}
CommonItem
*
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
order
.
order
=
pItem
->
sortOrder
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
.
columnIndex
].
colId
;
}
else
{
...
...
@@ -6160,7 +6178,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
return
invalidOperationMsg
(
pMsgBuf
,
msg11
);
}
CommonItem
*
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
order
.
order
=
pItem
->
sortOrder
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
.
columnIndex
].
colId
;
}
...
...
src/query/src/qExtbuffer.c
浏览文件 @
0170c3bb
...
...
@@ -391,7 +391,8 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
}
};
case
TSDB_DATA_TYPE_NCHAR
:
{
// todo handle the var string compare
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_JSON
:
{
// todo handle the var string compare
int32_t
len1
=
varDataLen
(
f1
);
int32_t
len2
=
varDataLen
(
f2
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录