Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dlink
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaowei
dlink
Commits
c896db4b
Unverified
Commit
c896db4b
authored
Oct 28, 2022
by
ZackYoung
Committed by
GitHub
Oct 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[feature][udf]添加udf 使用文档 (#1177)
* 添加udf 使用文档 * 添加udf 使用文档
parent
8a41580e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
200 additions
and
0 deletions
+200
-0
_category_.json
docs/docs/udf_develop/_category_.json
+4
-0
Java&Scala.md
docs/docs/udf_develop/how_to/Java&Scala.md
+56
-0
Python.md
docs/docs/udf_develop/how_to/Python.md
+65
-0
_category_.json
docs/docs/udf_develop/how_to/_category_.json
+4
-0
intro.md
docs/docs/udf_develop/intro.md
+35
-0
template_intro.md
docs/docs/udf_develop/template_intro.md
+36
-0
No files found.
docs/docs/udf_develop/_category_.json
0 → 100644
View file @
c896db4b
{
"label"
:
"UDF 开发"
,
"position"
:
14
}
docs/docs/udf_develop/how_to/Java&Scala.md
0 → 100644
View file @
c896db4b
---
sidebar_position
:
1
id
:
java&scala_udf
title
:
Java&Scala UDF
---
## 作业创建
1.
选择java作业,并输入对应参数
```
text
sub
截取函数
com.test.SubFunction
```


> 此时从模板构建了代码,剩下函数逻辑填补即可。

> 这里为了方便测试,返回一段字符串
2.
接下来创建一个
`FlinkSql`
作业

创建函数时,复制类名,以下为测试代码
```
sql
create
temporary
function
sb_j
as
'com.test.SubFunction'
;
CREATE
TABLE
sourceTable
(
id
int
,
java_c
string
)
WITH
(
'connector'
=
'datagen'
);
CREATE
TABLE
sinkTable
WITH
(
'connector'
=
'print'
)
LIKE
sourceTable
(
EXCLUDING
ALL
);
insert
into
sinkTable
select
id
,
sb_j
(
java_c
)
from
sourceTable
;
```

> 选择执行模式,我这里采用 `pre-job` 进行演示
3.
执行,结果查看

查看
`Taskmanager`
输出,正常输出,验证成功
## 动图演示

\ No newline at end of file
docs/docs/udf_develop/how_to/Python.md
0 → 100644
View file @
c896db4b
---
sidebar_position
:
2
id
:
python_udf
title
:
Python UDF
---
## 作业创建
1.
选择 Python 作业,并输入对应参数
```
text
python_udf_test
python截取函数
SubFunction.f
```

> 注意名称,底层实现逻辑即通过名称创建 py 文件,如: python_udf_test.py

> 观察最右侧的类型,前缀就是 刚刚填的`名称`
2.
接下来创建一个
`FlinkSql`
作业
创建函数与Java不太一样, 最后得指定语言
language PYTHON
```
sql
create
temporary
function
sb_p
as
'python_udf_test.SubFunction'
language
PYTHON
;
CREATE
TABLE
sourceTable
(
id
int
,
python_c
string
)
WITH
(
'connector'
=
'datagen'
);
CREATE
TABLE
sinkTable
WITH
(
'connector'
=
'print'
)
LIKE
sourceTable
(
EXCLUDING
ALL
);
insert
into
sinkTable
select
id
,
sb_p
(
python_c
)
from
sourceTable
;
```

flink-conf.yml
```
yaml
python.client.executable
:
/root/miniconda3/bin/python3.8
python.executable
:
/root/miniconda3/bin/python3.8
```
> 这里需要注意的是,`flink-conf.yml` 得配置 `python` 的执行路径,`python` 环境必须包含 `apache-flink` ,支持 `python3.6 - python3.8`
>
> `python.executable` 是 NodeManager 环境的 python 执行路径
>
> `python.client.executable` 是 Dinky 当前机器所在的python环境
>
> 特别注意,`yarn-application` 环境,2个参数均是hadoop集群 python3 的执行路径
3.
执行,结果查看

## 动图演示

\ No newline at end of file
docs/docs/udf_develop/how_to/_category_.json
0 → 100644
View file @
c896db4b
{
"label"
:
"快速使用"
,
"position"
:
1
}
docs/docs/udf_develop/intro.md
0 → 100644
View file @
c896db4b
---
sidebar_position
:
1
id
:
udf_intro
title
:
UDF 功能简介
---
## 开发目的
在使用 flink 中,难免碰到 UDF 的场景。开发、编译、打包,注册函数、测试等一系列流水线操作,这些
都由 Dinky 接管后,只需要开发、测试即可。
目前 Dinky 在对此模块进行优化调整,并有了一个雏形,现阶段支持单类开发;
Dinky 将持续打造 UDF 开发,将来规划与 git接轨,实现在线开发。
> 1. UDF 目前还在孵化阶段,请谨慎使用;
>
> 2. 支持 `Python` 、`Java` 、 `Scala` 三种代码语言
>
> 3. Flink 模式现除了 `k8s application`不支持外,其余模式均可正常使用
---
## 使用方式
1.
在
`数据开发`
里面创建作业 , 然后选择
`Python`
、
`Java`
、
`Scala`
等即可
!
[
create_udf_work.png
](
http://www.aiwenmo.com/dinky/docs/zh-CN/udf_develop/create_udf_work.png
)
2.
udf 这边提供模板,方便快速创建,模板具体使用请看
[
udf 模板介绍
](
./udf_template_intro
)
!
[
create_udf_work2.png
](
http://www.aiwenmo.com/dinky/docs/zh-CN/udf_develop/create_udf_work2.png
)
---
## 操作演示

docs/docs/udf_develop/template_intro.md
0 → 100644
View file @
c896db4b
---
sidebar_position
:
2
id
:
udf_template_intro
title
:
UDF Template 介绍
---
## 开发目的
1.
为了减少代码复制,实现快速开发
## 使用方式
模板引擎框架采用
[
`Freemarker`
](
https://freemarker.apache.org/
)
1.
在
`配置中心 -> udf模板设置`
可调节对应模板。Dinky官方目前提供这几个模板,后续会不断迭代以及追加
!
[
template_intro.png
](
http://www.aiwenmo.com/dinky/docs/zh-CN/udf_develop/template_intro.png
)
2.
在编辑模板中,java、scala 提供 package、className参数,由类名解析而来;如:
`com.dinky.SubStringFunction`
,
对应解析成
```
${package}=com.dinky
${className}=SubStringFunction
```


3.
python 这边较为特殊,目前只有2个参数,如:
`SubStringFunction.f`
,对应为
```
${className}=SubStringFunction,
${attr}=f
```


\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment