Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
333bbe73
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
333bbe73
编写于
3月 30, 2023
作者:
D
dapan1121
提交者:
GitHub
3月 30, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20669 from taosdata/szhou/python-udf-improvement
enhance: add language and body to ins_functions
上级
183d9bc4
dcf5f98b
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
50 addition
and
1 deletion
+50
-1
source/common/src/systable.c
source/common/src/systable.c
+2
-0
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+21
-0
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+7
-0
tests/script/tsim/query/udfpy.sim
tests/script/tsim/query/udfpy.sim
+19
-0
tests/system-test/2-query/odbc.py
tests/system-test/2-query/odbc.py
+1
-1
未找到文件。
source/common/src/systable.c
浏览文件 @
333bbe73
...
...
@@ -114,6 +114,8 @@ static const SSysDbTableSchema userFuncSchema[] = {
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
,
.
sysInfo
=
false
},
{.
name
=
"code_len"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
,
.
sysInfo
=
false
},
{.
name
=
"bufsize"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
,
.
sysInfo
=
false
},
{.
name
=
"func_language"
,
.
bytes
=
TSDB_TYPE_STR_MAX_LEN
-
1
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"func_body"
,
.
bytes
=
TSDB_MAX_BINARY_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
};
static
const
SSysDbTableSchema
userIdxSchema
[]
=
{
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
333bbe73
...
...
@@ -519,6 +519,7 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b2
,
false
);
taosMemoryFree
(
b2
);
}
else
{
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
NULL
,
true
);
...
...
@@ -545,6 +546,26 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pFunc
->
bufSize
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
char
*
language
=
""
;
if
(
pFunc
->
scriptType
==
TSDB_FUNC_SCRIPT_BIN_LIB
)
{
language
=
"C"
;
}
else
if
(
pFunc
->
scriptType
==
TSDB_FUNC_SCRIPT_PYTHON
)
{
language
=
"Python"
;
}
char
varLang
[
TSDB_TYPE_STR_MAX_LEN
+
1
]
=
{
0
};
varDataSetLen
(
varLang
,
strlen
(
language
));
strcpy
(
varDataVal
(
varLang
),
language
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
varLang
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
int32_t
varCodeLen
=
(
pFunc
->
codeSize
+
VARSTR_HEADER_SIZE
)
>
TSDB_MAX_BINARY_LEN
?
TSDB_MAX_BINARY_LEN
:
pFunc
->
codeSize
+
VARSTR_HEADER_SIZE
;
char
*
b4
=
taosMemoryMalloc
(
varCodeLen
);
memcpy
(
varDataVal
(
b4
),
pFunc
->
pCode
,
varCodeLen
-
VARSTR_HEADER_SIZE
);
varDataSetLen
(
b4
,
varCodeLen
-
VARSTR_HEADER_SIZE
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b4
,
false
);
taosMemoryFree
(
b4
);
numOfRows
++
;
sdbRelease
(
pSdb
,
pFunc
);
}
...
...
source/libs/function/src/tudf.c
浏览文件 @
333bbe73
...
...
@@ -1070,8 +1070,15 @@ int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols,
if
(
code
!=
0
)
{
return
code
;
}
SUdfcUvSession
*
session
=
handle
;
code
=
doCallUdfScalarFunc
(
handle
,
input
,
numOfCols
,
output
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
fnError
(
"udfc scalar function execution failure"
);
releaseUdfFuncHandle
(
udfName
);
return
code
;
}
if
(
output
->
columnData
==
NULL
)
{
fnError
(
"udfc scalar function calculate error. no column data"
);
code
=
TSDB_CODE_UDF_INVALID_OUTPUT_TYPE
;
...
...
tests/script/tsim/query/udfpy.sim
浏览文件 @
333bbe73
...
...
@@ -42,6 +42,25 @@ sql show functions;
if $rows != 4 then
return -1
endi
sql select func_language, func_body,name from information_schema.ins_functions order by name
if $rows != 4 then
return -1
endi
if $data00 != @C@ then
return -1
endi
if $data10 != @C@ then
return -1
endi
if $data20 != @Python@ then
return -1
endi
if $data30 != @Python@ then
return -1
endi
sql select bit_and(f, f) from t;
if $rows != 2 then
return -1
...
...
tests/system-test/2-query/odbc.py
浏览文件 @
333bbe73
...
...
@@ -22,7 +22,7 @@ class TDTestCase:
tdSql
.
execute
(
"insert into db.ctb using db.stb tags(1) (ts, c1) values (now, 1)"
)
tdSql
.
query
(
"select count(*) from information_schema.ins_columns"
)
tdSql
.
checkData
(
0
,
0
,
27
2
)
tdSql
.
checkData
(
0
,
0
,
27
4
)
tdSql
.
query
(
"select * from information_schema.ins_columns where table_name = 'ntb'"
)
tdSql
.
checkRows
(
14
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录