flinkSQL 1.16.0 动态加载udf包(二)
编写udf的动态jar的代码要点
- jar包的依赖,不能与flink启动主类的冲突
- udf动态jar包编写
- 需要在udf的类上加上返回类型
@FunctionHint(output = @DataTypeHint("ROW<sentiment ROW<score Double,senti_label STRING>>"))
- 在TableFunction的输入
public class ABC extends TableFunction<Row>
- 在pom中不能不能加入flink的模板中的信息,不然会在类加载时启动改类
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>com.google.code.findbugs:jsr305</exclude>
</excludes>
</artifactSet>
<filters>
<filter>
<!-- Do not copy the signatures in the META-INF folder.
Otherwise, this might cause SecurityExceptions when using the JAR. -->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<!-- Replace this with the main class of your job -->
<mainClass>aaa.bbb.engine.CreateStreamTable</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
如果有错误,欢迎指正、交流 ,谢谢!