-
Notifications
You must be signed in to change notification settings - Fork 319
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
Feat : Enable user-defined-java-function(UDF) #87
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
自定义UDF,尽可能减少用户使用成本。用户写UDF,import和使用的数据结构尽量是java 原生的,不需要额外import polardb-x 内部类(如果有有需要你编译优化的时候默默给他加上imprt)。输入行参和返回类型,尽量不需要显示定义。可以先把你的类编译成class,然后根据函数的输入和输出的对象,通过反射推导出java的原生类型是啥。
polardbx-calcite/src/main/java/org/apache/calcite/rel/ddl/CreateJavaFunction.java
Show resolved
Hide resolved
polardbx-calcite/src/main/java/org/apache/calcite/sql/SqlCreateJavaFunction.java
Show resolved
Hide resolved
…Carf/galaxysql into enable_user_defined_function
...rc/main/java/com/alibaba/polardbx/executor/handler/ddl/LogicalCreateJavaFunctionHandler.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问个问题:
CN 注册成功UDF后,可以正常使用。如果这个时候CN挂了,重启,那么这部分UDF应该会在CN重启的时候再次被注册到当前内存去,但这部分逻辑没有看到。意味着CN重启的时候,虽然metadb 有,但没有被动态加载?
polardbx-calcite/src/main/java/org/apache/calcite/sql/SqlDropJavaFunction.java
Show resolved
Hide resolved
.../src/test/java/com/alibaba/polardbx/qatest/ddl/userDefinedJavaFunction/JavaFunctionTest.java
Outdated
Show resolved
Hide resolved
.../src/test/java/com/alibaba/polardbx/qatest/ddl/userDefinedJavaFunction/JavaFunctionTest.java
Outdated
Show resolved
Hide resolved
...main/java/com/alibaba/polardbx/optimizer/core/expression/UserDefinedJavaFunctionManager.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUPPORT_MAX_REGISTER_UDF_NUM
防止用户注册非常多的UDF。
.../src/main/java/com/alibaba/polardbx/executor/handler/ddl/LogicalDropJavaFunctionHandler.java
Outdated
Show resolved
Hide resolved
|
Problems solved in this PR
Supporting CREATE FUNCTION and DROP FUNCTION syntax based on ScalaFunction, allowing users to define their own java functions and use them.
Changes proposed in this PR
UDF设计文档: https://drive.google.com/file/d/1IgL1BMlF_8leEvLbaBNOgQ9hUoQQxkxs/view?usp=sharing
UDF使用手册: https://drive.google.com/file/d/1UmTcmpIWvAb-AZFxWTQs877Nz6VA3AgA/view?usp=sharing
Tests
Release note
Issue link
#62