Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d48d98f0
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d48d98f0
编写于
5月 19, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fea:add select json logic
上级
6c26b623
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
12 deletion
+47
-12
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+17
-1
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+1
-1
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+1
-1
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+28
-9
未找到文件。
source/libs/executor/src/scanoperator.c
浏览文件 @
d48d98f0
...
...
@@ -295,10 +295,26 @@ void addTagPseudoColumnData(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock)
if
(
fmIsScanPseudoColumnFunc
(
functionId
))
{
setTbNameColData
(
pTableScanInfo
->
readHandle
.
meta
,
pBlock
,
pColInfoData
,
functionId
);
}
else
{
// these are tags
const
char
*
p
=
metaGetTableTagVal
(
&
mr
.
me
,
pExpr
->
base
.
pParam
[
0
].
pCol
->
colId
);
const
char
*
p
=
NULL
;
if
(
pColInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
){
const
uint8_t
*
tmp
=
mr
.
me
.
ctbEntry
.
pTags
;
char
*
data
=
taosMemoryCalloc
(
kvRowLen
(
tmp
)
+
1
,
1
);
if
(
data
==
NULL
){
qError
(
"doTagScan calloc error:%d"
,
kvRowLen
(
tmp
)
+
1
);
return
;
}
*
data
=
TSDB_DATA_TYPE_JSON
;
memcpy
(
data
+
1
,
tmp
,
kvRowLen
(
tmp
));
p
=
data
;
}
else
{
p
=
metaGetTableTagVal
(
&
mr
.
me
,
pExpr
->
base
.
pParam
[
0
].
pCol
->
colId
);
}
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
i
)
{
colDataAppend
(
pColInfoData
,
i
,
p
,
(
p
==
NULL
));
}
if
(
pColInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
){
taosMemoryFree
((
void
*
)
p
);
}
}
}
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
d48d98f0
...
...
@@ -899,7 +899,7 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
}
int32_t
code
=
0
;
SScalarCtx
ctx
=
{.
code
=
0
,
.
pBlockList
=
pBlockList
,
.
param
=
pDst
->
param
};
SScalarCtx
ctx
=
{.
code
=
0
,
.
pBlockList
=
pBlockList
,
.
param
=
pDst
?
pDst
->
param
:
NULL
};
// TODO: OPT performance
ctx
.
pRes
=
taosHashInit
(
SCL_DEFAULT_OP_NUM
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
d48d98f0
...
...
@@ -922,7 +922,7 @@ static void doReleaseVec(SColumnInfoData* pCol, int32_t type) {
}
}
char
*
getJsonValue
(
char
*
json
,
char
*
key
){
char
*
getJsonValue
(
char
*
json
,
char
*
key
){
//todo
json
++
;
// jump type
int16_t
cols
=
kvRowNCols
(
json
);
for
(
int
i
=
0
;
i
<
cols
;
++
i
)
{
...
...
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
d48d98f0
...
...
@@ -1035,7 +1035,7 @@ void makeJsonArrow(SSDataBlock **src, SNode **opNode, void *json, char *key){
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
;
scltMakeValueNode
(
&
pRight
,
TSDB_DATA_TYPE_BINARY
,
keyVar
);
scltMakeColumnNode
(
&
pLeft
,
src
,
TSDB_DATA_TYPE_JSON
,
varData
Len
(
json
),
1
,
json
);
scltMakeColumnNode
(
&
pLeft
,
src
,
TSDB_DATA_TYPE_JSON
,
kvRow
Len
(
json
),
1
,
json
);
scltMakeOpNode
(
opNode
,
OP_TYPE_JSON_GET_VALUE
,
TSDB_DATA_TYPE_JSON
,
pLeft
,
pRight
);
}
...
...
@@ -1088,18 +1088,17 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do
}
else
if
(
opType
==
OP_TYPE_ADD
||
opType
==
OP_TYPE_SUB
||
opType
==
OP_TYPE_MULTI
||
opType
==
OP_TYPE_DIV
||
opType
==
OP_TYPE_MOD
||
opType
==
OP_TYPE_MINUS
){
double
tmp
=
*
((
double
*
)
colDataGetData
(
column
,
0
));
ASSERT_TRUE
(
tmp
==
exceptValue
);
printf
(
"result:%lf
\n
"
,
tmp
);
printf
(
"1result:%f,except:%f
\n
"
,
*
((
double
*
)
colDataGetData
(
column
,
0
)),
exceptValue
);
ASSERT_TRUE
(
abs
(
*
((
double
*
)
colDataGetData
(
column
,
0
))
-
exceptValue
)
<
1e-15
);
}
else
if
(
opType
==
OP_TYPE_BIT_AND
||
opType
==
OP_TYPE_BIT_OR
){
printf
(
"2result:%ld,except:%f
\n
"
,
*
((
int64_t
*
)
colDataGetData
(
column
,
0
)),
exceptValue
);
ASSERT_EQ
(
*
((
int64_t
*
)
colDataGetData
(
column
,
0
)),
exceptValue
);
printf
(
"result:%ld
\n
"
,
*
((
int64_t
*
)
colDataGetData
(
column
,
0
)));
}
else
if
(
opType
==
OP_TYPE_GREATER_THAN
||
opType
==
OP_TYPE_GREATER_EQUAL
||
opType
==
OP_TYPE_LOWER_THAN
||
opType
==
OP_TYPE_LOWER_EQUAL
||
opType
==
OP_TYPE_EQUAL
||
opType
==
OP_TYPE_NOT_EQUAL
||
opType
==
OP_TYPE_IS_NULL
||
opType
==
OP_TYPE_IS_NOT_NULL
||
opType
==
OP_TYPE_IS_TRUE
||
opType
==
OP_TYPE_LIKE
||
opType
==
OP_TYPE_NOT_LIKE
||
opType
==
OP_TYPE_MATCH
||
opType
==
OP_TYPE_NMATCH
){
printf
(
"3result:%d,except:%f
\n
"
,
*
((
bool
*
)
colDataGetData
(
column
,
0
)),
exceptValue
);
ASSERT_EQ
(
*
((
bool
*
)
colDataGetData
(
column
,
0
)),
exceptValue
);
printf
(
"result:%d
\n
"
,
*
((
bool
*
)
colDataGetData
(
column
,
0
)));
}
taosArrayDestroyEx
(
blockList
,
scltFreeDataBlock
);
...
...
@@ -1114,6 +1113,13 @@ TEST(columnTest, json_column_arith_op) {
tdInitKVRowBuilder
(
&
kvRowBuilder
);
parseJsontoTagData
(
rightv
,
&
kvRowBuilder
,
NULL
,
0
);
SKVRow
row
=
tdGetKVRowFromBuilder
(
&
kvRowBuilder
);
char
*
tmp
=
(
char
*
)
taosMemoryRealloc
(
row
,
kvRowLen
(
row
)
+
1
);
if
(
tmp
==
NULL
){
ASSERT_TRUE
(
0
);
}
memmove
(
tmp
+
1
,
tmp
,
kvRowLen
(
tmp
));
*
tmp
=
TSDB_DATA_TYPE_JSON
;
row
=
tmp
;
const
int32_t
len
=
8
;
EOperatorType
op
[
len
]
=
{
OP_TYPE_ADD
,
OP_TYPE_SUB
,
OP_TYPE_MULTI
,
OP_TYPE_DIV
,
...
...
@@ -1166,6 +1172,9 @@ TEST(columnTest, json_column_arith_op) {
for
(
int
i
=
0
;
i
<
len
;
i
++
){
makeCalculate
(
row
,
key
,
TSDB_DATA_TYPE_INT
,
&
input
[
i
],
eRes5
[
i
],
op
[
i
]);
}
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
taosMemoryFree
(
row
);
}
void
*
prepareNchar
(
char
*
rightData
){
...
...
@@ -1186,6 +1195,13 @@ TEST(columnTest, json_column_logic_op) {
tdInitKVRowBuilder
(
&
kvRowBuilder
);
parseJsontoTagData
(
rightv
,
&
kvRowBuilder
,
NULL
,
0
);
SKVRow
row
=
tdGetKVRowFromBuilder
(
&
kvRowBuilder
);
char
*
tmp
=
(
char
*
)
taosMemoryRealloc
(
row
,
kvRowLen
(
row
)
+
1
);
if
(
tmp
==
NULL
){
ASSERT_TRUE
(
0
);
}
memmove
(
tmp
+
1
,
tmp
,
kvRowLen
(
tmp
));
*
tmp
=
TSDB_DATA_TYPE_JSON
;
row
=
tmp
;
const
int32_t
len
=
9
;
const
int32_t
len1
=
4
;
...
...
@@ -1223,7 +1239,7 @@ TEST(columnTest, json_column_logic_op) {
printf
(
"--------------------json null---------------------
\n
"
);
key
=
"k3"
;
double
eRes2
[
len
+
len1
]
=
{
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
true
,
false
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
};
bool
eRes2
[
len
+
len1
]
=
{
false
,
false
,
false
,
false
,
false
,
false
,
true
,
false
,
false
,
false
,
false
,
false
,
false
};
for
(
int
i
=
0
;
i
<
len
;
i
++
){
makeCalculate
(
row
,
key
,
TSDB_DATA_TYPE_INT
,
&
input
[
i
],
eRes2
[
i
],
op
[
i
]);
}
...
...
@@ -1262,7 +1278,7 @@ TEST(columnTest, json_column_logic_op) {
printf
(
"--------------------json double---------------------
\n
"
);
key
=
"k6"
;
bool
eRes5
[
len
+
len1
]
=
{
true
,
false
,
false
,
false
,
false
,
true
,
false
,
true
,
true
,
false
,
fals
e
,
false
,
true
};
bool
eRes5
[
len
+
len1
]
=
{
true
,
false
,
false
,
false
,
false
,
true
,
false
,
true
,
true
,
false
,
tru
e
,
false
,
true
};
for
(
int
i
=
0
;
i
<
len
;
i
++
){
makeCalculate
(
row
,
key
,
TSDB_DATA_TYPE_INT
,
&
input
[
i
],
eRes5
[
i
],
op
[
i
]);
}
...
...
@@ -1275,7 +1291,7 @@ TEST(columnTest, json_column_logic_op) {
printf
(
"---------------------json not exist--------------------
\n
"
);
key
=
"k10"
;
double
eRes10
[
len
+
len1
]
=
{
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
true
,
false
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
,
DBL_MAX
};
double
eRes10
[
len
+
len1
]
=
{
false
,
false
,
false
,
false
,
false
,
false
,
true
,
false
,
false
,
false
,
false
,
false
,
false
};
for
(
int
i
=
0
;
i
<
len
;
i
++
){
makeCalculate
(
row
,
key
,
TSDB_DATA_TYPE_INT
,
&
input
[
i
],
eRes10
[
i
],
op
[
i
]);
}
...
...
@@ -1284,6 +1300,9 @@ TEST(columnTest, json_column_logic_op) {
makeCalculate
(
row
,
key
,
TSDB_DATA_TYPE_NCHAR
,
rightData
,
eRes10
[
i
],
op
[
i
]);
taosMemoryFree
(
rightData
);
}
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
taosMemoryFree
(
row
);
}
TEST
(
columnTest
,
smallint_value_add_int_column
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录