Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于flink sql执行groovy表达式的想法,不知能否实现呢 #33

Open
kongweiteng opened this issue Mar 25, 2021 · 1 comment

Comments

@kongweiteng
Copy link

哈喽你好,我有这么一个想发,不知道能否实现。
source :kafka
比如说kafka中的数据格式如下:
{
"A":1,
"B":2,
"C":3,
"D":4
}
我想在flink中能够根据kafka中已有的属性按照groovy表达式计算出一个新的属性,将新的属性一起sink到下游。
表达式示例1
得到属性:E
if(A != null && B != null) (A - B); else 0;
表达式示例2
得到属性 :F
if(A != null){if (A <= 100 && 0 < A ) yes ;else if (A <= 200&&100 < A ) no

最终得到

{
"A":1,
"B":2,
"C":3,
"D":4,
"E":-1,
"F": yes
}

并输出到下游

类似这样的需求不知道有没有什么实现的思路呢?

@ZhangChaoming
Copy link

@kongweiteng 这个有 SQL UDF 函数可以解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants