Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a30ab5e6
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看板
提交
a30ab5e6
编写于
12月 06, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix id.id error in order by & change ? to contains
上级
36497668
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
526 addition
and
506 deletion
+526
-506
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+3
-3
src/inc/taosdef.h
src/inc/taosdef.h
+1
-1
src/inc/ttokendef.h
src/inc/ttokendef.h
+24
-23
src/query/inc/sql.y
src/query/inc/sql.y
+10
-6
src/query/src/qFilter.c
src/query/src/qFilter.c
+6
-6
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+1
-1
src/query/src/sql.c
src/query/src/sql.c
+464
-449
src/util/src/tcompare.c
src/util/src/tcompare.c
+1
-1
src/util/src/ttokenizer.c
src/util/src/ttokenizer.c
+2
-1
tests/pytest/stable/json_tag.py
tests/pytest/stable/json_tag.py
+14
-15
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
a30ab5e6
...
...
@@ -286,8 +286,8 @@ static uint8_t convertRelationalOperator(SStrToken *pToken) {
return
TSDB_RELATION_MATCH
;
case
TK_NMATCH
:
return
TSDB_RELATION_NMATCH
;
case
TK_
QUESTION
:
return
TSDB_RELATION_
QUESTION
;
case
TK_
CONTAINS
:
return
TSDB_RELATION_
CONTAINS
;
case
TK_ARROW
:
return
TSDB_RELATION_ARROW
;
case
TK_ISNULL
:
...
...
@@ -4743,7 +4743,7 @@ static int32_t validateJsonTagExpr(tSqlExpr* pExpr, char* msgBuf) {
tSqlExpr
*
pLeft
=
pExpr
->
pLeft
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
if
(
pExpr
->
tokenId
==
TK_
QUESTION
)
{
if
(
pExpr
->
tokenId
==
TK_
CONTAINS
)
{
if
(
pRight
!=
NULL
&&
!
IS_VAR_DATA_TYPE
(
pRight
->
value
.
nType
))
return
invalidOperationMsg
(
msgBuf
,
msg3
);
...
...
src/inc/taosdef.h
浏览文件 @
a30ab5e6
...
...
@@ -181,7 +181,7 @@ do { \
#define TSDB_RELATION_MATCH 14
#define TSDB_RELATION_NMATCH 15
#define TSDB_RELATION_
QUESTION
16
#define TSDB_RELATION_
CONTAINS
16
#define TSDB_RELATION_ARROW 17
#define TSDB_BINARY_OP_ADD 30
...
...
src/inc/ttokendef.h
浏览文件 @
a30ab5e6
...
...
@@ -40,29 +40,29 @@
#define TK_LIKE 22
#define TK_MATCH 23
#define TK_NMATCH 24
#define TK_
GLOB
25
#define TK_
BETWEEN
26
#define TK_
IN
27
#define TK_
GT
28
#define TK_G
E
29
#define TK_
LT
30
#define TK_L
E
31
#define TK_
BITAND
32
#define TK_BIT
OR
33
#define TK_
LSHIFT
34
#define TK_
R
SHIFT 35
#define TK_
PLUS
36
#define TK_
MINUS
37
#define TK_
DIVIDE
38
#define TK_
TIMES
39
#define TK_
STAR
40
#define TK_S
LASH
41
#define TK_
REM
42
#define TK_
CONCAT
43
#define TK_
UMINUS
44
#define TK_U
PLUS
45
#define TK_
BITNOT
46
#define TK_
QUESTION
47
#define TK_
CONTAINS
25
#define TK_
GLOB
26
#define TK_
BETWEEN
27
#define TK_
IN
28
#define TK_G
T
29
#define TK_
GE
30
#define TK_L
T
31
#define TK_
LE
32
#define TK_BIT
AND
33
#define TK_
BITOR
34
#define TK_
L
SHIFT 35
#define TK_
RSHIFT
36
#define TK_
PLUS
37
#define TK_
MINUS
38
#define TK_
DIVIDE
39
#define TK_
TIMES
40
#define TK_S
TAR
41
#define TK_
SLASH
42
#define TK_
REM
43
#define TK_
CONCAT
44
#define TK_U
MINUS
45
#define TK_
UPLUS
46
#define TK_
BITNOT
47
#define TK_ARROW 48
#define TK_SHOW 49
#define TK_DATABASES 50
...
...
@@ -225,6 +225,7 @@
#define TK_HEX 303 // hex number 0x123
#define TK_OCT 304 // oct number
#define TK_BIN 305 // bin format data 0b111
#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query
#endif
...
...
src/query/inc/sql.y
浏览文件 @
a30ab5e6
...
...
@@ -11,7 +11,7 @@
%left OR.
%left AND.
%right NOT.
%left EQ NE ISNULL NOTNULL IS LIKE MATCH NMATCH GLOB BETWEEN IN.
%left EQ NE ISNULL NOTNULL IS LIKE MATCH NMATCH
CONTAINS
GLOB BETWEEN IN.
%left GT GE LT LE.
%left BITAND BITOR LSHIFT RSHIFT.
%left PLUS MINUS.
...
...
@@ -19,7 +19,7 @@
%left STAR SLASH REM.
%left CONCAT.
%right UMINUS UPLUS BITNOT.
%right
QUESTION
ARROW.
%right ARROW.
%include {
#include <stdio.h>
...
...
@@ -651,10 +651,13 @@ sortlist(A) ::= arrow(Y) sortorder(Z). {
}
%type item {tVariant}
item(A) ::= ID(X). { toTSDBType(X.type); tVariantCreate(&A, &X, true); }
item(A) ::= ID(X). {
toTSDBType(X.type);
tVariantCreate(&A, &X, true);
}
item(A) ::= ID(X) DOT ID(Y). {
toTSDBType(X.type);
X.n +=
Y.n
;
X.n +=
(1+Y.n)
;
tVariantCreate(&A, &X, true);
}
...
...
@@ -779,8 +782,9 @@ expr(A) ::= expr(X) LIKE expr(Y). {A = tSqlExprCreate(X, Y, TK_LIKE); }
expr(A) ::= expr(X) MATCH expr(Y). {A = tSqlExprCreate(X, Y, TK_MATCH); }
expr(A) ::= expr(X) NMATCH expr(Y). {A = tSqlExprCreate(X, Y, TK_NMATCH); }
// question expression
expr(A) ::= ID(X) QUESTION STRING(Y). { tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &X, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &Y, TK_STRING); A = tSqlExprCreate(S, M, TK_QUESTION); }
// contains expression
expr(A) ::= ID(X) CONTAINS STRING(Y). { tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &X, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &Y, TK_STRING); A = tSqlExprCreate(S, M, TK_CONTAINS); }
expr(A) ::= ID(X) DOT ID(Y) CONTAINS STRING(Z). { X.n += (1+Y.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &X, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &Z, TK_STRING); A = tSqlExprCreate(S, M, TK_CONTAINS); }
// arrow expression
%type arrow {tSqlExpr*}
...
...
src/query/src/qFilter.c
浏览文件 @
a30ab5e6
...
...
@@ -37,7 +37,7 @@ OptrStr gOptrStr[] = {
{
TSDB_RELATION_NOT
,
"not"
},
{
TSDB_RELATION_MATCH
,
"match"
},
{
TSDB_RELATION_NMATCH
,
"nmatch"
},
{
TSDB_RELATION_
QUESTION
,
"?
"
},
{
TSDB_RELATION_
CONTAINS
,
"contains
"
},
};
static
FORCE_INLINE
int32_t
filterFieldColDescCompare
(
const
void
*
desc1
,
const
void
*
desc2
)
{
...
...
@@ -244,7 +244,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
comparFn
=
20
;
}
else
if
(
optr
==
TSDB_RELATION_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
9
;
}
else
if
(
optr
==
TSDB_RELATION_
QUESTION
)
{
}
else
if
(
optr
==
TSDB_RELATION_
CONTAINS
)
{
comparFn
=
21
;
}
else
{
comparFn
=
22
;
...
...
@@ -1193,7 +1193,7 @@ static int32_t filterDealJson(SFilterInfo *info, tExprNode* tree, tExprNode** pL
uint32_t
nullData
=
TSDB_DATA_JSON_NULL
;
jsonKeyMd5
(
&
nullData
,
INT_BYTES
,
keyMd5
);
memcpy
(
schema
->
name
,
keyMd5
,
TSDB_MAX_JSON_KEY_MD5_LEN
);
}
else
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_
QUESTION
){
}
else
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_
CONTAINS
){
SSchema
*
schema
=
(
*
pLeft
)
->
pSchema
;
if
(
tree
->
_node
.
pRight
->
pVal
->
nLen
>
TSDB_MAX_JSON_KEY_LEN
)
return
TSDB_CODE_TSC_INVALID_COLUMN_LENGTH
;
char
keyMd5
[
TSDB_MAX_JSON_KEY_MD5_LEN
]
=
{
0
};
...
...
@@ -1945,7 +1945,7 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right)
case
TSDB_RELATION_MATCH
:
{
return
ret
==
0
;
}
case
TSDB_RELATION_
QUESTION
:
{
case
TSDB_RELATION_
CONTAINS
:
{
return
ret
==
0
;
}
case
TSDB_RELATION_NMATCH
:
{
...
...
@@ -2718,7 +2718,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SDataStatis *pDataStatis, int32_t
if
(
cunit
->
optr
==
TSDB_RELATION_ISNULL
||
cunit
->
optr
==
TSDB_RELATION_NOTNULL
||
cunit
->
optr
==
TSDB_RELATION_IN
||
cunit
->
optr
==
TSDB_RELATION_LIKE
||
cunit
->
optr
==
TSDB_RELATION_MATCH
||
cunit
->
optr
==
TSDB_RELATION_NOT_EQUAL
||
cunit
->
optr
==
TSDB_RELATION_
QUESTION
)
{
||
cunit
->
optr
==
TSDB_RELATION_NOT_EQUAL
||
cunit
->
optr
==
TSDB_RELATION_
CONTAINS
)
{
continue
;
}
...
...
@@ -3600,7 +3600,7 @@ int32_t filterIsIndexedColumnQuery(SFilterInfo* info, int32_t idxId, bool *res)
int32_t
optr
=
FILTER_UNIT_OPTR
(
info
->
units
);
CHK_JMP
(
optr
==
TSDB_RELATION_LIKE
||
optr
==
TSDB_RELATION_IN
||
optr
==
TSDB_RELATION_MATCH
||
optr
==
TSDB_RELATION_ISNULL
||
optr
==
TSDB_RELATION_NOTNULL
||
optr
==
TSDB_RELATION_
QUESTION
);
||
optr
==
TSDB_RELATION_ISNULL
||
optr
==
TSDB_RELATION_NOTNULL
||
optr
==
TSDB_RELATION_
CONTAINS
);
*
res
=
true
;
...
...
src/query/src/qSqlParser.c
浏览文件 @
a30ab5e6
...
...
@@ -387,7 +387,7 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
pRSub
->
Expr
.
paramList
=
(
SArray
*
)
pRight
;
pExpr
->
pRight
=
pRSub
;
}
else
if
(
optrType
==
TK_ARROW
||
optrType
==
TK_
QUESTION
)
{
}
else
if
(
optrType
==
TK_ARROW
||
optrType
==
TK_
CONTAINS
)
{
pExpr
->
tokenId
=
optrType
;
pExpr
->
pLeft
=
pLeft
;
pExpr
->
pRight
=
pRight
;
...
...
src/query/src/sql.c
浏览文件 @
a30ab5e6
此差异已折叠。
点击以展开。
src/util/src/tcompare.c
浏览文件 @
a30ab5e6
...
...
@@ -544,7 +544,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
comparFn
=
compareStrRegexCompNMatch
;
}
else
if
(
optr
==
TSDB_RELATION_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
compareWStrPatternComp
;
}
else
if
(
optr
==
TSDB_RELATION_
QUESTION
)
{
}
else
if
(
optr
==
TSDB_RELATION_
CONTAINS
)
{
comparFn
=
compareStrContainJson
;
}
else
{
comparFn
=
compareJsonVal
;
...
...
src/util/src/ttokenizer.c
浏览文件 @
a30ab5e6
...
...
@@ -231,7 +231,8 @@ static SKeyword keywordTable[] = {
{
"OUTPUTTYPE"
,
TK_OUTPUTTYPE
},
{
"AGGREGATE"
,
TK_AGGREGATE
},
{
"BUFSIZE"
,
TK_BUFSIZE
},
{
"RANGE"
,
TK_RANGE
}
{
"RANGE"
,
TK_RANGE
},
{
"CONTAINS"
,
TK_CONTAINS
}
};
static
const
char
isIdChar
[]
=
{
...
...
tests/pytest/stable/json_tag.py
浏览文件 @
a30ab5e6
...
...
@@ -78,14 +78,13 @@ class TDTestCase:
tdSql
.
error
(
"select * from jsons1 where jtag->''"
)
tdSql
.
error
(
"select * from jsons1 where jtag->''=9"
)
tdSql
.
error
(
"select -> from jsons1"
)
tdSql
.
error
(
"select ? from jsons1"
)
tdSql
.
error
(
"select * from jsons1 where ?"
)
tdSql
.
error
(
"select * from jsons1 where contains"
)
tdSql
.
error
(
"select * from jsons1 where jtag->"
)
tdSql
.
error
(
"select jtag->location from jsons1"
)
tdSql
.
error
(
"select jtag
?
location from jsons1"
)
tdSql
.
error
(
"select * from jsons1 where jtag
?
location"
)
tdSql
.
error
(
"select * from jsons1 where jtag
?
''"
)
tdSql
.
error
(
"select * from jsons1 where jtag
?
'location'='beijing'"
)
tdSql
.
error
(
"select jtag
contains
location from jsons1"
)
tdSql
.
error
(
"select * from jsons1 where jtag
contains
location"
)
tdSql
.
error
(
"select * from jsons1 where jtag
contains
''"
)
tdSql
.
error
(
"select * from jsons1 where jtag
contains
'location'='beijing'"
)
# test select normal column
tdSql
.
query
(
"select dataint from jsons1"
)
...
...
@@ -246,12 +245,12 @@ class TDTestCase:
tdSql
.
query
(
"select * from jsons1 where jtag->'tag3' is not null"
)
tdSql
.
checkRows
(
4
)
# test
?
tdSql
.
query
(
"select * from jsons1 where jtag
?
'tag1'"
)
# test
contains
tdSql
.
query
(
"select * from jsons1 where jtag
contains
'tag1'"
)
tdSql
.
checkRows
(
8
)
tdSql
.
query
(
"select * from jsons1 where jtag
?
'tag3'"
)
tdSql
.
query
(
"select * from jsons1 where jtag
contains
'tag3'"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select * from jsons1 where jtag
?
'tag_no_exist'"
)
tdSql
.
query
(
"select * from jsons1 where jtag
contains
'tag_no_exist'"
)
tdSql
.
checkRows
(
0
)
# test json tag in where condition with and/or
...
...
@@ -267,19 +266,19 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1' is not null and jtag
?
'tag3'"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1' is not null and jtag
contains
'tag3'"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'='femail' and jtag
?
'tag3'"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'='femail' and jtag
contains
'tag3'"
)
tdSql
.
checkRows
(
2
)
# test with tbname/normal column
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1' and jtag
?
'tag3'"
)
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1' and jtag
contains
'tag3'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1' and jtag
?
'tag3' and dataint=3"
)
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1' and jtag
contains
'tag3' and dataint=3"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1' and jtag
?
'tag3' and dataint=23"
)
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1' and jtag
contains
'tag3' and dataint=23"
)
tdSql
.
checkRows
(
1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录