Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
10e48241
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看板
未验证
提交
10e48241
编写于
6月 05, 2022
作者:
wmmhello
提交者:
GitHub
6月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13483 from taosdata/feature/TD-13041
feat: add sort/group logic for json
上级
6c57bb2b
3aab3800
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
344 addition
and
146 deletion
+344
-146
include/common/tdatablock.h
include/common/tdatablock.h
+3
-9
include/util/tdef.h
include/util/tdef.h
+1
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+1
-1
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1
-1
source/libs/scalar/inc/filterInt.h
source/libs/scalar/inc/filterInt.h
+1
-1
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+3
-2
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+87
-66
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+235
-53
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+10
-10
未找到文件。
include/common/tdatablock.h
浏览文件 @
10e48241
...
...
@@ -71,20 +71,14 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
#define colDataGetData(p1_, r_) \
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? colDataGetVarData(p1_, r_) : colDataGetNumData(p1_, r_))
static
FORCE_INLINE
bool
colDataIsNull_s
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
)
{
if
(
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
colDataIsNull_var
(
pColumnInfoData
,
row
))
{
return
true
;
}
char
*
data
=
colDataGetVarData
(
pColumnInfoData
,
row
);
return
(
*
data
==
TSDB_DATA_TYPE_NULL
);
}
#define IS_JSON_NULL(type,data) ((type) == TSDB_DATA_TYPE_JSON && *(data) == TSDB_DATA_TYPE_NULL)
static
FORCE_INLINE
bool
colDataIsNull_s
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
)
{
if
(
!
pColumnInfoData
->
hasNull
)
{
return
false
;
}
if
(
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_VARCHAR
||
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
)
)
{
return
colDataIsNull_var
(
pColumnInfoData
,
row
);
}
else
{
if
(
pColumnInfoData
->
nullbitmap
==
NULL
)
{
...
...
include/util/tdef.h
浏览文件 @
10e48241
...
...
@@ -129,7 +129,7 @@ typedef enum EOperatorType {
OP_TYPE_SUB
,
OP_TYPE_MULTI
,
OP_TYPE_DIV
,
OP_TYPE_
MOD
,
OP_TYPE_
REM
,
// unary arithmetic operator
OP_TYPE_MINUS
,
OP_TYPE_ASSIGN
,
...
...
source/common/src/tdatablock.c
浏览文件 @
10e48241
...
...
@@ -109,7 +109,7 @@ int32_t getJsonValueLen(const char *data) {
dataLen
=
DOUBLE_BYTES
+
CHAR_BYTES
;
}
else
if
(
*
data
==
TSDB_DATA_TYPE_BOOL
)
{
dataLen
=
CHAR_BYTES
+
CHAR_BYTES
;
}
else
if
(
*
data
==
TD_TAG_JSON
)
{
// json string
}
else
if
(
*
data
&
TD_TAG_JSON
)
{
// json string
dataLen
=
((
STag
*
)(
data
))
->
len
;
}
else
{
ASSERT
(
0
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
10e48241
...
...
@@ -1096,7 +1096,7 @@ bool nodesIsArithmeticOp(const SOperatorNode* pOp) {
case
OP_TYPE_SUB
:
case
OP_TYPE_MULTI
:
case
OP_TYPE_DIV
:
case
OP_TYPE_
MOD
:
case
OP_TYPE_
REM
:
return
true
;
default:
break
;
...
...
source/libs/parser/inc/sql.y
浏览文件 @
10e48241
...
...
@@ -611,7 +611,7 @@ expression(A) ::= expression(B) NK_SLASH expression(C).
expression(A) ::= expression(B) NK_REM expression(C). {
SToken s = getTokenFromRawExprNode(pCxt, B);
SToken e = getTokenFromRawExprNode(pCxt, C);
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_
MOD, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_
REM, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
}
expression(A) ::= column_reference(B) NK_ARROW NK_STRING(C). {
SToken s = getTokenFromRawExprNode(pCxt, B);
...
...
source/libs/parser/src/sql.c
浏览文件 @
10e48241
...
...
@@ -4079,7 +4079,7 @@ static YYACTIONTYPE yy_reduce(
{
SToken
s
=
getTokenFromRawExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy172
);
SToken
e
=
getTokenFromRawExprNode
(
pCxt
,
yymsp
[
0
].
minor
.
yy172
);
yylhsminor
.
yy172
=
createRawExprNodeExt
(
pCxt
,
&
s
,
&
e
,
createOperatorNode
(
pCxt
,
OP_TYPE_
MOD
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy172
),
releaseRawExprNode
(
pCxt
,
yymsp
[
0
].
minor
.
yy172
)));
yylhsminor
.
yy172
=
createRawExprNodeExt
(
pCxt
,
&
s
,
&
e
,
createOperatorNode
(
pCxt
,
OP_TYPE_
REM
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy172
),
releaseRawExprNode
(
pCxt
,
yymsp
[
0
].
minor
.
yy172
)));
}
yymsp
[
-
2
].
minor
.
yy172
=
yylhsminor
.
yy172
;
break
;
...
...
source/libs/scalar/inc/filterInt.h
浏览文件 @
10e48241
...
...
@@ -350,7 +350,7 @@ struct SFilterInfo {
extern
bool
filterDoCompare
(
__compar_fn_t
func
,
uint8_t
optr
,
void
*
left
,
void
*
right
);
extern
__compar_fn_t
filterGetCompFunc
(
int32_t
type
,
int32_t
optr
);
extern
OptrStr
gOptrStr
[];
#ifdef __cplusplus
}
...
...
source/libs/scalar/src/filter.c
浏览文件 @
10e48241
...
...
@@ -29,8 +29,9 @@ OptrStr gOptrStr[] = {
{
OP_TYPE_SUB
,
"-"
},
{
OP_TYPE_MULTI
,
"*"
},
{
OP_TYPE_DIV
,
"/"
},
{
OP_TYPE_MOD
,
"%"
},
{
OP_TYPE_REM
,
"%"
},
{
OP_TYPE_MINUS
,
"minus"
},
{
OP_TYPE_ASSIGN
,
"assign"
},
// bit operator
{
OP_TYPE_BIT_AND
,
"&"
},
{
OP_TYPE_BIT_OR
,
"|"
},
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
10e48241
此差异已折叠。
点击以展开。
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
10e48241
此差异已折叠。
点击以展开。
tests/system-test/2-query/json_tag.py
浏览文件 @
10e48241
...
...
@@ -137,9 +137,9 @@ class TDTestCase:
tdSql
.
checkRows
(
9
)
tdSql
.
query
(
"select jtag from jsons1"
)
tdSql
.
checkRows
(
13
)
#
tdSql.query("select jtag from jsons1 where jtag is null")
tdSql
.
query
(
"select jtag from jsons1 where jtag is null"
)
# tdSql.checkRows(5)
#
tdSql.query("select jtag from jsons1 where jtag is not null")
tdSql
.
query
(
"select jtag from jsons1 where jtag is not null"
)
# tdSql.checkRows(8)
# test jtag is NULL
...
...
@@ -260,9 +260,9 @@ class TDTestCase:
# tdSql.checkRows(1)
#
# # where json is null
#
tdSql.query("select * from jsons1 where jtag is null")
tdSql
.
query
(
"select * from jsons1 where jtag is null"
)
# tdSql.checkRows(1)
#
tdSql.query("select * from jsons1 where jtag is not null")
tdSql
.
query
(
"select * from jsons1 where jtag is not null"
)
# tdSql.checkRows(8)
#
# # where json key is null
...
...
@@ -389,8 +389,8 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
1
,
"11.000000000"
)
tdSql
.
checkData
(
5
,
0
,
1
)
tdSql
.
checkData
(
5
,
1
,
"false"
)
#
tdSql.checkData(6, 0, 1)
#
tdSql.checkData(6, 1, "null")
tdSql
.
checkData
(
6
,
0
,
1
)
tdSql
.
checkData
(
6
,
1
,
"null"
)
tdSql
.
checkData
(
7
,
0
,
2
)
tdSql
.
checkData
(
7
,
1
,
None
)
...
...
@@ -409,7 +409,7 @@ class TDTestCase:
tdSql
.
query
(
"select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
0
,
10
)
#
tdSql.checkData(0, 1, None)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
4
,
0
,
0
)
tdSql
.
checkData
(
4
,
1
,
"5.000000000"
)
tdSql
.
checkData
(
7
,
0
,
11
)
...
...
@@ -424,10 +424,10 @@ class TDTestCase:
# test top/bottom with group by json tag
tdSql
.
query
(
"select top(dataint,2),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
2
,
0
,
4
)
tdSql
.
checkData
(
3
,
0
,
3
)
tdSql
.
checkData
(
3
,
1
,
"false"
)
# tdSql.checkData(3, 0, 24)
# tdSql.checkData(3, 1, None)
tdSql
.
checkData
(
10
,
0
,
23
)
tdSql
.
checkData
(
10
,
1
,
'"femail"'
)
...
...
@@ -436,7 +436,7 @@ class TDTestCase:
# tdSql.checkRows(2)
# subquery with json tag
tdSql
.
query
(
"select * from (select jtag, dataint from jsons1)"
)
tdSql
.
query
(
"select * from (select jtag, dataint from jsons1)
order by dataint
"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
1
,
1
,
1
)
tdSql
.
checkData
(
2
,
0
,
'{"tag1":5,"tag2":"beijing"}'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录