Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b4e2a79c
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看板
提交
b4e2a79c
编写于
12月 02, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs and add test case
上级
8f768263
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
145 addition
and
119 deletion
+145
-119
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+7
-3
src/query/src/qFilter.c
src/query/src/qFilter.c
+46
-67
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+2
-4
tests/pytest/stable/json_tag.py
tests/pytest/stable/json_tag.py
+90
-45
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
b4e2a79c
...
@@ -4979,8 +4979,9 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
...
@@ -4979,8 +4979,9 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
tSqlExpr
*
rexpr
=
NULL
;
tSqlExpr
*
rexpr
=
NULL
;
if
((
*
pExpr
)
->
tokenId
==
TK_NE
&&
(
pSchema
->
type
!=
TSDB_DATA_TYPE_BINARY
if
((
*
pExpr
)
->
tokenId
==
TK_NE
&&
(
pSchema
->
type
!=
TSDB_DATA_TYPE_BINARY
&&
pSchema
->
type
!=
TSDB_DATA_TYPE_NCHAR
&&
pSchema
->
type
!=
TSDB_DATA_TYPE_NCHAR
&&
pSchema
->
type
!=
TSDB_DATA_TYPE_BOOL
))
{
&&
pSchema
->
type
!=
TSDB_DATA_TYPE_BOOL
handleNeOptr
(
&
rexpr
,
*
pExpr
);
//todo json check
&&
pSchema
->
type
!=
TSDB_DATA_TYPE_JSON
))
{
handleNeOptr
(
&
rexpr
,
*
pExpr
);
*
pExpr
=
rexpr
;
*
pExpr
=
rexpr
;
}
}
...
@@ -9907,7 +9908,10 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
...
@@ -9907,7 +9908,10 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
// NOTE: binary|nchar data allows the >|< type filter
// NOTE: binary|nchar data allows the >|< type filter
if
((
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_EQUAL
&&
(
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_NOT_EQUAL
)
{
if
((
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_EQUAL
&&
(
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_NOT_EQUAL
)
{
if
(
pRight
!=
NULL
&&
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
if
(
pRight
!=
NULL
&&
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
if
(
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_BOOL
&&
pLeft
->
pSchema
->
type
==
TSDB_DATA_TYPE_BOOL
)
{
if
(
pLeft
->
_node
.
optr
==
TSDB_RELATION_ARROW
){
pLeft
=
pLeft
->
_node
.
pLeft
;
}
if
(
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_BOOL
&&
(
pLeft
->
pSchema
->
type
==
TSDB_DATA_TYPE_BOOL
||
pLeft
->
pSchema
->
type
==
TSDB_DATA_TYPE_JSON
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
}
}
}
...
...
src/query/src/qFilter.c
浏览文件 @
b4e2a79c
...
@@ -62,15 +62,23 @@ filter_desc_compare_func gDescCompare [FLD_TYPE_MAX] = {
...
@@ -62,15 +62,23 @@ filter_desc_compare_func gDescCompare [FLD_TYPE_MAX] = {
};
};
bool
filterRangeCompGi
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
bool
filterRangeCompGi
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
int32_t
result
=
cfunc
(
maxv
,
minr
);
if
(
result
==
TSDB_DATA_JSON_CAN_NOT_COMPARE
)
return
false
;
return
cfunc
(
maxv
,
minr
)
>=
0
;
return
cfunc
(
maxv
,
minr
)
>=
0
;
}
}
bool
filterRangeCompGe
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
bool
filterRangeCompGe
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
int32_t
result
=
cfunc
(
maxv
,
minr
);
if
(
result
==
TSDB_DATA_JSON_CAN_NOT_COMPARE
)
return
false
;
return
cfunc
(
maxv
,
minr
)
>
0
;
return
cfunc
(
maxv
,
minr
)
>
0
;
}
}
bool
filterRangeCompLi
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
bool
filterRangeCompLi
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
int32_t
result
=
cfunc
(
minv
,
maxr
);
if
(
result
==
TSDB_DATA_JSON_CAN_NOT_COMPARE
)
return
false
;
return
cfunc
(
minv
,
maxr
)
<=
0
;
return
cfunc
(
minv
,
maxr
)
<=
0
;
}
}
bool
filterRangeCompLe
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
bool
filterRangeCompLe
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
int32_t
result
=
cfunc
(
minv
,
maxr
);
if
(
result
==
TSDB_DATA_JSON_CAN_NOT_COMPARE
)
return
false
;
return
cfunc
(
minv
,
maxr
)
<
0
;
return
cfunc
(
minv
,
maxr
)
<
0
;
}
}
bool
filterRangeCompii
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
bool
filterRangeCompii
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
...
@@ -2990,6 +2998,42 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows
...
@@ -2990,6 +2998,42 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows
return
all
;
return
all
;
}
}
static
void
doJsonCompare
(
SFilterComUnit
*
cunit
,
int8_t
*
result
,
void
*
colData
){
if
(
cunit
->
optr
==
TSDB_RELATION_MATCH
||
cunit
->
optr
==
TSDB_RELATION_NMATCH
){
uint8_t
jsonType
=
*
(
char
*
)
colData
;
char
*
realData
=
colData
+
CHAR_BYTES
;
if
(
jsonType
!=
TSDB_DATA_TYPE_NCHAR
){
*
result
=
false
;
}
else
{
char
*
newColData
=
calloc
(
cunit
->
dataSize
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
,
1
);
int
len
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
varDataVal
(
newColData
));
varDataSetLen
(
newColData
,
len
);
tVariant
*
val
=
cunit
->
valData
;
char
newValData
[
TSDB_REGEX_STRING_DEFAULT_LEN
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
assert
(
val
->
nLen
<=
TSDB_REGEX_STRING_DEFAULT_LEN
*
TSDB_NCHAR_SIZE
);
memcpy
(
varDataVal
(
newValData
),
val
->
pz
,
val
->
nLen
);
varDataSetLen
(
newValData
,
val
->
nLen
);
*
result
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
newColData
,
newValData
);
tfree
(
newColData
);
}
}
else
if
(
cunit
->
optr
==
TSDB_RELATION_LIKE
){
uint8_t
jsonType
=
*
(
char
*
)
colData
;
char
*
realData
=
colData
+
CHAR_BYTES
;
if
(
jsonType
!=
TSDB_DATA_TYPE_NCHAR
){
*
result
=
false
;
}
else
{
tVariant
*
val
=
cunit
->
valData
;
char
*
newValData
=
calloc
(
val
->
nLen
+
VARSTR_HEADER_SIZE
,
1
);
memcpy
(
varDataVal
(
newValData
),
val
->
pz
,
val
->
nLen
);
varDataSetLen
(
newValData
,
val
->
nLen
);
*
result
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
realData
,
newValData
);
tfree
(
newValData
);
}
}
else
{
*
result
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
colData
,
cunit
->
valData
);
}
}
bool
filterExecuteImplRange
(
void
*
pinfo
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
)
{
bool
filterExecuteImplRange
(
void
*
pinfo
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
)
{
SFilterInfo
*
info
=
(
SFilterInfo
*
)
pinfo
;
SFilterInfo
*
info
=
(
SFilterInfo
*
)
pinfo
;
bool
all
=
true
;
bool
all
=
true
;
...
@@ -3056,39 +3100,7 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
...
@@ -3056,39 +3100,7 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
newColData
,
info
->
cunits
[
uidx
].
valData
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
newColData
,
info
->
cunits
[
uidx
].
valData
);
tfree
(
newColData
);
tfree
(
newColData
);
}
else
if
(
info
->
cunits
[
uidx
].
dataType
==
TSDB_DATA_TYPE_JSON
){
}
else
if
(
info
->
cunits
[
uidx
].
dataType
==
TSDB_DATA_TYPE_JSON
){
if
(
info
->
cunits
[
uidx
].
optr
==
TSDB_RELATION_MATCH
||
info
->
cunits
[
uidx
].
optr
==
TSDB_RELATION_NMATCH
){
doJsonCompare
(
&
(
info
->
cunits
[
uidx
]),
&
(
*
p
)[
i
],
colData
);
uint8_t
jsonType
=
*
(
char
*
)
colData
;
char
*
realData
=
colData
+
CHAR_BYTES
;
if
(
jsonType
!=
TSDB_DATA_TYPE_NCHAR
){
(
*
p
)[
i
]
=
false
;
}
else
{
char
*
newColData
=
calloc
(
info
->
cunits
[
uidx
].
dataSize
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
,
1
);
int
len
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
varDataVal
(
newColData
));
varDataSetLen
(
newColData
,
len
);
tVariant
*
val
=
info
->
cunits
[
uidx
].
valData
;
char
newValData
[
TSDB_REGEX_STRING_DEFAULT_LEN
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
assert
(
val
->
nLen
<=
TSDB_REGEX_STRING_DEFAULT_LEN
*
TSDB_NCHAR_SIZE
);
memcpy
(
varDataVal
(
newValData
),
val
->
pz
,
val
->
nLen
);
varDataSetLen
(
newValData
,
val
->
nLen
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
newColData
,
newValData
);
tfree
(
newColData
);
}
}
else
if
(
info
->
cunits
[
uidx
].
optr
==
TSDB_RELATION_LIKE
){
uint8_t
jsonType
=
*
(
char
*
)
colData
;
char
*
realData
=
colData
+
CHAR_BYTES
;
if
(
jsonType
!=
TSDB_DATA_TYPE_NCHAR
){
(
*
p
)[
i
]
=
false
;
}
else
{
tVariant
*
val
=
info
->
cunits
[
uidx
].
valData
;
char
*
newValData
=
calloc
(
val
->
nLen
+
VARSTR_HEADER_SIZE
,
1
);
memcpy
(
varDataVal
(
newValData
),
val
->
pz
,
val
->
nLen
);
varDataSetLen
(
newValData
,
val
->
nLen
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
realData
,
newValData
);
tfree
(
newValData
);
}
}
else
{
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
colData
,
info
->
cunits
[
uidx
].
valData
);
}
}
else
{
}
else
{
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
colData
,
info
->
cunits
[
uidx
].
valData
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
colData
,
info
->
cunits
[
uidx
].
valData
);
}
}
...
@@ -3101,7 +3113,6 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
...
@@ -3101,7 +3113,6 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
return
all
;
return
all
;
}
}
bool
filterExecuteImpl
(
void
*
pinfo
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
)
{
bool
filterExecuteImpl
(
void
*
pinfo
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
)
{
SFilterInfo
*
info
=
(
SFilterInfo
*
)
pinfo
;
SFilterInfo
*
info
=
(
SFilterInfo
*
)
pinfo
;
bool
all
=
true
;
bool
all
=
true
;
...
@@ -3146,39 +3157,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
...
@@ -3146,39 +3157,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
newColData
,
cunit
->
valData
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
newColData
,
cunit
->
valData
);
tfree
(
newColData
);
tfree
(
newColData
);
}
else
if
(
cunit
->
dataType
==
TSDB_DATA_TYPE_JSON
){
}
else
if
(
cunit
->
dataType
==
TSDB_DATA_TYPE_JSON
){
if
(
cunit
->
optr
==
TSDB_RELATION_MATCH
||
cunit
->
optr
==
TSDB_RELATION_NMATCH
){
doJsonCompare
(
cunit
,
&
(
*
p
)[
i
],
colData
);
uint8_t
jsonType
=
*
(
char
*
)
colData
;
char
*
realData
=
colData
+
CHAR_BYTES
;
if
(
jsonType
!=
TSDB_DATA_TYPE_NCHAR
){
(
*
p
)[
i
]
=
false
;
}
else
{
char
*
newColData
=
calloc
(
cunit
->
dataSize
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
,
1
);
int
len
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
varDataVal
(
newColData
));
varDataSetLen
(
newColData
,
len
);
tVariant
*
val
=
cunit
->
valData
;
char
newValData
[
TSDB_REGEX_STRING_DEFAULT_LEN
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
assert
(
val
->
nLen
<=
TSDB_REGEX_STRING_DEFAULT_LEN
*
TSDB_NCHAR_SIZE
);
memcpy
(
varDataVal
(
newValData
),
val
->
pz
,
val
->
nLen
);
varDataSetLen
(
newValData
,
val
->
nLen
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
newColData
,
newValData
);
tfree
(
newColData
);
}
}
else
if
(
cunit
->
optr
==
TSDB_RELATION_LIKE
){
uint8_t
jsonType
=
*
(
char
*
)
colData
;
char
*
realData
=
colData
+
CHAR_BYTES
;
if
(
jsonType
!=
TSDB_DATA_TYPE_NCHAR
){
(
*
p
)[
i
]
=
false
;
}
else
{
tVariant
*
val
=
cunit
->
valData
;
char
*
newValData
=
calloc
(
val
->
nLen
+
VARSTR_HEADER_SIZE
,
1
);
memcpy
(
varDataVal
(
newValData
),
val
->
pz
,
val
->
nLen
);
varDataSetLen
(
newValData
,
val
->
nLen
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
realData
,
newValData
);
tfree
(
newValData
);
}
}
else
{
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
colData
,
cunit
->
valData
);
}
}
else
{
}
else
{
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
colData
,
cunit
->
valData
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
colData
,
cunit
->
valData
);
}
}
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
b4e2a79c
...
@@ -4106,11 +4106,9 @@ static int32_t queryByJsonTag(STable* pTable, void* filterInfo, SArray* res){
...
@@ -4106,11 +4106,9 @@ static int32_t queryByJsonTag(STable* pTable, void* filterInfo, SArray* res){
}
}
}
}
}
}
if
(
tabList
==
NULL
||
taosArrayGetSize
(
tabList
)
==
0
){
if
(
tabList
==
NULL
){
tsdbError
(
"json key not exist, no candidate table"
);
tsdbError
(
"json key not exist, no candidate table"
);
terrno
=
TSDB_CODE_TDB_NO_JSON_TAG_KEY
;
return
TSDB_CODE_SUCCESS
;
taosArrayDestroy
(
tabList
);
return
TSDB_CODE_TDB_NO_JSON_TAG_KEY
;
}
}
int32_t
size
=
taosArrayGetSize
(
tabList
);
int32_t
size
=
taosArrayGetSize
(
tabList
);
int8_t
*
addToResult
=
NULL
;
int8_t
*
addToResult
=
NULL
;
...
...
tests/pytest/stable/json_tag.py
浏览文件 @
b4e2a79c
...
@@ -146,6 +146,9 @@ class TDTestCase:
...
@@ -146,6 +146,9 @@ class TDTestCase:
# test where with json tag
# test where with json tag
tdSql
.
error
(
"select * from jsons1_1 where jtag is not null"
)
tdSql
.
error
(
"select * from jsons1_1 where jtag is not null"
)
tdSql
.
error
(
"select * from jsons1 where jtag='{
\"
tag1
\"
:11,
\"
tag2
\"
:
\"\"
}'"
)
tdSql
.
error
(
"select * from jsons1 where jtag->'tag1'={}"
)
# where json value is string
# where json value is string
tdSql
.
query
(
"select * from jsons1 where jtag->'tag2'='beijing'"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag2'='beijing'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
...
@@ -161,6 +164,19 @@ class TDTestCase:
...
@@ -161,6 +164,19 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'='收到货'"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'='收到货'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag2'>'beijing'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag2'>='beijing'"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag2'<'beijing'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag2'<='beijing'"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag2'!='beijing'"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag2'=''"
)
tdSql
.
checkRows
(
2
)
# where json value is int
# where json value is int
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=5"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=5"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
...
@@ -169,12 +185,58 @@ class TDTestCase:
...
@@ -169,12 +185,58 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'<54"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'<54"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'<=11"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'>4"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'>=5"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'!=5"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'!=55"
)
tdSql
.
checkRows
(
3
)
# where json value is double
# where json value is double
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=1.232"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=1.232"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'<1.232"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'<=1.232"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'>1.23"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'>=1.232"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'!=1.232"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'!=3.232"
)
tdSql
.
checkRows
(
3
)
tdSql
.
error
(
"select * from jsons1 where jtag->'tag1'/0=3"
)
tdSql
.
error
(
"select * from jsons1 where jtag->'tag1'/5=1"
)
# where json value is bool
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=true"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=false"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'!=false"
)
tdSql
.
checkRows
(
0
)
tdSql
.
error
(
"select * from jsons1 where jtag->'tag1'>false"
)
# where json value is null
# where json value is null
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=null"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=null"
)
# only json suport =null. This synatx will change later.
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
# where json 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
.
checkRows
(
8
)
# where json key is null
tdSql
.
query
(
"select * from jsons1 where jtag->'tag_no_exist'=3"
)
tdSql
.
checkRows
(
0
)
# where json value is not exist
# where json value is not exist
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1' is null"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1' is null"
)
tdSql
.
checkData
(
0
,
0
,
'jsons1_9'
)
tdSql
.
checkData
(
0
,
0
,
'jsons1_9'
)
...
@@ -184,55 +246,42 @@ class TDTestCase:
...
@@ -184,55 +246,42 @@ class TDTestCase:
tdSql
.
query
(
"select * from jsons1 where jtag->'tag3' is not null"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag3' is not null"
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkRows
(
4
)
# test ?
# test json tag in where condition with and/or/?
tdSql
.
query
(
"select * from jsons1 where jtag?'tag1'"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'location'!='beijing'"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from jsons1 where jtag?'tag3'"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select jtag->'num' from jsons1 where jtag->'level'='l1'"
)
tdSql
.
query
(
"select * from jsons1 where jtag?'tag_no_exist'"
)
tdSql
.
checkData
(
0
,
0
,
34
)
# test json number value
tdSql
.
query
(
"select *,tbname from jsons1 where jtag->'class'>5 and jtag->'class'<9"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select *,tbname from jsons1 where jtag->'class'>5 and jtag->'class'<92"
)
# test json tag in where condition with and/or
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='beijing'"
)
# test where condition
tdSql
.
query
(
"select * from jsons1 where jtag?'sex' or jtag?'num'"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select * from jsons1 where jtag?'sex' or jtag?'numww'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=false or jtag->'tag2'='beijing'"
)
tdSql
.
query
(
"select * from jsons1 where jtag?'sex' and jtag?'num'"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select jtag->'sex' from jsons1 where jtag?'sex' or jtag?'num'"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select *,tbname from jsons1 where jtag->'location'='beijing'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'"
)
tdSql
.
query
(
"select *,tbname from jsons1 where jtag->'num'=5 or jtag?'sex'"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'"
)
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'=13 or jtag->'tag2'>35"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1' is not null and jtag?'tag3'"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select * from jsons1 where jtag->'tag1'='femail' and jtag?'tag3'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select *,tbname from jsons1 where jtag->'num'=5"
)
# test with tbname/normal cloumn
tdSql
.
checkRows
(
1
)
# test with tbname
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1'"
)
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1'"
)
tdSql
.
checkRows
(
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' or jtag?'num'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
3
)
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?'num'"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1' and jtag?'tag3' and dataint=23"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from jsons1 where tbname = 'jsons1_1' or jtag->'num'=5"
)
tdSql
.
checkRows
(
2
)
# test where condition like
# test where condition like
tdSql
.
query
(
"select *,tbname from jsons1 where jtag->'location' like 'bei%'"
)
tdSql
.
query
(
"select *,tbname from jsons1 where jtag->'location' like 'bei%'"
)
...
@@ -298,11 +347,7 @@ class TDTestCase:
...
@@ -298,11 +347,7 @@ class TDTestCase:
tdSql
.
query
(
"select jtag from jsons1 where jtag->'k2'=true"
)
tdSql
.
query
(
"select jtag from jsons1 where jtag->'k2'=true"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select jtag from jsons1 where jtag is null"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select jtag from jsons1 where jtag is not null"
)
tdSql
.
checkRows
(
6
)
tdSql
.
query
(
"select * from jsons1 where jtag->'location' is not null"
)
tdSql
.
query
(
"select * from jsons1 where jtag->'location' is not null"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录